PageRenderTime 59ms CodeModel.GetById 54ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/pt.py

https://code.google.com/p/mango-py/
Python | 32 lines | 28 code | 4 blank | 0 comment | 0 complexity | 2ccd9c7afad2864ba9810758a89c4d9d MD5 | raw file
 1from django.contrib.localflavor.pt.forms import PTZipCodeField, PTPhoneNumberField
 2
 3from utils import LocalFlavorTestCase
 4
 5
 6class PTLocalFlavorTests(LocalFlavorTestCase):
 7    def test_PTZipCodeField(self):
 8        error_format = [u'Enter a zip code in the format XXXX-XXX.']
 9        valid = {
10            '3030-034': '3030-034',
11            '1003456': '1003-456',
12        }
13        invalid = {
14            '2A200': error_format,
15            '980001': error_format,
16        }
17        self.assertFieldOutput(PTZipCodeField, valid, invalid)
18
19    def test_PTPhoneNumberField(self):
20        error_format = [u'Phone numbers must have 9 digits, or start by + or 00']
21        valid = {
22            '917845189': '917845189',
23            '91 784 5189': '917845189',
24            '91 784 5189': '917845189',
25            '+351 91 111': '+35191111',
26            '00351873': '00351873',
27        }
28        invalid = {
29            '91 784 51 8': error_format,
30            '091 456 987 1': error_format,
31        }
32        self.assertFieldOutput(PTPhoneNumberField, valid, invalid)