PageRenderTime 41ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/au.py

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