Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #15837. Consolidated all the locaflavor tests into a single, lo…

…gical, place (regressiontests/localflavor/).

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16680 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit a3fd9cf288e71b9c8e5fb6479eda3d33bc0a9d65 1 parent ec1226b
@jphalip jphalip authored
Showing with 483 additions and 554 deletions.
  1. +0 −1  tests/regressiontests/forms/localflavor/__init__.py
  2. +0 −50 tests/regressiontests/forms/localflavor/au.py
  3. +0 −131 tests/regressiontests/forms/localflavor/mk.py
  4. +0 −127 tests/regressiontests/forms/localflavor/mx.py
  5. +0 −129 tests/regressiontests/forms/localflavor/us.py
  6. +0 −42 tests/regressiontests/forms/localflavortests.py
  7. +0 −44 tests/regressiontests/forms/tests/__init__.py
  8. 0  tests/regressiontests/localflavor/ar/__init__.py
  9. 0  tests/regressiontests/{forms/localflavor/ar.py → localflavor/ar/tests.py}
  10. 0  tests/regressiontests/localflavor/at/__init__.py
  11. 0  tests/regressiontests/{forms/localflavor/at.py → localflavor/at/tests.py}
  12. +49 −2 tests/regressiontests/localflavor/au/tests.py
  13. 0  tests/regressiontests/localflavor/be/__init__.py
  14. 0  tests/regressiontests/{forms/localflavor/be.py → localflavor/be/tests.py}
  15. 0  tests/regressiontests/localflavor/br/__init__.py
  16. 0  tests/regressiontests/{forms/localflavor/br.py → localflavor/br/tests.py}
  17. 0  tests/regressiontests/localflavor/ca/__init__.py
  18. 0  tests/regressiontests/{forms/localflavor/ca.py → localflavor/ca/tests.py}
  19. 0  tests/regressiontests/localflavor/ch/__init__.py
  20. +3 −4 tests/regressiontests/{forms/localflavor/ch.py → localflavor/ch/tests.py}
  21. 0  tests/regressiontests/localflavor/cl/__init__.py
  22. 0  tests/regressiontests/{forms/localflavor/cl.py → localflavor/cl/tests.py}
  23. 0  tests/regressiontests/localflavor/cn/__init__.py
  24. +0 −1  tests/regressiontests/{forms/localflavor/cn.py → localflavor/cn/tests.py}
  25. 0  tests/regressiontests/localflavor/co/__init__.py
  26. 0  tests/regressiontests/{forms/localflavor/co.py → localflavor/co/tests.py}
  27. 0  tests/regressiontests/localflavor/cz/__init__.py
  28. 0  tests/regressiontests/{forms/localflavor/cz.py → localflavor/cz/tests.py}
  29. 0  tests/regressiontests/localflavor/de/__init__.py
  30. 0  tests/regressiontests/{forms/localflavor/de.py → localflavor/de/tests.py}
  31. 0  tests/regressiontests/localflavor/ec/__init__.py
  32. 0  tests/regressiontests/{forms/localflavor/ec.py → localflavor/ec/tests.py}
  33. 0  tests/regressiontests/localflavor/es/__init__.py
  34. +1 −3 tests/regressiontests/{forms/localflavor/es.py → localflavor/es/tests.py}
  35. 0  tests/regressiontests/localflavor/fi/__init__.py
  36. +0 −1  tests/regressiontests/{forms/localflavor/fi.py → localflavor/fi/tests.py}
  37. 0  tests/regressiontests/localflavor/fr/__init__.py
  38. 0  tests/regressiontests/{forms/localflavor/fr.py → localflavor/fr/tests.py}
  39. 0  tests/regressiontests/localflavor/gb/__init__.py
  40. 0  tests/regressiontests/{forms/localflavor/gb.py → localflavor/gb/tests.py}
  41. 0  tests/regressiontests/localflavor/generic/__init__.py
  42. 0  tests/regressiontests/{forms/localflavor/generic.py → localflavor/generic/tests.py}
  43. 0  tests/regressiontests/localflavor/hr/__init__.py
  44. 0  tests/regressiontests/{forms/localflavor/hr.py → localflavor/hr/tests.py}
  45. 0  tests/regressiontests/localflavor/id/__init__.py
  46. 0  tests/regressiontests/{forms/localflavor/id.py → localflavor/id/tests.py}
  47. 0  tests/regressiontests/localflavor/ie/__init__.py
  48. 0  tests/regressiontests/{forms/localflavor/ie.py → localflavor/ie/tests.py}
  49. 0  tests/regressiontests/localflavor/il/__init__.py
  50. 0  tests/regressiontests/{forms/localflavor/il.py → localflavor/il/tests.py}
  51. 0  tests/regressiontests/localflavor/in_/__init__.py
  52. 0  tests/regressiontests/{forms/localflavor/in_.py → localflavor/in_/tests.py}
  53. 0  tests/regressiontests/localflavor/is_/__init__.py
  54. +3 −4 tests/regressiontests/{forms/localflavor/is_.py → localflavor/is_/tests.py}
  55. 0  tests/regressiontests/localflavor/it/__init__.py
  56. +2 −3 tests/regressiontests/{forms/localflavor/it.py → localflavor/it/tests.py}
  57. 0  tests/regressiontests/localflavor/jp/__init__.py
  58. 0  tests/regressiontests/{forms/localflavor/jp.py → localflavor/jp/tests.py}
  59. 0  tests/regressiontests/localflavor/kw/__init__.py
  60. +0 −1  tests/regressiontests/{forms/localflavor/kw.py → localflavor/kw/tests.py}
  61. +130 −2 tests/regressiontests/localflavor/mk/tests.py
  62. 0  tests/regressiontests/localflavor/mx/mx.py
  63. +126 −2 tests/regressiontests/localflavor/mx/tests.py
  64. 0  tests/regressiontests/localflavor/nl/__init__.py
  65. 0  tests/regressiontests/{forms/localflavor/nl.py → localflavor/nl/tests.py}
  66. 0  tests/regressiontests/localflavor/pl/__init__.py
  67. 0  tests/regressiontests/{forms/localflavor/pl.py → localflavor/pl/tests.py}
  68. 0  tests/regressiontests/localflavor/pt/__init__.py
  69. 0  tests/regressiontests/{forms/localflavor/pt.py → localflavor/pt/tests.py}
  70. 0  tests/regressiontests/localflavor/py/__init__.py
  71. 0  tests/regressiontests/{forms/localflavor/py.py → localflavor/py/tests.py}
  72. 0  tests/regressiontests/localflavor/ro/__init__.py
  73. 0  tests/regressiontests/{forms/localflavor/ro.py → localflavor/ro/tests.py}
  74. 0  tests/regressiontests/localflavor/ru/__init__.py
  75. +1 −1  tests/regressiontests/{forms/localflavor/ru.py → localflavor/ru/tests.py}
  76. 0  tests/regressiontests/localflavor/se/__init__.py
  77. +0 −1  tests/regressiontests/{forms/localflavor/se.py → localflavor/se/tests.py}
  78. 0  tests/regressiontests/localflavor/sk/__init__.py
  79. 0  tests/regressiontests/{forms/localflavor/sk.py → localflavor/sk/tests.py}
  80. +37 −1 tests/regressiontests/localflavor/tests.py
  81. 0  tests/regressiontests/localflavor/tr/__init__.py
  82. 0  tests/regressiontests/{forms/localflavor/tr.py → localflavor/tr/tests.py}
  83. +130 −2 tests/regressiontests/localflavor/us/tests.py
  84. 0  tests/regressiontests/localflavor/uy/__init__.py
  85. +1 −2  tests/regressiontests/{forms/localflavor/uy.py → localflavor/uy/tests.py}
  86. 0  tests/regressiontests/localflavor/za/__init__.py
  87. 0  tests/regressiontests/{forms/localflavor/za.py → localflavor/za/tests.py}
