2012-06-07 16:08:47 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2010-12-18 20:33:32 +00:00
|
|
|
from django.contrib.localflavor.uy.forms import UYDepartamentSelect, UYCIField
|
|
|
|
from django.contrib.localflavor.uy.util import get_validation_digit
|
2010-01-01 21:31:47 +00:00
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
from django.test import SimpleTestCase
|
2010-01-01 21:31:47 +00:00
|
|
|
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
class UYLocalFlavorTests(SimpleTestCase):
|
2010-12-18 20:33:32 +00:00
|
|
|
def test_UYDepartmentSelect(self):
|
|
|
|
f = UYDepartamentSelect()
|
2012-06-07 16:08:47 +00:00
|
|
|
out = '''<select name="departamentos">
|
2010-12-18 20:33:32 +00:00
|
|
|
<option value="G">Artigas</option>
|
|
|
|
<option value="A">Canelones</option>
|
|
|
|
<option value="E">Cerro Largo</option>
|
|
|
|
<option value="L">Colonia</option>
|
|
|
|
<option value="Q">Durazno</option>
|
|
|
|
<option value="N">Flores</option>
|
|
|
|
<option value="O">Florida</option>
|
|
|
|
<option value="P">Lavalleja</option>
|
|
|
|
<option value="B">Maldonado</option>
|
|
|
|
<option value="S" selected="selected">Montevideo</option>
|
|
|
|
<option value="I">Paysand\xfa</option>
|
|
|
|
<option value="J">R\xedo Negro</option>
|
|
|
|
<option value="F">Rivera</option>
|
|
|
|
<option value="C">Rocha</option>
|
|
|
|
<option value="H">Salto</option>
|
|
|
|
<option value="M">San Jos\xe9</option>
|
|
|
|
<option value="K">Soriano</option>
|
|
|
|
<option value="R">Tacuaremb\xf3</option>
|
|
|
|
<option value="D">Treinta y Tres</option>
|
|
|
|
</select>'''
|
2012-01-31 20:36:11 +00:00
|
|
|
self.assertHTMLEqual(f.render('departamentos', 'S'), out)
|
2011-08-24 12:30:59 +00:00
|
|
|
|
2010-12-18 20:33:32 +00:00
|
|
|
def test_UYCIField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error_format = ['Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.']
|
|
|
|
error_invalid = ['Enter a valid CI number.']
|
2010-12-18 20:33:32 +00:00
|
|
|
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 = {
|
2012-06-07 16:08:47 +00:00
|
|
|
'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.'],
|
2010-12-18 20:33:32 +00:00
|
|
|
}
|
|
|
|
self.assertFieldOutput(UYCIField, valid, invalid)
|
|
|
|
self.assertEqual(get_validation_digit(409805), 3)
|
|
|
|
self.assertEqual(get_validation_digit(1005411), 2)
|