def test_wrong_zaak_identificatie(self): should_fail = [ # Do not accept 0 padding in SIA id 'SIA-0', 'SIA-0.01', 'SIA-01', 'SIA-01.01', # Do not accept 0 as a sequence number 'SIA-1.00', # Too high sequence number (max two digits) 'SIA-1.100', # SIA id must be present 'SIA-.01', # Do not accept whitespace inside the SIA id and sequence number 'SIA- 123', 'SIA- 123.01', 'SIA-123. 01', 'SIA-123 .01', # Miscellaneous misspellings 'SII-111', 'SIA-99.05.02', 'SIA-99.05 .02', 'SIA-99.O5', ] for wrong_zaak_identificatie in should_fail: with self.assertRaises(ValueError): _parse_zaak_identificatie(wrong_zaak_identificatie)
def test_correct_zaak_identificatie(self): # Test backwards compatibility self.assertEqual(_parse_zaak_identificatie('SIA-111'), (111, None)) # Test new style self.assertEqual(_parse_zaak_identificatie('SIA-123.01'), (123, 1)) self.assertEqual(_parse_zaak_identificatie('SIA-99.05'), (99, 5)) # Accept extra white space before and/or after SIA id and sequence number self.assertEqual(_parse_zaak_identificatie('SIA-99.05 '), (99, 5)) self.assertEqual(_parse_zaak_identificatie(' SIA-99.05 '), (99, 5)) self.assertEqual(_parse_zaak_identificatie(' SIA-99.05'), (99, 5))
def test_incorrect_type(self): with self.assertRaises(ValueError): _parse_zaak_identificatie(None)
def test_empty_zaak_identificatie(self): with self.assertRaises(ValueError): _parse_zaak_identificatie('') with self.assertRaises(ValueError): _parse_zaak_identificatie('SIA-')