from __future__ import unicode_literals from django.contrib.localflavor.uy.forms import UYDepartamentSelect, UYCIField from django.contrib.localflavor.uy.util import get_validation_digit from django.test import SimpleTestCase class UYLocalFlavorTests(SimpleTestCase): def test_UYDepartmentSelect(self): f = UYDepartamentSelect() out = '''''' self.assertHTMLEqual(f.render('departamentos', 'S'), out) def test_UYCIField(self): error_format = ['Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.'] error_invalid = ['Enter a valid CI number.'] valid = { '4098053': '4098053', '409805-3': '409805-3', '409.805-3': '409.805-3', '10054112': '10054112', '1005411-2': '1005411-2', '1.005.411-2': '1.005.411-2', } invalid = { 'foo': ['Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.'], '409805-2': ['Enter a valid CI number.'], '1.005.411-5': ['Enter a valid CI number.'], } self.assertFieldOutput(UYCIField, valid, invalid) self.assertEqual(get_validation_digit(409805), 3) self.assertEqual(get_validation_digit(1005411), 2)