PageRenderTime 47ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/at.py

https://code.google.com/p/mango-py/
Python | 45 lines | 42 code | 3 blank | 0 comment | 0 complexity | e8977e102ab8f70a0865009aa68ca2bd MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.contrib.localflavor.at.forms import (ATZipCodeField, ATStateSelect,
  2. ATSocialSecurityNumberField)
  3. from utils import LocalFlavorTestCase
  4. class ATLocalFlavorTests(LocalFlavorTestCase):
  5. def test_ATStateSelect(self):
  6. f = ATStateSelect()
  7. out = u'''<select name="bundesland">
  8. <option value="BL">Burgenland</option>
  9. <option value="KA">Carinthia</option>
  10. <option value="NO">Lower Austria</option>
  11. <option value="OO">Upper Austria</option>
  12. <option value="SA">Salzburg</option>
  13. <option value="ST">Styria</option>
  14. <option value="TI">Tyrol</option>
  15. <option value="VO">Vorarlberg</option>
  16. <option value="WI" selected="selected">Vienna</option>
  17. </select>'''
  18. self.assertEqual(f.render('bundesland', 'WI'), out)
  19. def test_ATZipCodeField(self):
  20. error_format = [u'Enter a zip code in the format XXXX.']
  21. valid = {
  22. '1150': '1150',
  23. '4020': '4020',
  24. '8020': '8020',
  25. }
  26. invalid = {
  27. '111222': error_format,
  28. 'eeffee': error_format,
  29. }
  30. self.assertFieldOutput(ATZipCodeField, valid, invalid)
  31. def test_ATSocialSecurityNumberField(self):
  32. error_format = [u'Enter a valid Austrian Social Security Number in XXXX XXXXXX format.']
  33. valid = {
  34. '1237 010180': '1237 010180',
  35. }
  36. invalid = {
  37. '1237 010181': error_format,
  38. '12370 010180': error_format,
  39. }
  40. self.assertFieldOutput(ATSocialSecurityNumberField, valid, invalid)