1 | # -*- coding: utf-8 -*-
|
---|
2 | # Tests for the contrib/localflavor/ IL Form Fields
|
---|
3 |
|
---|
4 | tests = r"""
|
---|
5 | # CZPostalCodeField #########################################################
|
---|
6 |
|
---|
7 | >>> from django.contrib.localflavor.il.forms import ILPostalCodeField
|
---|
8 | >>> f = ILPostalCodeField()
|
---|
9 | >>> f.clean('84545x')
|
---|
10 | Traceback (most recent call last):
|
---|
11 | ...
|
---|
12 | ValidationError: [u'Enter a postal code in the format XXXXX']
|
---|
13 | >>> f.clean('69973')
|
---|
14 | u'69973'
|
---|
15 | >>> f.clean('699 73')
|
---|
16 | u'69973'
|
---|
17 | >>> f.clean('12345')
|
---|
18 | u'12345'
|
---|
19 | >>> f.clean('123456')
|
---|
20 | Traceback (most recent call last):
|
---|
21 | ...
|
---|
22 | ValidationError: [u'Enter a postal code in the format XXXXX']
|
---|
23 | >>> f.clean('1234')
|
---|
24 | Traceback (most recent call last):
|
---|
25 | ...
|
---|
26 | ValidationError: [u'Enter a postal code in the format XXXXX']
|
---|
27 | >>> f.clean('123 4')
|
---|
28 | Traceback (most recent call last):
|
---|
29 | ...
|
---|
30 | ValidationError: [u'Enter a postal code in the format XXXXX']
|
---|
31 |
|
---|
32 | # ILIDNumberField ########################################################
|
---|
33 |
|
---|
34 | >>> from django.contrib.localflavor.il.forms import ILIDNumberField
|
---|
35 | >>> f = ILIDNumberField()
|
---|
36 | >>> f.clean('39337423')
|
---|
37 | u'39337423'
|
---|
38 | >>> f.clean('039337423')
|
---|
39 | u'039337423'
|
---|
40 | >>> f.clean('0091')
|
---|
41 | u'0091'
|
---|
42 | >>> f.clean('123465789')
|
---|
43 | Traceback (most recent call last):
|
---|
44 | ...
|
---|
45 | ValidationError: [u'Enter a valid ID number.']
|
---|
46 | >>> f.clean('012346578')
|
---|
47 | Traceback (most recent call last):
|
---|
48 | ...
|
---|
49 | ValidationError: [u'Enter a valid ID number.']
|
---|
50 | >>> f.clean('0001')
|
---|
51 | Traceback (most recent call last):
|
---|
52 | ...
|
---|
53 | ValidationError: [u'Enter a valid ID number.']
|
---|
54 | """
|
---|