from django.contrib.localflavor.fi.forms import (FIZipCodeField, FISocialSecurityNumber, FIMunicipalitySelect) from django.test import SimpleTestCase class FILocalFlavorTests(SimpleTestCase): def test_FIMunicipalitySelect(self): f = FIMunicipalitySelect() out = u'''''' self.assertEqual(f.render('municipalities', 'turku'), out) def test_FIZipCodeField(self): error_format = [u'Enter a zip code in the format XXXXX.'] valid = { '20540': '20540', '20101': '20101', } invalid = { '20s40': error_format, '205401': error_format } self.assertFieldOutput(FIZipCodeField, valid, invalid) def test_FISocialSecurityNumber(self): error_invalid = [u'Enter a valid Finnish social security number.'] valid = { '010101-0101': '010101-0101', '010101+0101': '010101+0101', '010101A0101': '010101A0101', } invalid = { '101010-0102': error_invalid, '10a010-0101': error_invalid, '101010-0\xe401': error_invalid, '101010b0101': error_invalid, } self.assertFieldOutput(FISocialSecurityNumber, valid, invalid)