mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #15837. Consolidated all the locaflavor tests into a single, logical, place (regressiontests/localflavor/).
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16680 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import re
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test import SimpleTestCase
|
||||
from django.contrib.localflavor.au.forms import (AUPostCodeField,
|
||||
AUPhoneNumberField, AUStateSelect)
|
||||
|
||||
from forms import AustralianPlaceForm
|
||||
|
||||
SELECTED_OPTION_PATTERN = r'<option value="%s" selected="selected">'
|
||||
@@ -8,7 +11,8 @@ BLANK_OPTION_PATTERN = r'<option value="">'
|
||||
INPUT_VALUE_PATTERN = r'<input[^>]*value="%s"[^>]*>'
|
||||
|
||||
|
||||
class AULocalflavorTests(TestCase):
|
||||
class AULocalflavorTests(SimpleTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.form = AustralianPlaceForm(
|
||||
{'state':'WA',
|
||||
@@ -56,3 +60,46 @@ class AULocalflavorTests(TestCase):
|
||||
str(self.form['postcode'])))
|
||||
self.assertTrue(re.search(INPUT_VALUE_PATTERN % '4321',
|
||||
str(self.form['postcode_required'])))
|
||||
|
||||
def test_AUStateSelect(self):
|
||||
f = AUStateSelect()
|
||||
out = u'''<select name="state">
|
||||
<option value="ACT">Australian Capital Territory</option>
|
||||
<option value="NSW" selected="selected">New South Wales</option>
|
||||
<option value="NT">Northern Territory</option>
|
||||
<option value="QLD">Queensland</option>
|
||||
<option value="SA">South Australia</option>
|
||||
<option value="TAS">Tasmania</option>
|
||||
<option value="VIC">Victoria</option>
|
||||
<option value="WA">Western Australia</option>
|
||||
</select>'''
|
||||
self.assertEqual(f.render('state', 'NSW'), out)
|
||||
|
||||
def test_AUPostCodeField(self):
|
||||
error_format = [u'Enter a 4 digit postcode.']
|
||||
valid = {
|
||||
'1234': '1234',
|
||||
'2000': '2000',
|
||||
}
|
||||
invalid = {
|
||||
'abcd': error_format,
|
||||
'20001': [u'Ensure this value has at most 4 characters (it has 5).'] + error_format,
|
||||
}
|
||||
self.assertFieldOutput(AUPostCodeField, valid, invalid)
|
||||
|
||||
def test_AUPhoneNumberField(self):
|
||||
error_format = [u'Phone numbers must contain 10 digits.']
|
||||
valid = {
|
||||
'1234567890': '1234567890',
|
||||
'0213456789': '0213456789',
|
||||
'02 13 45 67 89': '0213456789',
|
||||
'(02) 1345 6789': '0213456789',
|
||||
'(02) 1345-6789': '0213456789',
|
||||
'(02)1345-6789': '0213456789',
|
||||
'0408 123 456': '0408123456',
|
||||
}
|
||||
invalid = {
|
||||
'123': error_format,
|
||||
'1800DJANGO': error_format,
|
||||
}
|
||||
self.assertFieldOutput(AUPhoneNumberField, valid, invalid)
|
||||
|
||||
Reference in New Issue
Block a user