PageRenderTime 17ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/il.py

https://code.google.com/p/mango-py/
Python | 39 lines | 35 code | 4 blank | 0 comment | 0 complexity | b9b79dfae38629ac264479d27054f190 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.contrib.localflavor.il.forms import (ILPostalCodeField,
  2. ILIDNumberField)
  3. from utils import LocalFlavorTestCase
  4. class ILLocalFlavorTests(LocalFlavorTestCase):
  5. def test_ILPostalCodeField(self):
  6. error_format = [u'Enter a postal code in the format XXXXX']
  7. valid = {
  8. '69973': '69973',
  9. '699 73': '69973',
  10. '12345': '12345',
  11. }
  12. invalid = {
  13. '84545x': error_format,
  14. '123456': error_format,
  15. '1234': error_format,
  16. '123 4': error_format,
  17. }
  18. self.assertFieldOutput(ILPostalCodeField, valid, invalid)
  19. def test_ILIDNumberField(self):
  20. error_invalid = [u'Enter a valid ID number.']
  21. valid = {
  22. '3933742-3': '39337423',
  23. '39337423': '39337423',
  24. '039337423': '039337423',
  25. '03933742-3': '039337423',
  26. '0091': '0091',
  27. }
  28. invalid = {
  29. '123456789': error_invalid,
  30. '12345678-9': error_invalid,
  31. '012346578': error_invalid,
  32. '012346578-': error_invalid,
  33. '0001': error_invalid,
  34. }
  35. self.assertFieldOutput(ILIDNumberField, valid, invalid)