def test_umcn_invalid(self): """ Test that UMCNFields throw appropriate errors for invalid UMCNs. """ form = MKPersonForm({ 'first_name':'Someone', 'last_name':'Something', 'umcn': '2402983450007', 'municipality':'OD', 'municipality_req':'VE', 'id_number':'A1234567', }) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['umcn'], [u'The UMCN is not valid.']) form = MKPersonForm({ 'first_name':'Someone', 'last_name':'Something', 'umcn': '3002983450007', 'municipality':'OD', 'municipality_req':'VE', 'id_number':'A1234567', }) self.assertEqual(form.errors['umcn'], [u'The first 7 digits of the UMCN must represent a valid past date.'])
def test_umcn_invalid(self): """ Test that UMCNFields throw appropriate errors for invalid UMCNs. """ form = MKPersonForm({ 'first_name': 'Someone', 'last_name': 'Something', 'umcn': '2402983450007', 'municipality': 'OD', 'municipality_req': 'VE', 'id_number': 'A1234567', }) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['umcn'], [u'The UMCN is not valid.']) form = MKPersonForm({ 'first_name': 'Someone', 'last_name': 'Something', 'umcn': '3002983450007', 'municipality': 'OD', 'municipality_req': 'VE', 'id_number': 'A1234567', }) self.assertEqual(form.errors['umcn'], [ u'The first 7 digits of the UMCN must represent a valid past date.' ])
def test_municipality_required(self): """Test that required MKMunicipalityFields throw appropriate errors.""" form = MKPersonForm({'first_name':'Someone', 'last_name':'Something', 'umcn': '2402983450006', 'municipality':'OD', 'id_number':'A1234567'}) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['municipality_req'], [u'This field is required.'])
def test_idnumber_invalid(self): """Test that MKIdentityCardNumberFields throw appropriate errors for invalid values""" form = MKPersonForm({'first_name':'Someone', 'last_name':'Something', 'umcn': '2402983450007', 'municipality':'OD', 'municipality_req':'VE', 'id_number':'A123456a'}) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['id_number'],\ [u'Identity card numbers must contain'\ ' either 4 to 7 digits or an uppercase letter and 7 digits.'])
def test_municipality_required(self): """Test that required MKMunicipalityFields throw appropriate errors.""" form = MKPersonForm({ 'first_name': 'Someone', 'last_name': 'Something', 'umcn': '2402983450006', 'municipality': 'OD', 'id_number': 'A1234567' }) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['municipality_req'], [u'This field is required.'])
def test_idnumber_invalid(self): """Test that MKIdentityCardNumberFields throw appropriate errors for invalid values""" form = MKPersonForm({ 'first_name': 'Someone', 'last_name': 'Something', 'umcn': '2402983450007', 'municipality': 'OD', 'municipality_req': 'VE', 'id_number': 'A123456a' }) self.assertFalse(form.is_valid()) self.assertEqual(form.errors['id_number'],\ [u'Identity card numbers must contain'\ ' either 4 to 7 digits or an uppercase letter and 7 digits.'])