from django.contrib.localflavor.mk.forms import ( MKIdentityCardNumberField, MKMunicipalitySelect, UMCNField) from utils import LocalFlavorTestCase class MKLocalFlavorTests(LocalFlavorTestCase): def test_MKIdentityCardNumberField(self): error_invalid = [u'Identity card numbers must contain either 4 to 7 ' 'digits or an uppercase letter and 7 digits.'] valid = { 'L0018077':'L0018077', 'A0078315' : 'A0078315', } invalid = { '123': error_invalid, 'abcdf': error_invalid, '234390a': error_invalid, } self.assertFieldOutput(MKIdentityCardNumberField, valid, invalid) def test_MKMunicipalitySelect(self): f = MKMunicipalitySelect() out=u'''''' self.assertEqual(f.render('municipality', 'DL' ), out) def test_UMCNField(self): error_invalid = [u'This field should contain exactly 13 digits.'] error_checksum = [u'The UMCN is not valid.'] error_date = [u'The first 7 digits of the UMCN ' 'must represent a valid past date.'] valid = { '2402983450006': '2402983450006', '2803984430038': '2803984430038', '1909982045004': '1909982045004', } invalid = { '240298345': error_invalid, 'abcdefghj': error_invalid, '2402082450006': error_date, '3002982450006': error_date, '2402983450007': error_checksum, '2402982450006': error_checksum, } self.assertFieldOutput(UMCNField, valid, invalid)