Repository: identique/idnumbers (language: python)

Issue:
id number for Montenegro
https://en.wikipedia.org/wiki/National_identification_number#Montenegro


Discussion / hints:

Fix patch:
diff --git a/idnumbers/nationalid/MNE.py b/idnumbers/nationalid/MNE.py
new file mode 100644
index 00000000..eb4bb5f5
--- /dev/null
+++ b/idnumbers/nationalid/MNE.py
@@ -0,0 +1,53 @@
+from copy import copy
+from typing import Optional, Tuple
+from .constant import Citizenship
+
+from .yugoslavia import ParseResult, UniqueMasterCitizenNumber as YugoslaviaJMBG
+
+MNE_METADATA = copy(YugoslaviaJMBG.METADATA)
+MNE_METADATA.iso3166_alpha2 = 'ME'
+
+
+class UniqueMasterCitizenNumber(YugoslaviaJMBG):
+    """
+    Montenegro Unique Master Citizen Number format, JMBG
+    https://en.wikipedia.org/wiki/Unique_Master_Citizen_Number
+    """
+    METADATA = MNE_METADATA
+
+    @staticmethod
+    def parse(id_number: str) -> Optional[ParseResult]:
+        """parse the value"""
+        result = YugoslaviaJMBG.parse(id_number)
+        if not result:
+            return None
+        loc_citizenship = UniqueMasterCitizenNumber.check_location(result['location'])
+        if not loc_citizenship:
+            return None
+        citizenship, location = loc_citizenship
+        result['citizenship'] = citizenship
+        return result
+
+    @staticmethod
+    def check_location(location: str) -> Optional[Tuple[Citizenship, str]]:
+        result = YugoslaviaJMBG.check_location(location)
+        if not result:
+            return None
+        """
+        Since the North Macedonia is an independent country, they share the same id code base. So, the citizenship
+        is 20 < location < 30
+        """
+        if 20 < int(location) < 30:
+            return Citizenship.CITIZEN, location
+        return Citizenship.RESIDENT, location
+
+
+JMBG = UniqueMasterCitizenNumber
+"""
+Alias of UniqueMasterCitizenNumber
+"""
+
+NationalID = UniqueMasterCitizenNumber
+"""
+Alias of UniqueMasterCitizenNumber
+"""


Test patch:
diff --git a/tests/nationalid/test_SVN.py b/tests/nationalid/test_SVN.py
index de6e8217..b18b2c0e 100644
--- a/tests/nationalid/test_SVN.py
+++ b/tests/nationalid/test_SVN.py
@@ -6,7 +6,7 @@
 
 class TestSVNValidation(TestCase):
     """
-    It tests for SVN, SRB, MKD
+    It tests for SVN, SRB, MKD, MNE
     """
     def test_normal_case(self):
         self.assertTrue(SVN.UniqueMasterCitizenNumber.validate('0101006500006'))