Ejemplo n.º 1
0
def validate_gemeentecode(value: str):
    # Try to lookup a valid gemeente for the supplied value
    try:
        CodeResolver.get_gemeente(value)
    except DataItemNotFoundException:
        return False
    return True
Ejemplo n.º 2
0
    def test_get_land(self):
        for method_name in ['get_land', 'get_gemeente']:
            method = getattr(CodeResolver, method_name)

            result = method("")
            self.assertIsNone(result)

            result = method(None)
            self.assertIsNone(result)

            with self.assertRaises(DataItemNotFoundException):
                result = method("any code")

        CodeResolver._landen['any code'] = {'omschrijving': 'any land'}
        result = CodeResolver.get_land("any code")
        self.assertEqual(result, 'any land')

        # Pad codes to 4 characters
        CodeResolver._landen['0002'] = {'omschrijving': 'any land'}
        for code in ['2', '02', '002']:
            CodeResolver.get_land(code)
            self.assertIsNone(CodeResolver._landen.get(code))
Ejemplo n.º 3
0
    def test_get_gemeente_code(self):
        method = CodeResolver.get_gemeente_code
        result = method("")
        self.assertIsNone(result)

        result = method(None)
        self.assertIsNone(result)

        with self.assertRaises(DataItemNotFoundException):
            result = method("any code")

        CodeResolver._gemeenten_omschrijving['any omschrijving'] = {
            'code': 'any code'
        }
        result = CodeResolver.get_gemeente_code("any omschrijving")
        self.assertEqual(result, 'any code')
Ejemplo n.º 4
0
 def get_adellijke_titel_code(cls, mks_omschrijving):
     return CodeResolver.get_adellijke_titel_code(mks_omschrijving)
Ejemplo n.º 5
0
 def get_gemeente_code(cls, omschrijving):
     return CodeResolver.get_gemeente_code(omschrijving)
Ejemplo n.º 6
0
 def test_load_landen(self, mock_open):
     mock_open.side_effect = FileNotFoundError
     with self.assertRaises(DataNotFoundException):
         CodeResolver._load_data(CodeResolver.LANDEN, CodeResolver.CODE)
     with self.assertRaises(DataNotFoundException):
         CodeResolver._load_data(CodeResolver.GEMEENTEN, CodeResolver.CODE)