|
1 from django.contrib.localflavor.au.forms import (AUPostCodeField, |
|
2 AUPhoneNumberField, AUStateSelect) |
|
3 |
|
4 from utils import LocalFlavorTestCase |
|
5 |
|
6 |
|
7 class AULocalFlavorTests(LocalFlavorTestCase): |
|
8 def test_AUStateSelect(self): |
|
9 f = AUStateSelect() |
|
10 out = u'''<select name="state"> |
|
11 <option value="ACT">Australian Capital Territory</option> |
|
12 <option value="NSW" selected="selected">New South Wales</option> |
|
13 <option value="NT">Northern Territory</option> |
|
14 <option value="QLD">Queensland</option> |
|
15 <option value="SA">South Australia</option> |
|
16 <option value="TAS">Tasmania</option> |
|
17 <option value="VIC">Victoria</option> |
|
18 <option value="WA">Western Australia</option> |
|
19 </select>''' |
|
20 self.assertEqual(f.render('state', 'NSW'), out) |
|
21 |
|
22 def test_AUPostCodeField(self): |
|
23 error_format = [u'Enter a 4 digit post code.'] |
|
24 valid = { |
|
25 '1234': '1234', |
|
26 '2000': '2000', |
|
27 } |
|
28 invalid = { |
|
29 'abcd': error_format, |
|
30 '20001': error_format, |
|
31 } |
|
32 self.assertFieldOutput(AUPostCodeField, valid, invalid) |
|
33 |
|
34 def test_AUPhoneNumberField(self): |
|
35 error_format = [u'Phone numbers must contain 10 digits.'] |
|
36 valid = { |
|
37 '1234567890': '1234567890', |
|
38 '0213456789': '0213456789', |
|
39 '02 13 45 67 89': '0213456789', |
|
40 '(02) 1345 6789': '0213456789', |
|
41 '(02) 1345-6789': '0213456789', |
|
42 '(02)1345-6789': '0213456789', |
|
43 '0408 123 456': '0408123456', |
|
44 } |
|
45 invalid = { |
|
46 '123': error_format, |
|
47 '1800DJANGO': error_format, |
|
48 } |
|
49 self.assertFieldOutput(AUPhoneNumberField, valid, invalid) |
|
50 |