PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/uy.py

https://code.google.com/p/mango-py/
Python | 52 lines | 49 code | 3 blank | 0 comment | 4 complexity | 5aed3941e36bf9227159fc907ee675a9 MD5 | raw file
 1from django.contrib.localflavor.uy.forms import UYDepartamentSelect, UYCIField
 2from django.contrib.localflavor.uy.util import get_validation_digit
 3
 4from utils import LocalFlavorTestCase
 5
 6
 7class UYLocalFlavorTests(LocalFlavorTestCase):
 8    def test_UYDepartmentSelect(self):
 9        f = UYDepartamentSelect()
10        out = u'''<select name="departamentos">
11<option value="G">Artigas</option>
12<option value="A">Canelones</option>
13<option value="E">Cerro Largo</option>
14<option value="L">Colonia</option>
15<option value="Q">Durazno</option>
16<option value="N">Flores</option>
17<option value="O">Florida</option>
18<option value="P">Lavalleja</option>
19<option value="B">Maldonado</option>
20<option value="S" selected="selected">Montevideo</option>
21<option value="I">Paysand\xfa</option>
22<option value="J">R\xedo Negro</option>
23<option value="F">Rivera</option>
24<option value="C">Rocha</option>
25<option value="H">Salto</option>
26<option value="M">San Jos\xe9</option>
27<option value="K">Soriano</option>
28<option value="R">Tacuaremb\xf3</option>
29<option value="D">Treinta y Tres</option>
30</select>'''
31        self.assertEqual(f.render('departamentos', 'S'), out)
32    
33    def test_UYCIField(self):
34        error_format = [u'Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.']
35        error_invalid = [u'Enter a valid CI number.']
36        valid = {
37            '4098053': '4098053',
38            '409805-3': '409805-3',
39            '409.805-3': '409.805-3',
40            '10054112': '10054112',
41            '1005411-2': '1005411-2',
42            '1.005.411-2': '1.005.411-2',
43        }
44        invalid = {
45            'foo': [u'Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.'],
46            '409805-2': [u'Enter a valid CI number.'],
47            '1.005.411-5': [u'Enter a valid CI number.'],
48        }
49        self.assertFieldOutput(UYCIField, valid, invalid)
50        self.assertEqual(get_validation_digit(409805), 3)
51        self.assertEqual(get_validation_digit(1005411), 2)
52