View
1  tests/regressiontests/forms/localflavor/__init__.py
@@ -1 +0,0 @@
-#
View
50 tests/regressiontests/forms/localflavor/au.py
@@ -1,50 +0,0 @@
-from django.contrib.localflavor.au.forms import (AUPostCodeField,
- AUPhoneNumberField, AUStateSelect)
-
-from django.test import SimpleTestCase
-
-
-class AULocalFlavorTests(SimpleTestCase):
- 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)
-
View
131 tests/regressiontests/forms/localflavor/mk.py
@@ -1,131 +0,0 @@
-from django.contrib.localflavor.mk.forms import (
- MKIdentityCardNumberField, MKMunicipalitySelect, UMCNField)
-
-from django.test import SimpleTestCase
-
-
-class MKLocalFlavorTests(SimpleTestCase):
-
- def test_MKIdentityCardNumberField(self):
- error_invalid = [u'Identity card numbers must contain either 4 to 7 '
- 'digits or an uppercase letter and 7 digits.']
- valid = {
- 'L0018077':'L0018077',
- 'A0078315' : 'A0078315',
- }
- invalid = {
- '123': error_invalid,
- 'abcdf': error_invalid,
- '234390a': error_invalid,
- }
- self.assertFieldOutput(MKIdentityCardNumberField, valid, invalid)
-
- def test_MKMunicipalitySelect(self):
- f = MKMunicipalitySelect()
- out=u'''<select name="municipality">
-<option value="AD">Aerodrom</option>
-<option value="AR">Ara\u010dinovo</option>
-<option value="BR">Berovo</option>
-<option value="TL">Bitola</option>
-<option value="BG">Bogdanci</option>
-<option value="VJ">Bogovinje</option>
-<option value="BS">Bosilovo</option>
-<option value="BN">Brvenica</option>
-<option value="BU">Butel</option>
-<option value="VA">Valandovo</option>
-<option value="VL">Vasilevo</option>
-<option value="VV">Vev\u010dani</option>
-<option value="VE">Veles</option>
-<option value="NI">Vinica</option>
-<option value="VC">Vrane\u0161tica</option>
-<option value="VH">Vrap\u010di\u0161te</option>
-<option value="GB">Gazi Baba</option>
-<option value="GV">Gevgelija</option>
-<option value="GT">Gostivar</option>
-<option value="GR">Gradsko</option>
-<option value="DB">Debar</option>
-<option value="DA">Debarca</option>
-<option value="DL" selected="selected">Del\u010devo</option>
-<option value="DK">Demir Kapija</option>
-<option value="DM">Demir Hisar</option>
-<option value="DE">Dolneni</option>
-<option value="DR">Drugovo</option>
-<option value="GP">Gjor\u010de Petrov</option>
-<option value="ZE">\u017delino</option>
-<option value="ZA">Zajas</option>
-<option value="ZK">Zelenikovo</option>
-<option value="ZR">Zrnovci</option>
-<option value="IL">Ilinden</option>
-<option value="JG">Jegunovce</option>
-<option value="AV">Kavadarci</option>
-<option value="KB">Karbinci</option>
-<option value="KX">Karpo\u0161</option>
-<option value="VD">Kisela Voda</option>
-<option value="KH">Ki\u010devo</option>
-<option value="KN">Kon\u010de</option>
-<option value="OC">Ko\u0107ani</option>
-<option value="KY">Kratovo</option>
-<option value="KZ">Kriva Palanka</option>
-<option value="KG">Krivoga\u0161tani</option>
-<option value="KS">Kru\u0161evo</option>
-<option value="UM">Kumanovo</option>
-<option value="LI">Lipkovo</option>
-<option value="LO">Lozovo</option>
-<option value="MR">Mavrovo i Rostu\u0161a</option>
-<option value="MK">Makedonska Kamenica</option>
-<option value="MD">Makedonski Brod</option>
-<option value="MG">Mogila</option>
-<option value="NG">Negotino</option>
-<option value="NV">Novaci</option>
-<option value="NS">Novo Selo</option>
-<option value="OS">Oslomej</option>
-<option value="OD">Ohrid</option>
-<option value="PE">Petrovec</option>
-<option value="PH">Peh\u010devo</option>
-<option value="PN">Plasnica</option>
-<option value="PP">Prilep</option>
-<option value="PT">Probi\u0161tip</option>
-<option value="RV">Radovi\u0161</option>
-<option value="RN">Rankovce</option>
-<option value="RE">Resen</option>
-<option value="RO">Rosoman</option>
-<option value="AJ">Saraj</option>
-<option value="SL">Sveti Nikole</option>
-<option value="SS">Sopi\u0161te</option>
-<option value="SD">Star Dojran</option>
-<option value="NA">Staro Nagori\u010dane</option>
-<option value="UG">Struga</option>
-<option value="RU">Strumica</option>
-<option value="SU">Studeni\u010dani</option>
-<option value="TR">Tearce</option>
-<option value="ET">Tetovo</option>
-<option value="CE">Centar</option>
-<option value="CZ">Centar-\u017dupa</option>
-<option value="CI">\u010cair</option>
-<option value="CA">\u010ca\u0161ka</option>
-<option value="CH">\u010ce\u0161inovo-Oble\u0161evo</option>
-<option value="CS">\u010cu\u010der-Sandevo</option>
-<option value="ST">\u0160tip</option>
-<option value="SO">\u0160uto Orizari</option>
-</select>'''
- self.assertEqual(f.render('municipality', 'DL' ), out)
-
- def test_UMCNField(self):
- error_invalid = [u'This field should contain exactly 13 digits.']
- error_checksum = [u'The UMCN is not valid.']
- error_date = [u'The first 7 digits of the UMCN '
- 'must represent a valid past date.']
- valid = {
- '2402983450006': '2402983450006',
- '2803984430038': '2803984430038',
- '1909982045004': '1909982045004',
- }
- invalid = {
- '240298345': error_invalid,
- 'abcdefghj': error_invalid,
- '2402082450006': error_date,
- '3002982450006': error_date,
- '2402983450007': error_checksum,
- '2402982450006': error_checksum,
- }
- self.assertFieldOutput(UMCNField, valid, invalid)
View
127 tests/regressiontests/forms/localflavor/mx.py
@@ -1,127 +0,0 @@
-# -*- coding: utf-8 -*-
-from django.contrib.localflavor.mx.forms import (MXZipCodeField, MXRFCField,
- MXStateSelect, MXCURPField)
-
-from django.test import SimpleTestCase
-
-
-class MXLocalFlavorTests(SimpleTestCase):
- def test_MXStateSelect(self):
- f = MXStateSelect()
- out = u'''<select name="state">
-<option value="AGU">Aguascalientes</option>
-<option value="BCN">Baja California</option>
-<option value="BCS">Baja California Sur</option>
-<option value="CAM">Campeche</option>
-<option value="CHH">Chihuahua</option>
-<option value="CHP">Chiapas</option>
-<option value="COA">Coahuila</option>
-<option value="COL">Colima</option>
-<option value="DIF">Distrito Federal</option>
-<option value="DUR">Durango</option>
-<option value="GRO">Guerrero</option>
-<option value="GUA">Guanajuato</option>
-<option value="HID">Hidalgo</option>
-<option value="JAL">Jalisco</option>
-<option value="MEX">Estado de México</option>
-<option value="MIC" selected="selected">Michoacán</option>
-<option value="MOR">Morelos</option>
-<option value="NAY">Nayarit</option>
-<option value="NLE">Nuevo León</option>
-<option value="OAX">Oaxaca</option>
-<option value="PUE">Puebla</option>
-<option value="QUE">Querétaro</option>
-<option value="ROO">Quintana Roo</option>
-<option value="SIN">Sinaloa</option>
-<option value="SLP">San Luis Potosí</option>
-<option value="SON">Sonora</option>
-<option value="TAB">Tabasco</option>
-<option value="TAM">Tamaulipas</option>
-<option value="TLA">Tlaxcala</option>
-<option value="VER">Veracruz</option>
-<option value="YUC">Yucatán</option>
-<option value="ZAC">Zacatecas</option>
-</select>'''
- self.assertEqual(f.render('state', 'MIC'), out)
-
- def test_MXZipCodeField(self):
- error_format = [u'Enter a valid zip code in the format XXXXX.']
- valid = {
- '58120': u'58120',
- '58502': u'58502',
- '59310': u'59310',
- '99999': u'99999',
- }
- invalid = {
- '17000': error_format,
- '18000': error_format,
- '19000': error_format,
- '00000': error_format,
- }
- self.assertFieldOutput(MXZipCodeField, valid, invalid)
-
- def test_MXRFCField(self):
- error_format = [u'Enter a valid RFC.']
- error_checksum = [u'Invalid checksum for RFC.']
- valid = {
- 'MoFN641205eX5': u'MOFN641205EX5',
- 'ICa060120873': u'ICA060120873',
- 'eUcG751104rT0': u'EUCG751104RT0',
- 'GME08100195A': u'GME08100195A',
- 'AA&060524KX5': u'AA&060524KX5',
- 'CAÑ0708045P7': u'CAÑ0708045P7',
- 'aaa000101aa9': u'AAA000101AA9',
- }
- invalid = {
- 'MED0000000XA': error_format,
- '0000000000XA': error_format,
- 'AAA000000AA6': error_format,
- # Dates
- 'XXX880002XXX': error_format,
- 'XXX880200XXX': error_format,
- 'XXX880132XXX': error_format,
- 'XXX880230XXX': error_format,
- 'XXX880431XXX': error_format,
- # Incorrect checksum
- 'MOGR650524E73': error_checksum,
- 'HVA7810058F1': error_checksum,
- 'MoFN641205eX2': error_checksum,
- 'ICa060120871': error_checksum,
- 'eUcG751104rT7': error_checksum,
- 'GME081001955': error_checksum,
- 'AA&060524KX9': error_checksum,
- 'CAÑ0708045P2': error_checksum,
- }
- self.assertFieldOutput(MXRFCField, valid, invalid)
-
- def test_MXCURPField(self):
- error_format = [u'Enter a valid CURP.']
- error_checksum = [u'Invalid checksum for CURP.']
- valid = {
- 'AaMG890608HDFLJL00': u'AAMG890608HDFLJL00',
- 'BAAd890419HMNRRV07': u'BAAD890419HMNRRV07',
- 'VIAA900930MMNClL08': u'VIAA900930MMNCLL08',
- 'HEGR891009HMNRRD09': u'HEGR891009HMNRRD09',
- 'MARR890512HMNRMN09': u'MARR890512HMNRMN09',
- 'MESJ890928HMNZNS00': u'MESJ890928HMNZNS00',
- 'BAAA890317HDFRLL03': u'BAAA890317HDFRLL03',
- 'TOMA880125HMNRRNO2': u'TOMA880125HMNRRNO2',
- 'OOMG890727HMNRSR06': u'OOMG890727HMNRSR06',
- 'AAAA000101HDFCCC09': u'AAAA000101HDFCCC09',
- }
- invalid = {
- 'AAAA000000HDFCCC09': error_format,
- 'AAAA000000HDFAAA03': error_format,
- 'AAAA000000HXXCCC08': error_format,
- 'AAAA000000XMNCCC02': error_format,
- 'HEGR891009HMNRRD0A': error_format,
- 'MARR890512HMNRMN0A': error_format,
- 'AaMG890608HDFLJL01': error_checksum,
- 'BAAd890419HMNRRV08': error_checksum,
- 'VIAA900930MMNClL09': error_checksum,
- 'MESJ890928HMNZNS01': error_checksum,
- 'BAAA890317HDFRLL04': error_checksum,
- 'TOMA880125HMNRRNO3': error_checksum,
- 'OOMG890727HMNRSR07': error_checksum,
- }
- self.assertFieldOutput(MXCURPField, valid, invalid)
View
129 tests/regressiontests/forms/localflavor/us.py
@@ -1,129 +0,0 @@
-from django.contrib.localflavor.us.forms import (USZipCodeField,
- USPhoneNumberField, USStateField, USStateSelect, USSocialSecurityNumberField)
-
-from django.test import SimpleTestCase
-
-
-class USLocalFlavorTests(SimpleTestCase):
- def test_USStateSelect(self):
- f = USStateSelect()
- out = u'''<select name="state">
-<option value="AL">Alabama</option>
-<option value="AK">Alaska</option>
-<option value="AS">American Samoa</option>
-<option value="AZ">Arizona</option>
-<option value="AR">Arkansas</option>
-<option value="AA">Armed Forces Americas</option>
-<option value="AE">Armed Forces Europe</option>
-<option value="AP">Armed Forces Pacific</option>
-<option value="CA">California</option>
-<option value="CO">Colorado</option>
-<option value="CT">Connecticut</option>
-<option value="DE">Delaware</option>
-<option value="DC">District of Columbia</option>
-<option value="FL">Florida</option>
-<option value="GA">Georgia</option>
-<option value="GU">Guam</option>
-<option value="HI">Hawaii</option>
-<option value="ID">Idaho</option>
-<option value="IL" selected="selected">Illinois</option>
-<option value="IN">Indiana</option>
-<option value="IA">Iowa</option>
-<option value="KS">Kansas</option>
-<option value="KY">Kentucky</option>
-<option value="LA">Louisiana</option>
-<option value="ME">Maine</option>
-<option value="MD">Maryland</option>
-<option value="MA">Massachusetts</option>
-<option value="MI">Michigan</option>
-<option value="MN">Minnesota</option>
-<option value="MS">Mississippi</option>
-<option value="MO">Missouri</option>
-<option value="MT">Montana</option>
-<option value="NE">Nebraska</option>
-<option value="NV">Nevada</option>
-<option value="NH">New Hampshire</option>
-<option value="NJ">New Jersey</option>
-<option value="NM">New Mexico</option>
-<option value="NY">New York</option>
-<option value="NC">North Carolina</option>
-<option value="ND">North Dakota</option>
-<option value="MP">Northern Mariana Islands</option>
-<option value="OH">Ohio</option>
-<option value="OK">Oklahoma</option>
-<option value="OR">Oregon</option>
-<option value="PA">Pennsylvania</option>
-<option value="PR">Puerto Rico</option>
-<option value="RI">Rhode Island</option>
-<option value="SC">South Carolina</option>
-<option value="SD">South Dakota</option>
-<option value="TN">Tennessee</option>
-<option value="TX">Texas</option>
-<option value="UT">Utah</option>
-<option value="VT">Vermont</option>
-<option value="VI">Virgin Islands</option>
-<option value="VA">Virginia</option>
-<option value="WA">Washington</option>
-<option value="WV">West Virginia</option>
-<option value="WI">Wisconsin</option>
-<option value="WY">Wyoming</option>
-</select>'''
- self.assertEqual(f.render('state', 'IL'), out)
-
- def test_USZipCodeField(self):
- error_format = [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
- valid = {
- '60606': '60606',
- 60606: '60606',
- '04000': '04000',
- '60606-1234': '60606-1234',
- }
- invalid = {
- '4000': error_format,
- '6060-1234': error_format,
- '60606-': error_format,
- }
- self.assertFieldOutput(USZipCodeField, valid, invalid)
-
- def test_USPhoneNumberField(self):
- error_format = [u'Phone numbers must be in XXX-XXX-XXXX format.']
- valid = {
- '312-555-1212': '312-555-1212',
- '3125551212': '312-555-1212',
- '312 555-1212': '312-555-1212',
- '(312) 555-1212': '312-555-1212',
- '312 555 1212': '312-555-1212',
- '312.555.1212': '312-555-1212',
- '312.555-1212': '312-555-1212',
- ' (312) 555.1212 ': '312-555-1212',
- }
- invalid = {
- '555-1212': error_format,
- '312-55-1212': error_format,
- }
- self.assertFieldOutput(USPhoneNumberField, valid, invalid)
-
- def test_USStateField(self):
- error_invalid = [u'Enter a U.S. state or territory.']
- valid = {
- 'il': 'IL',
- 'IL': 'IL',
- 'illinois': 'IL',
- ' illinois ': 'IL',
- }
- invalid = {
- 60606: error_invalid,
- }
- self.assertFieldOutput(USStateField, valid, invalid)
-
- def test_USSocialSecurityNumberField(self):
- error_invalid = [u'Enter a valid U.S. Social Security number in XXX-XX-XXXX format.']
-
- valid = {
- '987-65-4330': '987-65-4330',
- '987654330': '987-65-4330',
- }
- invalid = {
- '078-05-1120': error_invalid,
- }
- self.assertFieldOutput(USSocialSecurityNumberField, valid, invalid)
View
42 tests/regressiontests/forms/localflavortests.py
@@ -1,42 +0,0 @@
-from localflavor.ar import ARLocalFlavorTests
-from localflavor.at import ATLocalFlavorTests
-from localflavor.au import AULocalFlavorTests
-from localflavor.be import BELocalFlavorTests
-from localflavor.br import BRLocalFlavorTests
-from localflavor.ca import CALocalFlavorTests
-from localflavor.ch import CHLocalFlavorTests
-from localflavor.cl import CLLocalFlavorTests
-from localflavor.cz import CZLocalFlavorTests
-from localflavor.cn import CNLocalFlavorTests
-from localflavor.co import COLocalFlavorTests
-from localflavor.de import DELocalFlavorTests
-from localflavor.es import ESLocalFlavorTests
-from localflavor.ec import ECLocalFlavorTests
-from localflavor.fi import FILocalFlavorTests
-from localflavor.fr import FRLocalFlavorTests
-from localflavor.gb import GBLocalFlavorTests
-from localflavor.generic import GenericLocalFlavorTests
-from localflavor.hr import HRLocalFlavorTests
-from localflavor.id import IDLocalFlavorTests
-from localflavor.ie import IELocalFlavorTests
-from localflavor.il import ILLocalFlavorTests
-from localflavor.is_ import ISLocalFlavorTests
-from localflavor.in_ import INLocalFlavorTests
-from localflavor.it import ITLocalFlavorTests
-from localflavor.jp import JPLocalFlavorTests
-from localflavor.kw import KWLocalFlavorTests
-from localflavor.mk import MKLocalFlavorTests
-from localflavor.mx import MXLocalFlavorTests
-from localflavor.nl import NLLocalFlavorTests
-from localflavor.pl import PLLocalFlavorTests
-from localflavor.pt import PTLocalFlavorTests
-from localflavor.py import PYLocalFlavorTests
-from localflavor.ro import ROLocalFlavorTests
-from localflavor.ru import RULocalFlavorTests
-from localflavor.se import SELocalFlavorTests
-from localflavor.sk import SKLocalFlavorTests
-from localflavor.tr import TRLocalFlavorTests
-from localflavor.us import USLocalFlavorTests
-from localflavor.uy import UYLocalFlavorTests
-from localflavor.za import ZALocalFlavorTests
-
View
44 tests/regressiontests/forms/tests/__init__.py
@@ -10,47 +10,3 @@
from util import *
from validators import TestFieldWithValidators
from widgets import *
-
-from regressiontests.forms.localflavortests import (
- ARLocalFlavorTests,
- ATLocalFlavorTests,
- AULocalFlavorTests,
- BELocalFlavorTests,
- BRLocalFlavorTests,
- CALocalFlavorTests,
- CHLocalFlavorTests,
- CLLocalFlavorTests,
- CNLocalFlavorTests,
- COLocalFlavorTests,
- CZLocalFlavorTests,
- DELocalFlavorTests,
- ECLocalFlavorTests,
- ESLocalFlavorTests,
- FILocalFlavorTests,
- FRLocalFlavorTests,
- GBLocalFlavorTests,
- GenericLocalFlavorTests,
- HRLocalFlavorTests,
- IDLocalFlavorTests,
- IELocalFlavorTests,
- ILLocalFlavorTests,
- ISLocalFlavorTests,
- INLocalFlavorTests,
- ITLocalFlavorTests,
- JPLocalFlavorTests,
- KWLocalFlavorTests,
- MKLocalFlavorTests,
- MXLocalFlavorTests,
- NLLocalFlavorTests,
- PLLocalFlavorTests,
- PTLocalFlavorTests,
- PYLocalFlavorTests,
- ROLocalFlavorTests,
- RULocalFlavorTests,
- SELocalFlavorTests,
- SKLocalFlavorTests,
- TRLocalFlavorTests,
- USLocalFlavorTests,
- UYLocalFlavorTests,
- ZALocalFlavorTests,
-)
View
0  tests/regressiontests/localflavor/ar/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/ar.py → ...s/regressiontests/localflavor/ar/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/at/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/at.py → ...s/regressiontests/localflavor/at/tests.py
File renamed without changes
View
51 tests/regressiontests/localflavor/au/tests.py
@@ -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 @@
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 @@ def test_selected_values(self):
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)
View
0  tests/regressiontests/localflavor/be/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/be.py → ...s/regressiontests/localflavor/be/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/br/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/br.py → ...s/regressiontests/localflavor/br/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/ca/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/ca.py → ...s/regressiontests/localflavor/ca/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/ch/__init__.py
No changes.
View
7 ...s/regressiontests/forms/localflavor/ch.py → ...s/regressiontests/localflavor/ch/tests.py
@@ -36,7 +36,7 @@ def test_CHStateSelect(self):
<option value="ZH">Zurich</option>
</select>'''
self.assertEqual(f.render('state', 'AG'), out)
-
+
def test_CHZipCodeField(self):
error_format = [u'Enter a zip code in the format XXXX.']
valid = {
@@ -48,7 +48,7 @@ def test_CHZipCodeField(self):
'80 00': error_format,
}
self.assertFieldOutput(CHZipCodeField, valid, invalid)
-
+
def test_CHPhoneNumberField(self):
error_format = [u'Phone numbers must be in 0XX XXX XX XX format.']
valid = {
@@ -60,7 +60,7 @@ def test_CHPhoneNumberField(self):
'1234567890': error_format,
}
self.assertFieldOutput(CHPhoneNumberField, valid, invalid)
-
+
def test_CHIdentityCardNumberField(self):
error_format = [u'Enter a valid Swiss identity or passport card number in X1234567<0 or 1234567890 format.']
valid = {
@@ -72,4 +72,3 @@ def test_CHIdentityCardNumberField(self):
'2123456701': error_format,
}
self.assertFieldOutput(CHIdentityCardNumberField, valid, invalid)
-
View
0  tests/regressiontests/localflavor/cl/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/cl.py → ...s/regressiontests/localflavor/cl/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/cn/__init__.py
No changes.
View
1  ...s/regressiontests/forms/localflavor/cn.py → ...s/regressiontests/localflavor/cn/tests.py
@@ -110,4 +110,3 @@ def test_CNCellNumberField(self):
'14012345678': error_format
}
self.assertFieldOutput(CNCellNumberField, valid, invalid)
-
View
0  tests/regressiontests/localflavor/co/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/co.py → ...s/regressiontests/localflavor/co/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/cz/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/cz.py → ...s/regressiontests/localflavor/cz/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/de/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/de.py → ...s/regressiontests/localflavor/de/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/ec/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/ec.py → ...s/regressiontests/localflavor/ec/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/es/__init__.py
No changes.
View
4 ...s/regressiontests/forms/localflavor/es.py → ...s/regressiontests/localflavor/es/tests.py
@@ -153,7 +153,7 @@ def test_ESIdentityCardNumberField(self):
'78699688-2': error_invalid,
}
self.assertFieldOutput(ESIdentityCardNumberField, valid, invalid)
-
+
def test_ESCCCField(self):
error_invalid = [u'Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.']
error_checksum = [u'Invalid checksum for bank account number.']
@@ -169,5 +169,3 @@ def test_ESCCCField(self):
'2077-03-3879-3100254321': error_invalid,
}
self.assertFieldOutput(ESCCCField, valid, invalid)
-
-
View
0  tests/regressiontests/localflavor/fi/__init__.py
No changes.
View
1  ...s/regressiontests/forms/localflavor/fi.py → ...s/regressiontests/localflavor/fi/tests.py
@@ -379,4 +379,3 @@ def test_FISocialSecurityNumber(self):
'101010b0101': error_invalid,
}
self.assertFieldOutput(FISocialSecurityNumber, valid, invalid)
-
View
0  tests/regressiontests/localflavor/fr/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/fr.py → ...s/regressiontests/localflavor/fr/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/gb/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/gb.py → ...s/regressiontests/localflavor/gb/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/generic/__init__.py
No changes.
View
0  ...ressiontests/forms/localflavor/generic.py → ...ressiontests/localflavor/generic/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/hr/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/hr.py → ...s/regressiontests/localflavor/hr/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/id/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/id.py → ...s/regressiontests/localflavor/id/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/ie/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/ie.py → ...s/regressiontests/localflavor/ie/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/il/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/il.py → ...s/regressiontests/localflavor/il/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/in_/__init__.py
No changes.
View
0  .../regressiontests/forms/localflavor/in_.py → .../regressiontests/localflavor/in_/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/is_/__init__.py
No changes.
View
7 .../regressiontests/forms/localflavor/is_.py → .../regressiontests/localflavor/is_/tests.py
@@ -157,7 +157,7 @@ def test_ISPostalCodeSelect(self):
<option value="902">902 Vestmannaeyjar</option>
</select>'''
self.assertEqual(f.render('foo', 'bar'), out)
-
+
def test_ISIdNumberField(self):
error_atleast = [u'Ensure this value has at least 10 characters (it has 9).']
error_invalid = [u'Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
@@ -174,10 +174,10 @@ def test_ISIdNumberField(self):
'230880343234': error_atmost + error_invalid,
'abcdefghijk': error_invalid,
'2308803439': error_notvalid,
-
+
}
self.assertFieldOutput(ISIdNumberField, valid, invalid)
-
+
def test_ISPhoneNumberField(self):
error_invalid = [u'Enter a valid value.']
error_atleast = [u'Ensure this value has at least 7 characters (it has 6).']
@@ -196,4 +196,3 @@ def test_ISPhoneNumberField(self):
' 12367 ': error_invalid
}
self.assertFieldOutput(ISPhoneNumberField, valid, invalid)
-
View
0  tests/regressiontests/localflavor/it/__init__.py
No changes.
View
5 ...s/regressiontests/forms/localflavor/it.py → ...s/regressiontests/localflavor/it/tests.py
@@ -40,7 +40,7 @@ def test_ITZipCodeField(self):
' 00100': error_invalid,
}
self.assertFieldOutput(ITZipCodeField, valid, invalid)
-
+
def test_ITSocialSecurityNumberField(self):
error_invalid = [u'Enter a valid Social Security number.']
valid = {
@@ -54,7 +54,7 @@ def test_ITSocialSecurityNumberField(self):
'%BRRME11A01L736W': error_invalid,
}
self.assertFieldOutput(ITSocialSecurityNumberField, valid, invalid)
-
+
def test_ITVatNumberField(self):
error_invalid = [u'Enter a valid VAT number.']
valid = {
@@ -67,4 +67,3 @@ def test_ITVatNumberField(self):
'A7973780013': error_invalid,
}
self.assertFieldOutput(ITVatNumberField, valid, invalid)
-
View
0  tests/regressiontests/localflavor/jp/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/jp.py → ...s/regressiontests/localflavor/jp/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/kw/__init__.py
No changes.
View
1  ...s/regressiontests/forms/localflavor/kw.py → ...s/regressiontests/localflavor/kw/tests.py
@@ -13,4 +13,3 @@ def test_KWCivilIDNumberField(self):
'289332013455': error_invalid,
}
self.assertFieldOutput(KWCivilIDNumberField, valid, invalid)
-
View
132 tests/regressiontests/localflavor/mk/tests.py
@@ -1,7 +1,11 @@
-from django.test import TestCase
+from django.contrib.localflavor.mk.forms import (
+ MKIdentityCardNumberField, MKMunicipalitySelect, UMCNField)
+from django.test import SimpleTestCase
+
from forms import MKPersonForm
-class MKLocalflavorTests(TestCase):
+class MKLocalflavorTests(SimpleTestCase):
+
def setUp(self):
self.form = MKPersonForm({
'first_name':'Someone',
@@ -174,3 +178,127 @@ def test_field_blank_option(self):
<option value="SO">\xc5\xa0uto Orizari</option>
</select>"""
self.assertEqual(str(self.form['municipality']), municipality_select_html)
+
+ def test_MKIdentityCardNumberField(self):
+ error_invalid = [u'Identity card numbers must contain either 4 to 7 '
+ 'digits or an uppercase letter and 7 digits.']
+ valid = {
+ 'L0018077':'L0018077',
+ 'A0078315' : 'A0078315',
+ }
+ invalid = {
+ '123': error_invalid,
+ 'abcdf': error_invalid,
+ '234390a': error_invalid,
+ }
+ self.assertFieldOutput(MKIdentityCardNumberField, valid, invalid)
+
+ def test_MKMunicipalitySelect(self):
+ f = MKMunicipalitySelect()
+ out=u'''<select name="municipality">
+<option value="AD">Aerodrom</option>
+<option value="AR">Ara\u010dinovo</option>
+<option value="BR">Berovo</option>
+<option value="TL">Bitola</option>
+<option value="BG">Bogdanci</option>
+<option value="VJ">Bogovinje</option>
+<option value="BS">Bosilovo</option>
+<option value="BN">Brvenica</option>
+<option value="BU">Butel</option>
+<option value="VA">Valandovo</option>
+<option value="VL">Vasilevo</option>
+<option value="VV">Vev\u010dani</option>
+<option value="VE">Veles</option>
+<option value="NI">Vinica</option>
+<option value="VC">Vrane\u0161tica</option>
+<option value="VH">Vrap\u010di\u0161te</option>
+<option value="GB">Gazi Baba</option>
+<option value="GV">Gevgelija</option>
+<option value="GT">Gostivar</option>
+<option value="GR">Gradsko</option>
+<option value="DB">Debar</option>
+<option value="DA">Debarca</option>
+<option value="DL" selected="selected">Del\u010devo</option>
+<option value="DK">Demir Kapija</option>
+<option value="DM">Demir Hisar</option>
+<option value="DE">Dolneni</option>
+<option value="DR">Drugovo</option>
+<option value="GP">Gjor\u010de Petrov</option>
+<option value="ZE">\u017delino</option>
+<option value="ZA">Zajas</option>
+<option value="ZK">Zelenikovo</option>
+<option value="ZR">Zrnovci</option>
+<option value="IL">Ilinden</option>
+<option value="JG">Jegunovce</option>
+<option value="AV">Kavadarci</option>
+<option value="KB">Karbinci</option>
+<option value="KX">Karpo\u0161</option>
+<option value="VD">Kisela Voda</option>
+<option value="KH">Ki\u010devo</option>
+<option value="KN">Kon\u010de</option>
+<option value="OC">Ko\u0107ani</option>
+<option value="KY">Kratovo</option>
+<option value="KZ">Kriva Palanka</option>
+<option value="KG">Krivoga\u0161tani</option>
+<option value="KS">Kru\u0161evo</option>
+<option value="UM">Kumanovo</option>
+<option value="LI">Lipkovo</option>
+<option value="LO">Lozovo</option>
+<option value="MR">Mavrovo i Rostu\u0161a</option>
+<option value="MK">Makedonska Kamenica</option>
+<option value="MD">Makedonski Brod</option>
+<option value="MG">Mogila</option>
+<option value="NG">Negotino</option>
+<option value="NV">Novaci</option>
+<option value="NS">Novo Selo</option>
+<option value="OS">Oslomej</option>
+<option value="OD">Ohrid</option>
+<option value="PE">Petrovec</option>
+<option value="PH">Peh\u010devo</option>
+<option value="PN">Plasnica</option>
+<option value="PP">Prilep</option>
+<option value="PT">Probi\u0161tip</option>
+<option value="RV">Radovi\u0161</option>
+<option value="RN">Rankovce</option>
+<option value="RE">Resen</option>
+<option value="RO">Rosoman</option>
+<option value="AJ">Saraj</option>
+<option value="SL">Sveti Nikole</option>
+<option value="SS">Sopi\u0161te</option>
+<option value="SD">Star Dojran</option>
+<option value="NA">Staro Nagori\u010dane</option>
+<option value="UG">Struga</option>
+<option value="RU">Strumica</option>
+<option value="SU">Studeni\u010dani</option>
+<option value="TR">Tearce</option>
+<option value="ET">Tetovo</option>
+<option value="CE">Centar</option>
+<option value="CZ">Centar-\u017dupa</option>
+<option value="CI">\u010cair</option>
+<option value="CA">\u010ca\u0161ka</option>
+<option value="CH">\u010ce\u0161inovo-Oble\u0161evo</option>
+<option value="CS">\u010cu\u010der-Sandevo</option>
+<option value="ST">\u0160tip</option>
+<option value="SO">\u0160uto Orizari</option>
+</select>'''
+ self.assertEqual(f.render('municipality', 'DL' ), out)
+
+ def test_UMCNField(self):
+ error_invalid = [u'This field should contain exactly 13 digits.']
+ error_checksum = [u'The UMCN is not valid.']
+ error_date = [u'The first 7 digits of the UMCN '
+ 'must represent a valid past date.']
+ valid = {
+ '2402983450006': '2402983450006',
+ '2803984430038': '2803984430038',
+ '1909982045004': '1909982045004',
+ }
+ invalid = {
+ '240298345': error_invalid,
+ 'abcdefghj': error_invalid,
+ '2402082450006': error_date,
+ '3002982450006': error_date,
+ '2402983450007': error_checksum,
+ '2402982450006': error_checksum,
+ }
+ self.assertFieldOutput(UMCNField, valid, invalid)
View
0  tests/regressiontests/localflavor/mx/mx.py
No changes.
View
128 tests/regressiontests/localflavor/mx/tests.py
@@ -1,8 +1,12 @@
# -*- coding: utf-8 -*-
-from django.test import TestCase
+from django.contrib.localflavor.mx.forms import (MXZipCodeField, MXRFCField,
+ MXStateSelect, MXCURPField)
+from django.test import SimpleTestCase
+
from forms import MXPersonProfileForm
-class MXLocalFlavorTests(TestCase):
+class MXLocalFlavorTests(SimpleTestCase):
+
def setUp(self):
self.form = MXPersonProfileForm({
'state': 'MIC',
@@ -69,3 +73,123 @@ def test_field_blank_option(self):
<option value="ZAC">Zacatecas</option>
</select>"""
self.assertEqual(str(self.form['state']), state_select_html)
+
+ def test_MXStateSelect(self):
+ f = MXStateSelect()
+ out = u'''<select name="state">
+<option value="AGU">Aguascalientes</option>
+<option value="BCN">Baja California</option>
+<option value="BCS">Baja California Sur</option>
+<option value="CAM">Campeche</option>
+<option value="CHH">Chihuahua</option>
+<option value="CHP">Chiapas</option>
+<option value="COA">Coahuila</option>
+<option value="COL">Colima</option>
+<option value="DIF">Distrito Federal</option>
+<option value="DUR">Durango</option>
+<option value="GRO">Guerrero</option>
+<option value="GUA">Guanajuato</option>
+<option value="HID">Hidalgo</option>
+<option value="JAL">Jalisco</option>
+<option value="MEX">Estado de México</option>
+<option value="MIC" selected="selected">Michoacán</option>
+<option value="MOR">Morelos</option>
+<option value="NAY">Nayarit</option>
+<option value="NLE">Nuevo León</option>
+<option value="OAX">Oaxaca</option>
+<option value="PUE">Puebla</option>
+<option value="QUE">Querétaro</option>
+<option value="ROO">Quintana Roo</option>
+<option value="SIN">Sinaloa</option>
+<option value="SLP">San Luis Potosí</option>
+<option value="SON">Sonora</option>
+<option value="TAB">Tabasco</option>
+<option value="TAM">Tamaulipas</option>
+<option value="TLA">Tlaxcala</option>
+<option value="VER">Veracruz</option>
+<option value="YUC">Yucatán</option>
+<option value="ZAC">Zacatecas</option>
+</select>'''
+ self.assertEqual(f.render('state', 'MIC'), out)
+
+ def test_MXZipCodeField(self):
+ error_format = [u'Enter a valid zip code in the format XXXXX.']
+ valid = {
+ '58120': u'58120',
+ '58502': u'58502',
+ '59310': u'59310',
+ '99999': u'99999',
+ }
+ invalid = {
+ '17000': error_format,
+ '18000': error_format,
+ '19000': error_format,
+ '00000': error_format,
+ }
+ self.assertFieldOutput(MXZipCodeField, valid, invalid)
+
+ def test_MXRFCField(self):
+ error_format = [u'Enter a valid RFC.']
+ error_checksum = [u'Invalid checksum for RFC.']
+ valid = {
+ 'MoFN641205eX5': u'MOFN641205EX5',
+ 'ICa060120873': u'ICA060120873',
+ 'eUcG751104rT0': u'EUCG751104RT0',
+ 'GME08100195A': u'GME08100195A',
+ 'AA&060524KX5': u'AA&060524KX5',
+ 'CAÑ0708045P7': u'CAÑ0708045P7',
+ 'aaa000101aa9': u'AAA000101AA9',
+ }
+ invalid = {
+ 'MED0000000XA': error_format,
+ '0000000000XA': error_format,
+ 'AAA000000AA6': error_format,
+ # Dates
+ 'XXX880002XXX': error_format,
+ 'XXX880200XXX': error_format,
+ 'XXX880132XXX': error_format,
+ 'XXX880230XXX': error_format,
+ 'XXX880431XXX': error_format,
+ # Incorrect checksum
+ 'MOGR650524E73': error_checksum,
+ 'HVA7810058F1': error_checksum,
+ 'MoFN641205eX2': error_checksum,
+ 'ICa060120871': error_checksum,
+ 'eUcG751104rT7': error_checksum,
+ 'GME081001955': error_checksum,
+ 'AA&060524KX9': error_checksum,
+ 'CAÑ0708045P2': error_checksum,
+ }
+ self.assertFieldOutput(MXRFCField, valid, invalid)
+
+ def test_MXCURPField(self):
+ error_format = [u'Enter a valid CURP.']
+ error_checksum = [u'Invalid checksum for CURP.']
+ valid = {
+ 'AaMG890608HDFLJL00': u'AAMG890608HDFLJL00',
+ 'BAAd890419HMNRRV07': u'BAAD890419HMNRRV07',
+ 'VIAA900930MMNClL08': u'VIAA900930MMNCLL08',
+ 'HEGR891009HMNRRD09': u'HEGR891009HMNRRD09',
+ 'MARR890512HMNRMN09': u'MARR890512HMNRMN09',
+ 'MESJ890928HMNZNS00': u'MESJ890928HMNZNS00',
+ 'BAAA890317HDFRLL03': u'BAAA890317HDFRLL03',
+ 'TOMA880125HMNRRNO2': u'TOMA880125HMNRRNO2',
+ 'OOMG890727HMNRSR06': u'OOMG890727HMNRSR06',
+ 'AAAA000101HDFCCC09': u'AAAA000101HDFCCC09',
+ }
+ invalid = {
+ 'AAAA000000HDFCCC09': error_format,
+ 'AAAA000000HDFAAA03': error_format,
+ 'AAAA000000HXXCCC08': error_format,
+ 'AAAA000000XMNCCC02': error_format,
+ 'HEGR891009HMNRRD0A': error_format,
+ 'MARR890512HMNRMN0A': error_format,
+ 'AaMG890608HDFLJL01': error_checksum,
+ 'BAAd890419HMNRRV08': error_checksum,
+ 'VIAA900930MMNClL09': error_checksum,
+ 'MESJ890928HMNZNS01': error_checksum,
+ 'BAAA890317HDFRLL04': error_checksum,
+ 'TOMA880125HMNRRNO3': error_checksum,
+ 'OOMG890727HMNRSR07': error_checksum,
+ }
+ self.assertFieldOutput(MXCURPField, valid, invalid)
View
0  tests/regressiontests/localflavor/nl/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/nl.py → ...s/regressiontests/localflavor/nl/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/pl/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/pl.py → ...s/regressiontests/localflavor/pl/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/pt/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/pt.py → ...s/regressiontests/localflavor/pt/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/py/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/py.py → ...s/regressiontests/localflavor/py/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/ro/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/ro.py → ...s/regressiontests/localflavor/ro/tests.py
File renamed without changes
View
0  tests/regressiontests/localflavor/ru/__init__.py
No changes.
View
2  ...s/regressiontests/forms/localflavor/ru.py → ...s/regressiontests/localflavor/ru/tests.py
@@ -1,5 +1,5 @@
from django.contrib.localflavor.ru.forms import *
-
+
from django.test import SimpleTestCase
View
0  tests/regressiontests/localflavor/se/__init__.py
No changes.
View
1  ...s/regressiontests/forms/localflavor/se.py → ...s/regressiontests/localflavor/se/tests.py
@@ -162,4 +162,3 @@ def test_SEPostalCodeField(self):
}
self.assertFieldOutput(SEPostalCodeField, valid, invalid)
-
View
0  tests/regressiontests/localflavor/sk/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/sk.py → ...s/regressiontests/localflavor/sk/tests.py
File renamed without changes
View
38 tests/regressiontests/localflavor/tests.py
@@ -1,5 +1,41 @@
+from ar.tests import *
+from at.tests import *
from au.tests import *
+from be.tests import *
+from br.tests import *
+from ca.tests import *
+from ch.tests import *
+from cl.tests import *
+from cn.tests import *
+from co.tests import *
+from cz.tests import *
+from de.tests import *
+from ec.tests import *
+from es.tests import *
+from fi.tests import *
+from fr.tests import *
+from gb.tests import *
+from generic.tests import *
+from hr.tests import *
+from id.tests import *
+from ie.tests import *
+from il.tests import *
+from in_.tests import *
+from is_.tests import *
+from it.tests import *
+from jp.tests import *
+from kw.tests import *
from mk.tests import *
from mx.tests import *
+from nl.tests import *
+from pl.tests import *
+from pt.tests import *
+from py.tests import *
+from ro.tests import *
+from ru.tests import *
+from se.tests import *
+from sk.tests import *
+from tr.tests import *
from us.tests import *
-
+from uy.tests import *
+from za.tests import *
View
0  tests/regressiontests/localflavor/tr/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/tr.py → ...s/regressiontests/localflavor/tr/tests.py
File renamed without changes
View
132 tests/regressiontests/localflavor/us/tests.py
@@ -1,7 +1,12 @@
-from django.test import TestCase
+from django.contrib.localflavor.us.forms import (USZipCodeField,
+ USPhoneNumberField, USStateField, USStateSelect,
+ USSocialSecurityNumberField)
+from django.test import SimpleTestCase
+
from forms import USPlaceForm
-class USLocalflavorTests(TestCase):
+class USLocalflavorTests(SimpleTestCase):
+
def setUp(self):
self.form = USPlaceForm({'state':'GA', 'state_req':'NC', 'postal_code': 'GA', 'name':'impossible'})
@@ -153,3 +158,126 @@ def test_full_postal_code_list(self):
<option value="WY">Wyoming</option>
</select>"""
self.assertEqual(str(self.form['postal_code']), usps_select_html)
+
+ def test_USStateSelect(self):
+ f = USStateSelect()
+ out = u'''<select name="state">
+<option value="AL">Alabama</option>
+<option value="AK">Alaska</option>
+<option value="AS">American Samoa</option>
+<option value="AZ">Arizona</option>
+<option value="AR">Arkansas</option>
+<option value="AA">Armed Forces Americas</option>
+<option value="AE">Armed Forces Europe</option>
+<option value="AP">Armed Forces Pacific</option>
+<option value="CA">California</option>
+<option value="CO">Colorado</option>
+<option value="CT">Connecticut</option>
+<option value="DE">Delaware</option>
+<option value="DC">District of Columbia</option>
+<option value="FL">Florida</option>
+<option value="GA">Georgia</option>
+<option value="GU">Guam</option>
+<option value="HI">Hawaii</option>
+<option value="ID">Idaho</option>
+<option value="IL" selected="selected">Illinois</option>
+<option value="IN">Indiana</option>
+<option value="IA">Iowa</option>
+<option value="KS">Kansas</option>
+<option value="KY">Kentucky</option>
+<option value="LA">Louisiana</option>
+<option value="ME">Maine</option>
+<option value="MD">Maryland</option>
+<option value="MA">Massachusetts</option>
+<option value="MI">Michigan</option>
+<option value="MN">Minnesota</option>
+<option value="MS">Mississippi</option>
+<option value="MO">Missouri</option>
+<option value="MT">Montana</option>
+<option value="NE">Nebraska</option>
+<option value="NV">Nevada</option>
+<option value="NH">New Hampshire</option>
+<option value="NJ">New Jersey</option>
+<option value="NM">New Mexico</option>
+<option value="NY">New York</option>
+<option value="NC">North Carolina</option>
+<option value="ND">North Dakota</option>
+<option value="MP">Northern Mariana Islands</option>
+<option value="OH">Ohio</option>
+<option value="OK">Oklahoma</option>
+<option value="OR">Oregon</option>
+<option value="PA">Pennsylvania</option>
+<option value="PR">Puerto Rico</option>
+<option value="RI">Rhode Island</option>
+<option value="SC">South Carolina</option>
+<option value="SD">South Dakota</option>
+<option value="TN">Tennessee</option>
+<option value="TX">Texas</option>
+<option value="UT">Utah</option>
+<option value="VT">Vermont</option>
+<option value="VI">Virgin Islands</option>
+<option value="VA">Virginia</option>
+<option value="WA">Washington</option>
+<option value="WV">West Virginia</option>
+<option value="WI">Wisconsin</option>
+<option value="WY">Wyoming</option>
+</select>'''
+ self.assertEqual(f.render('state', 'IL'), out)
+
+ def test_USZipCodeField(self):
+ error_format = [u'Enter a zip code in the format XXXXX or XXXXX-XXXX.']
+ valid = {
+ '60606': '60606',
+ 60606: '60606',
+ '04000': '04000',
+ '60606-1234': '60606-1234',
+ }
+ invalid = {
+ '4000': error_format,
+ '6060-1234': error_format,
+ '60606-': error_format,
+ }
+ self.assertFieldOutput(USZipCodeField, valid, invalid)
+
+ def test_USPhoneNumberField(self):
+ error_format = [u'Phone numbers must be in XXX-XXX-XXXX format.']
+ valid = {
+ '312-555-1212': '312-555-1212',
+ '3125551212': '312-555-1212',
+ '312 555-1212': '312-555-1212',
+ '(312) 555-1212': '312-555-1212',
+ '312 555 1212': '312-555-1212',
+ '312.555.1212': '312-555-1212',
+ '312.555-1212': '312-555-1212',
+ ' (312) 555.1212 ': '312-555-1212',
+ }
+ invalid = {
+ '555-1212': error_format,
+ '312-55-1212': error_format,
+ }
+ self.assertFieldOutput(USPhoneNumberField, valid, invalid)
+
+ def test_USStateField(self):
+ error_invalid = [u'Enter a U.S. state or territory.']
+ valid = {
+ 'il': 'IL',
+ 'IL': 'IL',
+ 'illinois': 'IL',
+ ' illinois ': 'IL',
+ }
+ invalid = {
+ 60606: error_invalid,
+ }
+ self.assertFieldOutput(USStateField, valid, invalid)
+
+ def test_USSocialSecurityNumberField(self):
+ error_invalid = [u'Enter a valid U.S. Social Security number in XXX-XX-XXXX format.']
+
+ valid = {
+ '987-65-4330': '987-65-4330',
+ '987654330': '987-65-4330',
+ }
+ invalid = {
+ '078-05-1120': error_invalid,
+ }
+ self.assertFieldOutput(USSocialSecurityNumberField, valid, invalid)
View
0  tests/regressiontests/localflavor/uy/__init__.py
No changes.
View
3  ...s/regressiontests/forms/localflavor/uy.py → ...s/regressiontests/localflavor/uy/tests.py
@@ -29,7 +29,7 @@ def test_UYDepartmentSelect(self):
<option value="D">Treinta y Tres</option>
</select>'''
self.assertEqual(f.render('departamentos', 'S'), out)
-
+
def test_UYCIField(self):
error_format = [u'Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.']
error_invalid = [u'Enter a valid CI number.']
@@ -49,4 +49,3 @@ def test_UYCIField(self):
self.assertFieldOutput(UYCIField, valid, invalid)
self.assertEqual(get_validation_digit(409805), 3)
self.assertEqual(get_validation_digit(1005411), 2)
-
View
0  tests/regressiontests/localflavor/za/__init__.py
No changes.
View
0  ...s/regressiontests/forms/localflavor/za.py → ...s/regressiontests/localflavor/za/tests.py
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.