1
# -*- coding: utf-8 -*-
2
# Tests for the contrib/localflavor/ AU form fields.
5
## AUPostCodeField ##########################################################
7
A field that accepts a four digit Australian post code.
9
>>> from django.contrib.localflavor.au.forms import AUPostCodeField
10
>>> f = AUPostCodeField()
16
Traceback (most recent call last):
18
ValidationError: [u'Enter a 4 digit post code.']
20
Traceback (most recent call last):
22
ValidationError: [u'Enter a 4 digit post code.']
24
Traceback (most recent call last):
26
ValidationError: [u'This field is required.']
28
Traceback (most recent call last):
30
ValidationError: [u'This field is required.']
32
>>> f = AUPostCodeField(required=False)
38
Traceback (most recent call last):
40
ValidationError: [u'Enter a 4 digit post code.']
42
Traceback (most recent call last):
44
ValidationError: [u'Enter a 4 digit post code.']
50
## AUPhoneNumberField ########################################################
52
A field that accepts a 10 digit Australian phone number.
53
llows spaces and parentheses around area code.
55
>>> from django.contrib.localflavor.au.forms import AUPhoneNumberField
56
>>> f = AUPhoneNumberField()
57
>>> f.clean('1234567890')
59
>>> f.clean('0213456789')
61
>>> f.clean('02 13 45 67 89')
63
>>> f.clean('(02) 1345 6789')
65
>>> f.clean('(02) 1345-6789')
67
>>> f.clean('(02)1345-6789')
69
>>> f.clean('0408 123 456')
72
Traceback (most recent call last):
74
ValidationError: [u'Phone numbers must contain 10 digits.']
75
>>> f.clean('1800DJANGO')
76
Traceback (most recent call last):
78
ValidationError: [u'Phone numbers must contain 10 digits.']
80
Traceback (most recent call last):
82
ValidationError: [u'This field is required.']
84
Traceback (most recent call last):
86
ValidationError: [u'This field is required.']
88
>>> f = AUPhoneNumberField(required=False)
89
>>> f.clean('1234567890')
91
>>> f.clean('0213456789')
93
>>> f.clean('02 13 45 67 89')
95
>>> f.clean('(02) 1345 6789')
97
>>> f.clean('(02) 1345-6789')
99
>>> f.clean('(02)1345-6789')
101
>>> f.clean('0408 123 456')
104
Traceback (most recent call last):
106
ValidationError: [u'Phone numbers must contain 10 digits.']
107
>>> f.clean('1800DJANGO')
108
Traceback (most recent call last):
110
ValidationError: [u'Phone numbers must contain 10 digits.']
116
## AUStateSelect #############################################################
118
AUStateSelect is a Select widget that uses a list of Australian
119
states/territories as its choices.
121
>>> from django.contrib.localflavor.au.forms import AUStateSelect
122
>>> f = AUStateSelect()
123
>>> print f.render('state', 'NSW')
124
<select name="state">
125
<option value="ACT">Australian Capital Territory</option>
126
<option value="NSW" selected="selected">New South Wales</option>
127
<option value="NT">Northern Territory</option>
128
<option value="QLD">Queensland</option>
129
<option value="SA">South Australia</option>
130
<option value="TAS">Tasmania</option>
131
<option value="VIC">Victoria</option>
132
<option value="WA">Western Australia</option>