Removed country-specific localflavor tests.

They now live in separate django-contrib-XX packages.
This commit is contained in:
Adrian Holovaty 2012-10-12 16:21:40 -05:00
parent 24c7d828b0
commit ffbc599f77
95 changed files with 0 additions and 5722 deletions

View File

@ -1,103 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.ar.forms import (ARProvinceSelect,
ARPostalCodeField, ARDNIField, ARCUITField)
from django.test import SimpleTestCase
class ARLocalFlavorTests(SimpleTestCase):
def test_ARProvinceSelect(self):
f = ARProvinceSelect()
out = '''<select name="provincias">
<option value="B">Buenos Aires</option>
<option value="K">Catamarca</option>
<option value="H">Chaco</option>
<option value="U">Chubut</option>
<option value="C">Ciudad Aut\xf3noma de Buenos Aires</option>
<option value="X">C\xf3rdoba</option>
<option value="W">Corrientes</option>
<option value="E">Entre R\xedos</option>
<option value="P">Formosa</option>
<option value="Y">Jujuy</option>
<option value="L">La Pampa</option>
<option value="F">La Rioja</option>
<option value="M">Mendoza</option>
<option value="N">Misiones</option>
<option value="Q">Neuqu\xe9n</option>
<option value="R">R\xedo Negro</option>
<option value="A" selected="selected">Salta</option>
<option value="J">San Juan</option>
<option value="D">San Luis</option>
<option value="Z">Santa Cruz</option>
<option value="S">Santa Fe</option>
<option value="G">Santiago del Estero</option>
<option value="V">Tierra del Fuego, Ant\xe1rtida e Islas del Atl\xe1ntico Sur</option>
<option value="T">Tucum\xe1n</option>
</select>'''
self.assertHTMLEqual(f.render('provincias', 'A'), out)
def test_ARPostalCodeField(self):
error_format = ['Enter a postal code in the format NNNN or ANNNNAAA.']
error_atmost = ['Ensure this value has at most 8 characters (it has 9).']
error_atleast = ['Ensure this value has at least 4 characters (it has 3).']
valid = {
'5000': '5000',
'C1064AAB': 'C1064AAB',
'c1064AAB': 'C1064AAB',
'C1064aab': 'C1064AAB',
'4400': '4400',
'C1064AAB': 'C1064AAB',
}
invalid = {
'C1064AABB': error_atmost + error_format,
'C1064AA': error_format,
'C1064AB': error_format,
'106AAB': error_format,
'500': error_atleast + error_format,
'5PPP': error_format,
}
self.assertFieldOutput(ARPostalCodeField, valid, invalid)
def test_ARDNIField(self):
error_length = ['This field requires 7 or 8 digits.']
error_digitsonly = ['This field requires only numbers.']
valid = {
'20123456': '20123456',
'20.123.456': '20123456',
'20123456': '20123456',
'20.123.456': '20123456',
'20.123456': '20123456',
'9123456': '9123456',
'9.123.456': '9123456',
}
invalid = {
'101234566': error_length,
'W0123456': error_digitsonly,
'10,123,456': error_digitsonly,
}
self.assertFieldOutput(ARDNIField, valid, invalid)
def test_ARCUITField(self):
error_format = ['Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.']
error_invalid = ['Invalid CUIT.']
error_legal_type = ['Invalid legal type. Type must be 27, 20, 23 or 30.']
valid = {
'20-10123456-9': '20-10123456-9',
'20-10123456-9': '20-10123456-9',
'27-10345678-4': '27-10345678-4',
'20101234569': '20-10123456-9',
'27103456784': '27-10345678-4',
'30011111110': '30-01111111-0',
}
invalid = {
'2-10123456-9': error_format,
'210123456-9': error_format,
'20-10123456': error_format,
'20-10123456-': error_format,
'20-10123456-5': error_invalid,
'27-10345678-1': error_invalid,
'27-10345678-1': error_invalid,
'11211111110': error_legal_type,
}
self.assertFieldOutput(ARCUITField, valid, invalid)

View File

@ -1,49 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.at.forms import (ATZipCodeField, ATStateSelect,
ATSocialSecurityNumberField)
from django.test import SimpleTestCase
class ATLocalFlavorTests(SimpleTestCase):
def test_ATStateSelect(self):
f = ATStateSelect()
out = '''<select name="bundesland">
<option value="BL">Burgenland</option>
<option value="KA">Carinthia</option>
<option value="NO">Lower Austria</option>
<option value="OO">Upper Austria</option>
<option value="SA">Salzburg</option>
<option value="ST">Styria</option>
<option value="TI">Tyrol</option>
<option value="VO">Vorarlberg</option>
<option value="WI" selected="selected">Vienna</option>
</select>'''
self.assertHTMLEqual(f.render('bundesland', 'WI'), out)
def test_ATZipCodeField(self):
error_format = ['Enter a zip code in the format XXXX.']
valid = {
'1150': '1150',
'4020': '4020',
'8020': '8020',
}
invalid = {
'0000' : error_format,
'0123' : error_format,
'111222': error_format,
'eeffee': error_format,
}
self.assertFieldOutput(ATZipCodeField, valid, invalid)
def test_ATSocialSecurityNumberField(self):
error_format = ['Enter a valid Austrian Social Security Number in XXXX XXXXXX format.']
valid = {
'1237 010180': '1237 010180',
}
invalid = {
'1237 010181': error_format,
'12370 010180': error_format,
}
self.assertFieldOutput(ATSocialSecurityNumberField, valid, invalid)

View File

@ -1,11 +0,0 @@
from __future__ import absolute_import
from django.forms import ModelForm
from .models import AustralianPlace
class AustralianPlaceForm(ModelForm):
""" Form for storing an Australian place. """
class Meta:
model = AustralianPlace

View File

@ -1,14 +0,0 @@
from django.contrib.localflavor.au.models import AUStateField, AUPostCodeField
from django.db import models
class AustralianPlace(models.Model):
state = AUStateField(blank=True)
state_required = AUStateField()
state_default = AUStateField(default="NSW", blank=True)
postcode = AUPostCodeField(blank=True)
postcode_required = AUPostCodeField()
postcode_default = AUPostCodeField(default="2500", blank=True)
name = models.CharField(max_length=20)
class Meta:
app_label = 'localflavor'

View File

@ -1,108 +0,0 @@
from __future__ import absolute_import, unicode_literals
import re
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">'
BLANK_OPTION_PATTERN = r'<option value="">'
INPUT_VALUE_PATTERN = r'<input[^>]*value="%s"[^>]*>'
class AULocalflavorTests(SimpleTestCase):
def setUp(self):
self.form = AustralianPlaceForm(
{'state':'WA',
'state_required':'QLD',
'name':'dummy',
'postcode':'1234',
'postcode_required':'4321',
})
def test_get_display_methods(self):
""" Ensure get_*_display() methods are added to model instances. """
place = self.form.save()
self.assertEqual(place.get_state_display(), 'Western Australia')
self.assertEqual(place.get_state_required_display(), 'Queensland')
def test_default_values(self):
""" Ensure that default values are selected in forms. """
form = AustralianPlaceForm()
self.assertTrue(re.search(SELECTED_OPTION_PATTERN % 'NSW',
str(form['state_default'])))
self.assertTrue(re.search(INPUT_VALUE_PATTERN % '2500',
str(form['postcode_default'])))
def test_required(self):
""" Test that required AUStateFields throw appropriate errors. """
form = AustralianPlaceForm({'state':'NSW', 'name':'Wollongong'})
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors['state_required'], ['This field is required.'])
self.assertEqual(
form.errors['postcode_required'], ['This field is required.'])
def test_field_blank_option(self):
""" Test that the empty option is there. """
self.assertTrue(re.search(BLANK_OPTION_PATTERN,
str(self.form['state'])))
def test_selected_values(self):
""" Ensure selected states match the initial values provided. """
self.assertTrue(re.search(SELECTED_OPTION_PATTERN % 'WA',
str(self.form['state'])))
self.assertTrue(re.search(SELECTED_OPTION_PATTERN % 'QLD',
str(self.form['state_required'])))
self.assertTrue(re.search(INPUT_VALUE_PATTERN % '1234',
str(self.form['postcode'])))
self.assertTrue(re.search(INPUT_VALUE_PATTERN % '4321',
str(self.form['postcode_required'])))
def test_AUStateSelect(self):
f = AUStateSelect()
out = '''<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.assertHTMLEqual(f.render('state', 'NSW'), out)
def test_AUPostCodeField(self):
error_format = ['Enter a 4 digit postcode.']
valid = {
'1234': '1234',
'2000': '2000',
}
invalid = {
'abcd': error_format,
'20001': ['Ensure this value has at most 4 characters (it has 5).'] + error_format,
}
self.assertFieldOutput(AUPostCodeField, valid, invalid)
def test_AUPhoneNumberField(self):
error_format = ['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 File

@ -1,81 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.be.forms import (BEPostalCodeField,
BEPhoneNumberField, BERegionSelect, BEProvinceSelect)
from django.test import SimpleTestCase
class BELocalFlavorTests(SimpleTestCase):
def test_BEPostalCodeField(self):
error_format = ['Enter a valid postal code in the range and format 1XXX - 9XXX.']
valid = {
'1451': '1451',
'2540': '2540',
}
invalid = {
'0287': error_format,
'14309': error_format,
'873': error_format,
'35 74': error_format,
'859A': error_format,
}
self.assertFieldOutput(BEPostalCodeField, valid, invalid)
def test_BEPhoneNumberField(self):
error_format = [
('Enter a valid phone number in one of the formats 0x xxx xx xx, '
'0xx xx xx xx, 04xx xx xx xx, 0x/xxx.xx.xx, 0xx/xx.xx.xx, '
'04xx/xx.xx.xx, 0x.xxx.xx.xx, 0xx.xx.xx.xx, 04xx.xx.xx.xx, '
'0xxxxxxxx or 04xxxxxxxx.')
]
valid = {
'01 234 56 78': '01 234 56 78',
'01/234.56.78': '01/234.56.78',
'01.234.56.78': '01.234.56.78',
'012 34 56 78': '012 34 56 78',
'012/34.56.78': '012/34.56.78',
'012.34.56.78': '012.34.56.78',
'0412 34 56 78': '0412 34 56 78',
'0412/34.56.78': '0412/34.56.78',
'0412.34.56.78': '0412.34.56.78',
'012345678': '012345678',
'0412345678': '0412345678',
}
invalid = {
'01234567': error_format,
'12/345.67.89': error_format,
'012/345.678.90': error_format,
'012/34.56.789': error_format,
'0123/45.67.89': error_format,
'012/345 678 90': error_format,
'012/34 56 789': error_format,
'012.34 56 789': error_format,
}
self.assertFieldOutput(BEPhoneNumberField, valid, invalid)
def test_BERegionSelect(self):
f = BERegionSelect()
out = '''<select name="regions">
<option value="BRU">Brussels Capital Region</option>
<option value="VLG" selected="selected">Flemish Region</option>
<option value="WAL">Wallonia</option>
</select>'''
self.assertHTMLEqual(f.render('regions', 'VLG'), out)
def test_BEProvinceSelect(self):
f = BEProvinceSelect()
out = '''<select name="provinces">
<option value="VAN">Antwerp</option>
<option value="BRU">Brussels</option>
<option value="VOV">East Flanders</option>
<option value="VBR">Flemish Brabant</option>
<option value="WHT">Hainaut</option>
<option value="WLG" selected="selected">Liege</option>
<option value="VLI">Limburg</option>
<option value="WLX">Luxembourg</option>
<option value="WNA">Namur</option>
<option value="WBR">Walloon Brabant</option>
<option value="VWV">West Flanders</option>
</select>'''
self.assertHTMLEqual(f.render('provinces', 'WLG'), out)

View File

@ -1,146 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.br.forms import (BRZipCodeField,
BRCNPJField, BRCPFField, BRPhoneNumberField, BRStateSelect,
BRStateChoiceField)
from django.test import SimpleTestCase
class BRLocalFlavorTests(SimpleTestCase):
def test_BRZipCodeField(self):
error_format = ['Enter a zip code in the format XXXXX-XXX.']
valid = {
'12345-123': '12345-123',
}
invalid = {
'12345_123': error_format,
'1234-123': error_format,
'abcde-abc': error_format,
'12345-': error_format,
'-123': error_format,
}
self.assertFieldOutput(BRZipCodeField, valid, invalid)
def test_BRCNPJField(self):
error_format = ['Invalid CNPJ number.']
error_numbersonly = ['This field requires only numbers.']
valid = {
'64.132.916/0001-88': '64.132.916/0001-88',
'64-132-916/0001-88': '64-132-916/0001-88',
'64132916/0001-88': '64132916/0001-88',
}
invalid = {
'12-345-678/9012-10': error_format,
'12.345.678/9012-10': error_format,
'12345678/9012-10': error_format,
'64.132.916/0001-XX': error_numbersonly,
}
self.assertFieldOutput(BRCNPJField, valid, invalid)
def test_BRCPFField(self):
error_format = ['Invalid CPF number.']
error_numbersonly = ['This field requires only numbers.']
error_atmost_chars = ['Ensure this value has at most 14 characters (it has 15).']
error_atleast_chars = ['Ensure this value has at least 11 characters (it has 10).']
error_atmost = ['This field requires at most 11 digits or 14 characters.']
valid = {
'663.256.017-26': '663.256.017-26',
'66325601726': '66325601726',
'375.788.573-20': '375.788.573-20',
'84828509895': '84828509895',
}
invalid = {
'489.294.654-54': error_format,
'295.669.575-98': error_format,
'539.315.127-22': error_format,
'375.788.573-XX': error_numbersonly,
'375.788.573-000': error_atmost_chars,
'123.456.78': error_atleast_chars,
'123456789555': error_atmost,
}
self.assertFieldOutput(BRCPFField, valid, invalid)
def test_BRPhoneNumberField(self):
# TODO: this doesn't test for any invalid inputs.
valid = {
'41-3562-3464': '41-3562-3464',
'4135623464': '41-3562-3464',
'41 3562-3464': '41-3562-3464',
'41 3562 3464': '41-3562-3464',
'(41) 3562 3464': '41-3562-3464',
'41.3562.3464': '41-3562-3464',
'41.3562-3464': '41-3562-3464',
' (41) 3562.3464': '41-3562-3464',
}
invalid = {}
self.assertFieldOutput(BRPhoneNumberField, valid, invalid)
def test_BRStateSelect(self):
f = BRStateSelect()
out = '''<select name="states">
<option value="AC">Acre</option>
<option value="AL">Alagoas</option>
<option value="AP">Amap\xe1</option>
<option value="AM">Amazonas</option>
<option value="BA">Bahia</option>
<option value="CE">Cear\xe1</option>
<option value="DF">Distrito Federal</option>
<option value="ES">Esp\xedrito Santo</option>
<option value="GO">Goi\xe1s</option>
<option value="MA">Maranh\xe3o</option>
<option value="MT">Mato Grosso</option>
<option value="MS">Mato Grosso do Sul</option>
<option value="MG">Minas Gerais</option>
<option value="PA">Par\xe1</option>
<option value="PB">Para\xedba</option>
<option value="PR" selected="selected">Paran\xe1</option>
<option value="PE">Pernambuco</option>
<option value="PI">Piau\xed</option>
<option value="RJ">Rio de Janeiro</option>
<option value="RN">Rio Grande do Norte</option>
<option value="RS">Rio Grande do Sul</option>
<option value="RO">Rond\xf4nia</option>
<option value="RR">Roraima</option>
<option value="SC">Santa Catarina</option>
<option value="SP">S\xe3o Paulo</option>
<option value="SE">Sergipe</option>
<option value="TO">Tocantins</option>
</select>'''
self.assertHTMLEqual(f.render('states', 'PR'), out)
def test_BRStateChoiceField(self):
error_invalid = ['Select a valid brazilian state. That state is not one of the available states.']
valid = {
'AC': 'AC',
'AL': 'AL',
'AP': 'AP',
'AM': 'AM',
'BA': 'BA',
'CE': 'CE',
'DF': 'DF',
'ES': 'ES',
'GO': 'GO',
'MA': 'MA',
'MT': 'MT',
'MS': 'MS',
'MG': 'MG',
'PA': 'PA',
'PB': 'PB',
'PR': 'PR',
'PE': 'PE',
'PI': 'PI',
'RJ': 'RJ',
'RN': 'RN',
'RS': 'RS',
'RO': 'RO',
'RR': 'RR',
'SC': 'SC',
'SP': 'SP',
'SE': 'SE',
'TO': 'TO',
}
invalid = {
'pr': error_invalid,
}
self.assertFieldOutput(BRStateChoiceField, valid, invalid)

View File

@ -1,115 +0,0 @@
from __future__ import unicode_literals
import warnings
from django.contrib.localflavor.ca.forms import (CAPostalCodeField,
CAPhoneNumberField, CAProvinceField, CAProvinceSelect,
CASocialInsuranceNumberField)
from django.test import SimpleTestCase
class CALocalFlavorTests(SimpleTestCase):
def setUp(self):
self.save_warnings_state()
warnings.filterwarnings(
"ignore",
category=RuntimeWarning,
module='django.contrib.localflavor.ca.ca_provinces'
)
def tearDown(self):
self.restore_warnings_state()
def test_CAProvinceSelect(self):
f = CAProvinceSelect()
out = '''<select name="province">
<option value="AB" selected="selected">Alberta</option>
<option value="BC">British Columbia</option>
<option value="MB">Manitoba</option>
<option value="NB">New Brunswick</option>
<option value="NL">Newfoundland and Labrador</option>
<option value="NT">Northwest Territories</option>
<option value="NS">Nova Scotia</option>
<option value="NU">Nunavut</option>
<option value="ON">Ontario</option>
<option value="PE">Prince Edward Island</option>
<option value="QC">Quebec</option>
<option value="SK">Saskatchewan</option>
<option value="YT">Yukon</option>
</select>'''
self.assertHTMLEqual(f.render('province', 'AB'), out)
def test_CAPostalCodeField(self):
error_format = ['Enter a postal code in the format XXX XXX.']
valid = {
'T2S 2H7': 'T2S 2H7',
'T2S 2W7': 'T2S 2W7',
'T2S 2Z7': 'T2S 2Z7',
'T2Z 2H7': 'T2Z 2H7',
'T2S2H7' : 'T2S 2H7',
't2s 2h7': 'T2S 2H7',
't2s2h7' : 'T2S 2H7',
't2s 2H7': 'T2S 2H7',
' t2s 2H7 ': 'T2S 2H7',
}
invalid = {
'T2S 2H' : error_format,
'2T6 H8I': error_format,
'T2S2H' : error_format,
't2s h8i': error_format,
90210 : error_format,
'W2S 2H3': error_format,
'Z2S 2H3': error_format,
'F2S 2H3': error_format,
'A2S 2D3': error_format,
'A2I 2R3': error_format,
'A2Q 2R3': error_format,
'U2B 2R3': error_format,
'O2B 2R3': error_format,
}
self.assertFieldOutput(CAPostalCodeField, valid, invalid)
def test_CAPhoneNumberField(self):
error_format = ['Phone numbers must be in XXX-XXX-XXXX format.']
valid = {
'403-555-1212': '403-555-1212',
'4035551212': '403-555-1212',
'403 555-1212': '403-555-1212',
'(403) 555-1212': '403-555-1212',
'403 555 1212': '403-555-1212',
'403.555.1212': '403-555-1212',
'403.555-1212': '403-555-1212',
' (403) 555.1212 ': '403-555-1212',
}
invalid = {
'555-1212': error_format,
'403-55-1212': error_format,
}
self.assertFieldOutput(CAPhoneNumberField, valid, invalid)
def test_CAProvinceField(self):
error_format = ['Enter a Canadian province or territory.']
valid = {
'ab': 'AB',
'BC': 'BC',
'nova scotia': 'NS',
' manitoba ': 'MB',
'pq': 'QC',
}
invalid = {
'T2S 2H7': error_format,
}
self.assertFieldOutput(CAProvinceField, valid, invalid)
def test_CASocialInsuranceField(self):
error_format = ['Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.']
valid = {
'046-454-286': '046-454-286',
}
invalid = {
'046-454-287': error_format,
'046 454 286': error_format,
'046-44-286': error_format,
}
self.assertFieldOutput(CASocialInsuranceNumberField, valid, invalid)

View File

@ -1,76 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.ch.forms import (CHZipCodeField,
CHPhoneNumberField, CHIdentityCardNumberField, CHStateSelect)
from django.test import SimpleTestCase
class CHLocalFlavorTests(SimpleTestCase):
def test_CHStateSelect(self):
f = CHStateSelect()
out = '''<select name="state">
<option value="AG" selected="selected">Aargau</option>
<option value="AI">Appenzell Innerrhoden</option>
<option value="AR">Appenzell Ausserrhoden</option>
<option value="BS">Basel-Stadt</option>
<option value="BL">Basel-Land</option>
<option value="BE">Berne</option>
<option value="FR">Fribourg</option>
<option value="GE">Geneva</option>
<option value="GL">Glarus</option>
<option value="GR">Graubuenden</option>
<option value="JU">Jura</option>
<option value="LU">Lucerne</option>
<option value="NE">Neuchatel</option>
<option value="NW">Nidwalden</option>
<option value="OW">Obwalden</option>
<option value="SH">Schaffhausen</option>
<option value="SZ">Schwyz</option>
<option value="SO">Solothurn</option>
<option value="SG">St. Gallen</option>
<option value="TG">Thurgau</option>
<option value="TI">Ticino</option>
<option value="UR">Uri</option>
<option value="VS">Valais</option>
<option value="VD">Vaud</option>
<option value="ZG">Zug</option>
<option value="ZH">Zurich</option>
</select>'''
self.assertHTMLEqual(f.render('state', 'AG'), out)
def test_CHZipCodeField(self):
error_format = ['Enter a zip code in the format XXXX.']
valid = {
'1234': '1234',
'0000': '0000',
}
invalid = {
'800x': error_format,
'80 00': error_format,
}
self.assertFieldOutput(CHZipCodeField, valid, invalid)
def test_CHPhoneNumberField(self):
error_format = ['Phone numbers must be in 0XX XXX XX XX format.']
valid = {
'012 345 67 89': '012 345 67 89',
'0123456789': '012 345 67 89',
}
invalid = {
'01234567890': error_format,
'1234567890': error_format,
}
self.assertFieldOutput(CHPhoneNumberField, valid, invalid)
def test_CHIdentityCardNumberField(self):
error_format = ['Enter a valid Swiss identity or passport card number in X1234567<0 or 1234567890 format.']
valid = {
'C1234567<0': 'C1234567<0',
'2123456700': '2123456700',
}
invalid = {
'C1234567<1': error_format,
'2123456701': error_format,
}
self.assertFieldOutput(CHIdentityCardNumberField, valid, invalid)

View File

@ -1,58 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.cl.forms import CLRutField, CLRegionSelect
from django.test import SimpleTestCase
class CLLocalFlavorTests(SimpleTestCase):
def test_CLRegionSelect(self):
f = CLRegionSelect()
out = '''<select name="foo">
<option value="RM">Regi\xf3n Metropolitana de Santiago</option>
<option value="I">Regi\xf3n de Tarapac\xe1</option>
<option value="II">Regi\xf3n de Antofagasta</option>
<option value="III">Regi\xf3n de Atacama</option>
<option value="IV">Regi\xf3n de Coquimbo</option>
<option value="V">Regi\xf3n de Valpara\xedso</option>
<option value="VI">Regi\xf3n del Libertador Bernardo O&#39;Higgins</option>
<option value="VII">Regi\xf3n del Maule</option>
<option value="VIII">Regi\xf3n del B\xedo B\xedo</option>
<option value="IX">Regi\xf3n de la Araucan\xeda</option>
<option value="X">Regi\xf3n de los Lagos</option>
<option value="XI">Regi\xf3n de Ays\xe9n del General Carlos Ib\xe1\xf1ez del Campo</option>
<option value="XII">Regi\xf3n de Magallanes y la Ant\xe1rtica Chilena</option>
<option value="XIV">Regi\xf3n de Los R\xedos</option>
<option value="XV">Regi\xf3n de Arica-Parinacota</option>
</select>'''
self.assertHTMLEqual(f.render('foo', 'bar'), out)
def test_CLRutField(self):
error_invalid = ['The Chilean RUT is not valid.']
error_format = ['Enter a valid Chilean RUT. The format is XX.XXX.XXX-X.']
valid = {
'11-6': '11-6',
'116': '11-6',
'767484100': '76.748.410-0',
'78.412.790-7': '78.412.790-7',
'8.334.6043': '8.334.604-3',
'76793310-K': '76.793.310-K',
'76793310-k': '76.793.310-K',
}
invalid = {
'11.111.111-0': error_invalid,
'111': error_invalid,
}
self.assertFieldOutput(CLRutField, valid, invalid)
# deal with special "Strict Mode".
invalid = {
'11-6': error_format,
'767484100': error_format,
'8.334.6043': error_format,
'76793310-K': error_format,
'11.111.111-0': error_invalid
}
self.assertFieldOutput(CLRutField,
{}, invalid, field_kwargs={"strict": True}
)

View File

@ -1,113 +0,0 @@
# Tests for contrib/localflavor/ CN Form Fields
from __future__ import unicode_literals
from django.contrib.localflavor.cn.forms import (CNProvinceSelect,
CNPostCodeField, CNIDCardField, CNPhoneNumberField, CNCellNumberField)
from django.test import SimpleTestCase
class CNLocalFlavorTests(SimpleTestCase):
def test_CNProvinceSelect(self):
f = CNProvinceSelect()
correct_output = '''<select name="provinces">
<option value="anhui">\u5b89\u5fbd</option>
<option value="beijing">\u5317\u4eac</option>
<option value="chongqing">\u91cd\u5e86</option>
<option value="fujian">\u798f\u5efa</option>
<option value="gansu">\u7518\u8083</option>
<option value="guangdong">\u5e7f\u4e1c</option>
<option value="guangxi">\u5e7f\u897f\u58ee\u65cf\u81ea\u6cbb\u533a</option>
<option value="guizhou">\u8d35\u5dde</option>
<option value="hainan">\u6d77\u5357</option>
<option value="hebei">\u6cb3\u5317</option>
<option value="heilongjiang">\u9ed1\u9f99\u6c5f</option>
<option value="henan">\u6cb3\u5357</option>
<option value="hongkong">\u9999\u6e2f</option>
<option value="hubei" selected="selected">\u6e56\u5317</option>
<option value="hunan">\u6e56\u5357</option>
<option value="jiangsu">\u6c5f\u82cf</option>
<option value="jiangxi">\u6c5f\u897f</option>
<option value="jilin">\u5409\u6797</option>
<option value="liaoning">\u8fbd\u5b81</option>
<option value="macao">\u6fb3\u95e8</option>
<option value="neimongol">\u5185\u8499\u53e4\u81ea\u6cbb\u533a</option>
<option value="ningxia">\u5b81\u590f\u56de\u65cf\u81ea\u6cbb\u533a</option>
<option value="qinghai">\u9752\u6d77</option>
<option value="shaanxi">\u9655\u897f</option>
<option value="shandong">\u5c71\u4e1c</option>
<option value="shanghai">\u4e0a\u6d77</option>
<option value="shanxi">\u5c71\u897f</option>
<option value="sichuan">\u56db\u5ddd</option>
<option value="taiwan">\u53f0\u6e7e</option>
<option value="tianjin">\u5929\u6d25</option>
<option value="xinjiang">\u65b0\u7586\u7ef4\u543e\u5c14\u81ea\u6cbb\u533a</option>
<option value="xizang">\u897f\u85cf\u81ea\u6cbb\u533a</option>
<option value="yunnan">\u4e91\u5357</option>
<option value="zhejiang">\u6d59\u6c5f</option>
</select>'''
self.assertHTMLEqual(f.render('provinces', 'hubei'), correct_output)
def test_CNPostCodeField(self):
error_format = ['Enter a post code in the format XXXXXX.']
valid = {
'091209': '091209'
}
invalid = {
'09120': error_format,
'09120916': error_format
}
self.assertFieldOutput(CNPostCodeField, valid, invalid)
def test_CNIDCardField(self):
valid = {
# A valid 1st generation ID Card Number.
'110101491001001': '110101491001001',
# A valid 2nd generation ID Card number.
'11010119491001001X': '11010119491001001X',
# Another valid 2nd gen ID Number with a case change
'11010119491001001x': '11010119491001001X'
}
wrong_format = ['ID Card Number consists of 15 or 18 digits.']
wrong_location = ['Invalid ID Card Number: Wrong location code']
wrong_bday = ['Invalid ID Card Number: Wrong birthdate']
wrong_checksum = ['Invalid ID Card Number: Wrong checksum']
invalid = {
'abcdefghijklmnop': wrong_format,
'1010101010101010': wrong_format,
'010101491001001' : wrong_location, # 1st gen, 01 is invalid
'110101491041001' : wrong_bday, # 1st gen. There wasn't day 41
'92010119491001001X': wrong_location, # 2nd gen, 92 is invalid
'91010119491301001X': wrong_bday, # 2nd gen, 19491301 is invalid date
'910101194910010014': wrong_checksum #2nd gen
}
self.assertFieldOutput(CNIDCardField, valid, invalid)
def test_CNPhoneNumberField(self):
error_format = ['Enter a valid phone number.']
valid = {
'010-12345678': '010-12345678',
'010-1234567': '010-1234567',
'0101-12345678': '0101-12345678',
'0101-1234567': '0101-1234567',
'010-12345678-020':'010-12345678-020'
}
invalid = {
'01x-12345678': error_format,
'12345678': error_format,
'01123-12345678': error_format,
'010-123456789': error_format,
'010-12345678-': error_format
}
self.assertFieldOutput(CNPhoneNumberField, valid, invalid)
def test_CNCellNumberField(self):
error_format = ['Enter a valid cell number.']
valid = {
'13012345678': '13012345678',
}
invalid = {
'130123456789': error_format,
'14012345678': error_format
}
self.assertFieldOutput(CNCellNumberField, valid, invalid)

View File

@ -1,45 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.co.forms import CODepartmentSelect
from django.test import SimpleTestCase
class COLocalFlavorTests(SimpleTestCase):
def test_CODepartmentSelect(self):
d = CODepartmentSelect()
out = """<select name="department">
<option value="AMA">Amazonas</option>
<option value="ANT">Antioquia</option>
<option value="ARA">Arauca</option>
<option value="ATL">Atl\xe1ntico</option>
<option value="DC">Bogot\xe1</option>
<option value="BOL">Bol\xedvar</option>
<option value="BOY">Boyac\xe1</option>
<option value="CAL">Caldas</option>
<option value="CAQ">Caquet\xe1</option>
<option value="CAS">Casanare</option>
<option value="CAU">Cauca</option>
<option value="CES">Cesar</option>
<option value="CHO">Choc\xf3</option>
<option value="COR" selected="selected">C\xf3rdoba</option>
<option value="CUN">Cundinamarca</option>
<option value="GUA">Guain\xeda</option>
<option value="GUV">Guaviare</option>
<option value="HUI">Huila</option>
<option value="LAG">La Guajira</option>
<option value="MAG">Magdalena</option>
<option value="MET">Meta</option>
<option value="NAR">Nari\xf1o</option>
<option value="NSA">Norte de Santander</option>
<option value="PUT">Putumayo</option>
<option value="QUI">Quind\xedo</option>
<option value="RIS">Risaralda</option>
<option value="SAP">San Andr\xe9s and Providencia</option>
<option value="SAN">Santander</option>
<option value="SUC">Sucre</option>
<option value="TOL">Tolima</option>
<option value="VAC">Valle del Cauca</option>
<option value="VAU">Vaup\xe9s</option>
<option value="VID">Vichada</option>
</select>"""
self.assertHTMLEqual(d.render('department', 'COR'), out)

View File

@ -1,80 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.cz.forms import (CZPostalCodeField,
CZRegionSelect, CZBirthNumberField, CZICNumberField)
from django.core.exceptions import ValidationError
from django.test import SimpleTestCase
class CZLocalFlavorTests(SimpleTestCase):
def test_CZRegionSelect(self):
f = CZRegionSelect()
out = '''<select name="regions">
<option value="PR">Prague</option>
<option value="CE">Central Bohemian Region</option>
<option value="SO">South Bohemian Region</option>
<option value="PI">Pilsen Region</option>
<option value="CA">Carlsbad Region</option>
<option value="US">Usti Region</option>
<option value="LB">Liberec Region</option>
<option value="HK">Hradec Region</option>
<option value="PA">Pardubice Region</option>
<option value="VY">Vysocina Region</option>
<option value="SM">South Moravian Region</option>
<option value="OL">Olomouc Region</option>
<option value="ZL">Zlin Region</option>
<option value="MS">Moravian-Silesian Region</option>
</select>'''
self.assertHTMLEqual(f.render('regions', 'TT'), out)
def test_CZPostalCodeField(self):
error_format = ['Enter a postal code in the format XXXXX or XXX XX.']
valid = {
'91909': '91909',
'917 01': '91701',
'12345': '12345',
}
invalid = {
'84545x': error_format,
'123456': error_format,
'1234': error_format,
'123 4': error_format,
}
self.assertFieldOutput(CZPostalCodeField, valid, invalid)
def test_CZBirthNumberField(self):
error_format = ['Enter a birth number in the format XXXXXX/XXXX or XXXXXXXXXX.']
error_invalid = ['Enter a valid birth number.']
valid = {
'880523/1237': '880523/1237',
'8805231237': '8805231237',
'880523/000': '880523/000',
'880523000': '880523000',
'882101/0011': '882101/0011',
}
invalid = {
'123456/12': error_format,
'123456/12345': error_format,
'12345612': error_format,
'12345612345': error_format,
'880523/1239': error_invalid,
'8805231239': error_invalid,
'990101/0011': error_invalid,
}
self.assertFieldOutput(CZBirthNumberField, valid, invalid)
def test_CZICNumberField(self):
error_invalid = ['Enter a valid IC number.']
valid ={
'12345679': '12345679',
'12345601': '12345601',
'12345661': '12345661',
'12345610': '12345610',
}
invalid = {
'1234567': error_invalid,
'12345660': error_invalid,
'12345600': error_invalid,
}
self.assertFieldOutput(CZICNumberField, valid, invalid)

View File

@ -1,51 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.de.forms import (DEZipCodeField, DEStateSelect,
DEIdentityCardNumberField)
from django.test import SimpleTestCase
class DELocalFlavorTests(SimpleTestCase):
def test_DEStateSelect(self):
f = DEStateSelect()
out = '''<select name="states">
<option value="BW">Baden-Wuerttemberg</option>
<option value="BY">Bavaria</option>
<option value="BE">Berlin</option>
<option value="BB">Brandenburg</option>
<option value="HB">Bremen</option>
<option value="HH">Hamburg</option>
<option value="HE">Hessen</option>
<option value="MV">Mecklenburg-Western Pomerania</option>
<option value="NI">Lower Saxony</option>
<option value="NW">North Rhine-Westphalia</option>
<option value="RP">Rhineland-Palatinate</option>
<option value="SL">Saarland</option>
<option value="SN">Saxony</option>
<option value="ST">Saxony-Anhalt</option>
<option value="SH">Schleswig-Holstein</option>
<option value="TH" selected="selected">Thuringia</option>
</select>'''
self.assertHTMLEqual(f.render('states', 'TH'), out)
def test_DEZipCodeField(self):
error_format = ['Enter a zip code in the format XXXXX.']
valid = {
'99423': '99423',
}
invalid = {
' 99423': error_format,
}
self.assertFieldOutput(DEZipCodeField, valid, invalid)
def test_DEIdentityCardNumberField(self):
error_format = ['Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.']
valid = {
'7549313035D-6004103-0903042-0': '7549313035D-6004103-0903042-0',
'9786324830D 6104243 0910271 2': '9786324830D-6104243-0910271-2',
}
invalid = {
'0434657485D-6407276-0508137-9': error_format,
}
self.assertFieldOutput(DEIdentityCardNumberField, valid, invalid)

View File

@ -1,36 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.ec.forms import ECProvinceSelect
from django.test import SimpleTestCase
class ECLocalFlavorTests(SimpleTestCase):
def test_ECProvinceSelect(self):
p = ECProvinceSelect()
out = """<select name="province">
<option value="A">Azuay</option>
<option value="B">Bol\xedvar</option>
<option value="F">Ca\xf1ar</option>
<option value="C">Carchi</option>
<option value="H">Chimborazo</option>
<option value="X">Cotopaxi</option>
<option value="O">El Oro</option>
<option value="E">Esmeraldas</option>
<option value="W">Gal\xe1pagos</option>
<option value="G">Guayas</option>
<option value="I">Imbabura</option>
<option value="L">Loja</option>
<option value="R">Los R\xedos</option>
<option value="M">Manab\xed</option>
<option value="S">Morona Santiago</option>
<option value="N">Napo</option>
<option value="D">Orellana</option>
<option value="Y">Pastaza</option>
<option value="P">Pichincha</option>
<option value="SE">Santa Elena</option>
<option value="SD">Santo Domingo de los Ts\xe1chilas</option>
<option value="U" selected="selected">Sucumb\xedos</option>
<option value="T">Tungurahua</option>
<option value="Z">Zamora Chinchipe</option>
</select>"""
self.assertHTMLEqual(p.render('province', 'U'), out)

View File

@ -1,173 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.es.forms import (ESPostalCodeField, ESPhoneNumberField,
ESIdentityCardNumberField, ESCCCField, ESRegionSelect, ESProvinceSelect)
from django.test import SimpleTestCase
class ESLocalFlavorTests(SimpleTestCase):
def test_ESRegionSelect(self):
f = ESRegionSelect()
out = '''<select name="regions">
<option value="AN">Andalusia</option>
<option value="AR">Aragon</option>
<option value="O">Principality of Asturias</option>
<option value="IB">Balearic Islands</option>
<option value="PV">Basque Country</option>
<option value="CN">Canary Islands</option>
<option value="S">Cantabria</option>
<option value="CM">Castile-La Mancha</option>
<option value="CL">Castile and Leon</option>
<option value="CT" selected="selected">Catalonia</option>
<option value="EX">Extremadura</option>
<option value="GA">Galicia</option>
<option value="LO">La Rioja</option>
<option value="M">Madrid</option>
<option value="MU">Region of Murcia</option>
<option value="NA">Foral Community of Navarre</option>
<option value="VC">Valencian Community</option>
</select>'''
self.assertHTMLEqual(f.render('regions', 'CT'), out)
def test_ESProvinceSelect(self):
f = ESProvinceSelect()
out = '''<select name="provinces">
<option value="01">Araba</option>
<option value="02">Albacete</option>
<option value="03">Alacant</option>
<option value="04">Almeria</option>
<option value="05">Avila</option>
<option value="06">Badajoz</option>
<option value="07">Illes Balears</option>
<option value="08" selected="selected">Barcelona</option>
<option value="09">Burgos</option>
<option value="10">Caceres</option>
<option value="11">Cadiz</option>
<option value="12">Castello</option>
<option value="13">Ciudad Real</option>
<option value="14">Cordoba</option>
<option value="15">A Coruna</option>
<option value="16">Cuenca</option>
<option value="17">Girona</option>
<option value="18">Granada</option>
<option value="19">Guadalajara</option>
<option value="20">Guipuzkoa</option>
<option value="21">Huelva</option>
<option value="22">Huesca</option>
<option value="23">Jaen</option>
<option value="24">Leon</option>
<option value="25">Lleida</option>
<option value="26">La Rioja</option>
<option value="27">Lugo</option>
<option value="28">Madrid</option>
<option value="29">Malaga</option>
<option value="30">Murcia</option>
<option value="31">Navarre</option>
<option value="32">Ourense</option>
<option value="33">Asturias</option>
<option value="34">Palencia</option>
<option value="35">Las Palmas</option>
<option value="36">Pontevedra</option>
<option value="37">Salamanca</option>
<option value="38">Santa Cruz de Tenerife</option>
<option value="39">Cantabria</option>
<option value="40">Segovia</option>
<option value="41">Seville</option>
<option value="42">Soria</option>
<option value="43">Tarragona</option>
<option value="44">Teruel</option>
<option value="45">Toledo</option>
<option value="46">Valencia</option>
<option value="47">Valladolid</option>
<option value="48">Bizkaia</option>
<option value="49">Zamora</option>
<option value="50">Zaragoza</option>
<option value="51">Ceuta</option>
<option value="52">Melilla</option>
</select>'''
self.assertHTMLEqual(f.render('provinces', '08'), out)
def test_ESPostalCodeField(self):
error_invalid = ['Enter a valid postal code in the range and format 01XXX - 52XXX.']
valid = {
'08028': '08028',
'28080': '28080',
}
invalid = {
'53001': error_invalid,
'0801': error_invalid,
'080001': error_invalid,
'00999': error_invalid,
'08 01': error_invalid,
'08A01': error_invalid,
}
self.assertFieldOutput(ESPostalCodeField, valid, invalid)
def test_ESPhoneNumberField(self):
error_invalid = ['Enter a valid phone number in one of the formats 6XXXXXXXX, 8XXXXXXXX or 9XXXXXXXX.']
valid = {
'650010101': '650010101',
'931234567': '931234567',
'800123123': '800123123',
'789789789': '789789789',
}
invalid = {
'555555555': error_invalid,
'489489489': error_invalid,
'99123123': error_invalid,
'9999123123': error_invalid,
}
self.assertFieldOutput(ESPhoneNumberField, valid, invalid)
def test_ESIdentityCardNumberField(self):
error_invalid = ['Please enter a valid NIF, NIE, or CIF.']
error_checksum_nif = ['Invalid checksum for NIF.']
error_checksum_nie = ['Invalid checksum for NIE.']
error_checksum_cif = ['Invalid checksum for CIF.']
valid = {
'78699688J': '78699688J',
'78699688-J': '78699688J',
'78699688 J': '78699688J',
'78699688 j': '78699688J',
'X0901797J': 'X0901797J',
'X-6124387-Q': 'X6124387Q',
'X 0012953 G': 'X0012953G',
'x-3287690-r': 'X3287690R',
't-03287690r': 'T03287690R',
'P2907500I': 'P2907500I',
'B38790911': 'B38790911',
'B31234560': 'B31234560',
'B-3879091A': 'B3879091A',
'B 38790911': 'B38790911',
'P-3900800-H': 'P3900800H',
'P 39008008': 'P39008008',
'C-28795565': 'C28795565',
'C 2879556E': 'C2879556E',
}
invalid = {
'78699688T': error_checksum_nif,
'X-03287690': error_invalid,
'X-03287690-T': error_checksum_nie,
'B 38790917': error_checksum_cif,
'C28795567': error_checksum_cif,
'I38790911': error_invalid,
'78699688-2': error_invalid,
}
self.assertFieldOutput(ESIdentityCardNumberField, valid, invalid)
def test_ESCCCField(self):
error_invalid = ['Please enter a valid bank account number in format XXXX-XXXX-XX-XXXXXXXXXX.']
error_checksum = ['Invalid checksum for bank account number.']
valid = {
'20770338793100254321': '20770338793100254321',
'2077 0338 79 3100254321': '2077 0338 79 3100254321',
'2077-0338-79-3100254321': '2077-0338-79-3100254321',
}
invalid = {
'2077.0338.79.3100254321': error_invalid,
'2077-0338-78-3100254321': error_checksum,
'2077-0338-89-3100254321': error_checksum,
'2077-03-3879-3100254321': error_invalid,
}
self.assertFieldOutput(ESCCCField, valid, invalid)

View File

@ -1,383 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.fi.forms import (FIZipCodeField,
FISocialSecurityNumber, FIMunicipalitySelect)
from django.test import SimpleTestCase
class FILocalFlavorTests(SimpleTestCase):
def test_FIMunicipalitySelect(self):
f = FIMunicipalitySelect()
out = '''<select name="municipalities">
<option value="akaa">Akaa</option>
<option value="alajarvi">Alaj\xe4rvi</option>
<option value="alavieska">Alavieska</option>
<option value="alavus">Alavus</option>
<option value="artjarvi">Artj\xe4rvi</option>
<option value="asikkala">Asikkala</option>
<option value="askola">Askola</option>
<option value="aura">Aura</option>
<option value="brando">Br\xe4nd\xf6</option>
<option value="eckero">Ecker\xf6</option>
<option value="enonkoski">Enonkoski</option>
<option value="enontekio">Enonteki\xf6</option>
<option value="espoo">Espoo</option>
<option value="eura">Eura</option>
<option value="eurajoki">Eurajoki</option>
<option value="evijarvi">Evij\xe4rvi</option>
<option value="finstrom">Finstr\xf6m</option>
<option value="forssa">Forssa</option>
<option value="foglo">F\xf6gl\xf6</option>
<option value="geta">Geta</option>
<option value="haapajarvi">Haapaj\xe4rvi</option>
<option value="haapavesi">Haapavesi</option>
<option value="hailuoto">Hailuoto</option>
<option value="halsua">Halsua</option>
<option value="hamina">Hamina</option>
<option value="hammarland">Hammarland</option>
<option value="hankasalmi">Hankasalmi</option>
<option value="hanko">Hanko</option>
<option value="harjavalta">Harjavalta</option>
<option value="hartola">Hartola</option>
<option value="hattula">Hattula</option>
<option value="haukipudas">Haukipudas</option>
<option value="hausjarvi">Hausj\xe4rvi</option>
<option value="heinola">Heinola</option>
<option value="heinavesi">Hein\xe4vesi</option>
<option value="helsinki">Helsinki</option>
<option value="hirvensalmi">Hirvensalmi</option>
<option value="hollola">Hollola</option>
<option value="honkajoki">Honkajoki</option>
<option value="huittinen">Huittinen</option>
<option value="humppila">Humppila</option>
<option value="hyrynsalmi">Hyrynsalmi</option>
<option value="hyvinkaa">Hyvink\xe4\xe4</option>
<option value="hameenkoski">H\xe4meenkoski</option>
<option value="hameenkyro">H\xe4meenkyr\xf6</option>
<option value="hameenlinna">H\xe4meenlinna</option>
<option value="ii">Ii</option>
<option value="iisalmi">Iisalmi</option>
<option value="iitti">Iitti</option>
<option value="ikaalinen">Ikaalinen</option>
<option value="ilmajoki">Ilmajoki</option>
<option value="ilomantsi">Ilomantsi</option>
<option value="imatra">Imatra</option>
<option value="inari">Inari</option>
<option value="inkoo">Inkoo</option>
<option value="isojoki">Isojoki</option>
<option value="isokyro">Isokyr\xf6</option>
<option value="jalasjarvi">Jalasj\xe4rvi</option>
<option value="janakkala">Janakkala</option>
<option value="joensuu">Joensuu</option>
<option value="jokioinen">Jokioinen</option>
<option value="jomala">Jomala</option>
<option value="joroinen">Joroinen</option>
<option value="joutsa">Joutsa</option>
<option value="juankoski">Juankoski</option>
<option value="juuka">Juuka</option>
<option value="juupajoki">Juupajoki</option>
<option value="juva">Juva</option>
<option value="jyvaskyla">Jyv\xe4skyl\xe4</option>
<option value="jamijarvi">J\xe4mij\xe4rvi</option>
<option value="jamsa">J\xe4ms\xe4</option>
<option value="jarvenpaa">J\xe4rvenp\xe4\xe4</option>
<option value="kaarina">Kaarina</option>
<option value="kaavi">Kaavi</option>
<option value="kajaani">Kajaani</option>
<option value="kalajoki">Kalajoki</option>
<option value="kangasala">Kangasala</option>
<option value="kangasniemi">Kangasniemi</option>
<option value="kankaanpaa">Kankaanp\xe4\xe4</option>
<option value="kannonkoski">Kannonkoski</option>
<option value="kannus">Kannus</option>
<option value="karijoki">Karijoki</option>
<option value="karjalohja">Karjalohja</option>
<option value="karkkila">Karkkila</option>
<option value="karstula">Karstula</option>
<option value="karttula">Karttula</option>
<option value="karvia">Karvia</option>
<option value="kaskinen">Kaskinen</option>
<option value="kauhajoki">Kauhajoki</option>
<option value="kauhava">Kauhava</option>
<option value="kauniainen">Kauniainen</option>
<option value="kaustinen">Kaustinen</option>
<option value="keitele">Keitele</option>
<option value="kemi">Kemi</option>
<option value="kemijarvi">Kemij\xe4rvi</option>
<option value="keminmaa">Keminmaa</option>
<option value="kemionsaari">Kemi\xf6nsaari</option>
<option value="kempele">Kempele</option>
<option value="kerava">Kerava</option>
<option value="kerimaki">Kerim\xe4ki</option>
<option value="kesalahti">Kes\xe4lahti</option>
<option value="keuruu">Keuruu</option>
<option value="kihnio">Kihni\xf6</option>
<option value="kiikoinen">Kiikoinen</option>
<option value="kiiminki">Kiiminki</option>
<option value="kinnula">Kinnula</option>
<option value="kirkkonummi">Kirkkonummi</option>
<option value="kitee">Kitee</option>
<option value="kittila">Kittil\xe4</option>
<option value="kiuruvesi">Kiuruvesi</option>
<option value="kivijarvi">Kivij\xe4rvi</option>
<option value="kokemaki">Kokem\xe4ki</option>
<option value="kokkola">Kokkola</option>
<option value="kolari">Kolari</option>
<option value="konnevesi">Konnevesi</option>
<option value="kontiolahti">Kontiolahti</option>
<option value="korsnas">Korsn\xe4s</option>
<option value="koskitl">Koski Tl</option>
<option value="kotka">Kotka</option>
<option value="kouvola">Kouvola</option>
<option value="kristiinankaupunki">Kristiinankaupunki</option>
<option value="kruunupyy">Kruunupyy</option>
<option value="kuhmalahti">Kuhmalahti</option>
<option value="kuhmo">Kuhmo</option>
<option value="kuhmoinen">Kuhmoinen</option>
<option value="kumlinge">Kumlinge</option>
<option value="kuopio">Kuopio</option>
<option value="kuortane">Kuortane</option>
<option value="kurikka">Kurikka</option>
<option value="kustavi">Kustavi</option>
<option value="kuusamo">Kuusamo</option>
<option value="kylmakoski">Kylm\xe4koski</option>
<option value="kyyjarvi">Kyyj\xe4rvi</option>
<option value="karkola">K\xe4rk\xf6l\xe4</option>
<option value="karsamaki">K\xe4rs\xe4m\xe4ki</option>
<option value="kokar">K\xf6kar</option>
<option value="koylio">K\xf6yli\xf6</option>
<option value="lahti">Lahti</option>
<option value="laihia">Laihia</option>
<option value="laitila">Laitila</option>
<option value="lapinjarvi">Lapinj\xe4rvi</option>
<option value="lapinlahti">Lapinlahti</option>
<option value="lappajarvi">Lappaj\xe4rvi</option>
<option value="lappeenranta">Lappeenranta</option>
<option value="lapua">Lapua</option>
<option value="laukaa">Laukaa</option>
<option value="lavia">Lavia</option>
<option value="lemi">Lemi</option>
<option value="lemland">Lemland</option>
<option value="lempaala">Lemp\xe4\xe4l\xe4</option>
<option value="leppavirta">Lepp\xe4virta</option>
<option value="lestijarvi">Lestij\xe4rvi</option>
<option value="lieksa">Lieksa</option>
<option value="lieto">Lieto</option>
<option value="liminka">Liminka</option>
<option value="liperi">Liperi</option>
<option value="lohja">Lohja</option>
<option value="loimaa">Loimaa</option>
<option value="loppi">Loppi</option>
<option value="loviisa">Loviisa</option>
<option value="luhanka">Luhanka</option>
<option value="lumijoki">Lumijoki</option>
<option value="lumparland">Lumparland</option>
<option value="luoto">Luoto</option>
<option value="luumaki">Luum\xe4ki</option>
<option value="luvia">Luvia</option>
<option value="lansi-turunmaa">L\xe4nsi-Turunmaa</option>
<option value="maalahti">Maalahti</option>
<option value="maaninka">Maaninka</option>
<option value="maarianhamina">Maarianhamina</option>
<option value="marttila">Marttila</option>
<option value="masku">Masku</option>
<option value="merijarvi">Merij\xe4rvi</option>
<option value="merikarvia">Merikarvia</option>
<option value="miehikkala">Miehikk\xe4l\xe4</option>
<option value="mikkeli">Mikkeli</option>
<option value="muhos">Muhos</option>
<option value="multia">Multia</option>
<option value="muonio">Muonio</option>
<option value="mustasaari">Mustasaari</option>
<option value="muurame">Muurame</option>
<option value="mynamaki">Myn\xe4m\xe4ki</option>
<option value="myrskyla">Myrskyl\xe4</option>
<option value="mantsala">M\xe4nts\xe4l\xe4</option>
<option value="mantta-vilppula">M\xe4ntt\xe4-Vilppula</option>
<option value="mantyharju">M\xe4ntyharju</option>
<option value="naantali">Naantali</option>
<option value="nakkila">Nakkila</option>
<option value="nastola">Nastola</option>
<option value="nilsia">Nilsi\xe4</option>
<option value="nivala">Nivala</option>
<option value="nokia">Nokia</option>
<option value="nousiainen">Nousiainen</option>
<option value="nummi-pusula">Nummi-Pusula</option>
<option value="nurmes">Nurmes</option>
<option value="nurmijarvi">Nurmij\xe4rvi</option>
<option value="narpio">N\xe4rpi\xf6</option>
<option value="oravainen">Oravainen</option>
<option value="orimattila">Orimattila</option>
<option value="oripaa">Orip\xe4\xe4</option>
<option value="orivesi">Orivesi</option>
<option value="oulainen">Oulainen</option>
<option value="oulu">Oulu</option>
<option value="oulunsalo">Oulunsalo</option>
<option value="outokumpu">Outokumpu</option>
<option value="padasjoki">Padasjoki</option>
<option value="paimio">Paimio</option>
<option value="paltamo">Paltamo</option>
<option value="parikkala">Parikkala</option>
<option value="parkano">Parkano</option>
<option value="pedersore">Peders\xf6re</option>
<option value="pelkosenniemi">Pelkosenniemi</option>
<option value="pello">Pello</option>
<option value="perho">Perho</option>
<option value="pertunmaa">Pertunmaa</option>
<option value="petajavesi">Pet\xe4j\xe4vesi</option>
<option value="pieksamaki">Pieks\xe4m\xe4ki</option>
<option value="pielavesi">Pielavesi</option>
<option value="pietarsaari">Pietarsaari</option>
<option value="pihtipudas">Pihtipudas</option>
<option value="pirkkala">Pirkkala</option>
<option value="polvijarvi">Polvij\xe4rvi</option>
<option value="pomarkku">Pomarkku</option>
<option value="pori">Pori</option>
<option value="pornainen">Pornainen</option>
<option value="porvoo">Porvoo</option>
<option value="posio">Posio</option>
<option value="pudasjarvi">Pudasj\xe4rvi</option>
<option value="pukkila">Pukkila</option>
<option value="punkaharju">Punkaharju</option>
<option value="punkalaidun">Punkalaidun</option>
<option value="puolanka">Puolanka</option>
<option value="puumala">Puumala</option>
<option value="pyhtaa">Pyht\xe4\xe4</option>
<option value="pyhajoki">Pyh\xe4joki</option>
<option value="pyhajarvi">Pyh\xe4j\xe4rvi</option>
<option value="pyhanta">Pyh\xe4nt\xe4</option>
<option value="pyharanta">Pyh\xe4ranta</option>
<option value="palkane">P\xe4lk\xe4ne</option>
<option value="poytya">P\xf6yty\xe4</option>
<option value="raahe">Raahe</option>
<option value="raasepori">Raasepori</option>
<option value="raisio">Raisio</option>
<option value="rantasalmi">Rantasalmi</option>
<option value="ranua">Ranua</option>
<option value="rauma">Rauma</option>
<option value="rautalampi">Rautalampi</option>
<option value="rautavaara">Rautavaara</option>
<option value="rautjarvi">Rautj\xe4rvi</option>
<option value="reisjarvi">Reisj\xe4rvi</option>
<option value="riihimaki">Riihim\xe4ki</option>
<option value="ristiina">Ristiina</option>
<option value="ristijarvi">Ristij\xe4rvi</option>
<option value="rovaniemi">Rovaniemi</option>
<option value="ruokolahti">Ruokolahti</option>
<option value="ruovesi">Ruovesi</option>
<option value="rusko">Rusko</option>
<option value="raakkyla">R\xe4\xe4kkyl\xe4</option>
<option value="saarijarvi">Saarij\xe4rvi</option>
<option value="salla">Salla</option>
<option value="salo">Salo</option>
<option value="saltvik">Saltvik</option>
<option value="sastamala">Sastamala</option>
<option value="sauvo">Sauvo</option>
<option value="savitaipale">Savitaipale</option>
<option value="savonlinna">Savonlinna</option>
<option value="savukoski">Savukoski</option>
<option value="seinajoki">Sein\xe4joki</option>
<option value="sievi">Sievi</option>
<option value="siikainen">Siikainen</option>
<option value="siikajoki">Siikajoki</option>
<option value="siikalatva">Siikalatva</option>
<option value="siilinjarvi">Siilinj\xe4rvi</option>
<option value="simo">Simo</option>
<option value="sipoo">Sipoo</option>
<option value="siuntio">Siuntio</option>
<option value="sodankyla">Sodankyl\xe4</option>
<option value="soini">Soini</option>
<option value="somero">Somero</option>
<option value="sonkajarvi">Sonkaj\xe4rvi</option>
<option value="sotkamo">Sotkamo</option>
<option value="sottunga">Sottunga</option>
<option value="sulkava">Sulkava</option>
<option value="sund">Sund</option>
<option value="suomenniemi">Suomenniemi</option>
<option value="suomussalmi">Suomussalmi</option>
<option value="suonenjoki">Suonenjoki</option>
<option value="sysma">Sysm\xe4</option>
<option value="sakyla">S\xe4kyl\xe4</option>
<option value="taipalsaari">Taipalsaari</option>
<option value="taivalkoski">Taivalkoski</option>
<option value="taivassalo">Taivassalo</option>
<option value="tammela">Tammela</option>
<option value="tampere">Tampere</option>
<option value="tarvasjoki">Tarvasjoki</option>
<option value="tervo">Tervo</option>
<option value="tervola">Tervola</option>
<option value="teuva">Teuva</option>
<option value="tohmajarvi">Tohmaj\xe4rvi</option>
<option value="toholampi">Toholampi</option>
<option value="toivakka">Toivakka</option>
<option value="tornio">Tornio</option>
<option value="turku" selected="selected">Turku</option>
<option value="tuusniemi">Tuusniemi</option>
<option value="tuusula">Tuusula</option>
<option value="tyrnava">Tyrn\xe4v\xe4</option>
<option value="toysa">T\xf6ys\xe4</option>
<option value="ulvila">Ulvila</option>
<option value="urjala">Urjala</option>
<option value="utajarvi">Utaj\xe4rvi</option>
<option value="utsjoki">Utsjoki</option>
<option value="uurainen">Uurainen</option>
<option value="uusikaarlepyy">Uusikaarlepyy</option>
<option value="uusikaupunki">Uusikaupunki</option>
<option value="vaala">Vaala</option>
<option value="vaasa">Vaasa</option>
<option value="valkeakoski">Valkeakoski</option>
<option value="valtimo">Valtimo</option>
<option value="vantaa">Vantaa</option>
<option value="varkaus">Varkaus</option>
<option value="varpaisjarvi">Varpaisj\xe4rvi</option>
<option value="vehmaa">Vehmaa</option>
<option value="vesanto">Vesanto</option>
<option value="vesilahti">Vesilahti</option>
<option value="veteli">Veteli</option>
<option value="vierema">Vierem\xe4</option>
<option value="vihanti">Vihanti</option>
<option value="vihti">Vihti</option>
<option value="viitasaari">Viitasaari</option>
<option value="vimpeli">Vimpeli</option>
<option value="virolahti">Virolahti</option>
<option value="virrat">Virrat</option>
<option value="vardo">V\xe5rd\xf6</option>
<option value="vahakyro">V\xe4h\xe4kyr\xf6</option>
<option value="voyri-maksamaa">V\xf6yri-Maksamaa</option>
<option value="yli-ii">Yli-Ii</option>
<option value="ylitornio">Ylitornio</option>
<option value="ylivieska">Ylivieska</option>
<option value="ylojarvi">Yl\xf6j\xe4rvi</option>
<option value="ypaja">Yp\xe4j\xe4</option>
<option value="ahtari">\xc4ht\xe4ri</option>
<option value="aanekoski">\xc4\xe4nekoski</option>
</select>'''
self.assertHTMLEqual(f.render('municipalities', 'turku'), out)
def test_FIZipCodeField(self):
error_format = ['Enter a zip code in the format XXXXX.']
valid = {
'20540': '20540',
'20101': '20101',
}
invalid = {
'20s40': error_format,
'205401': error_format
}
self.assertFieldOutput(FIZipCodeField, valid, invalid)
def test_FISocialSecurityNumber(self):
error_invalid = ['Enter a valid Finnish social security number.']
valid = {
'010101-0101': '010101-0101',
'010101+0101': '010101+0101',
'010101A0101': '010101A0101',
}
invalid = {
'101010-0102': error_invalid,
'10a010-0101': error_invalid,
'101010-0\xe401': error_invalid,
'101010b0101': error_invalid,
}
self.assertFieldOutput(FISocialSecurityNumber, valid, invalid)

View File

@ -1,152 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.localflavor.fr.forms import (FRZipCodeField,
FRPhoneNumberField, FRDepartmentSelect)
from django.test import SimpleTestCase
class FRLocalFlavorTests(SimpleTestCase):
def test_FRZipCodeField(self):
error_format = ['Enter a zip code in the format XXXXX.']
valid = {
'75001': '75001',
'93200': '93200',
}
invalid = {
'2A200': error_format,
'980001': ['Ensure this value has at most 5 characters (it has 6).'
] + error_format,
}
self.assertFieldOutput(FRZipCodeField, valid, invalid)
def test_FRPhoneNumberField(self):
error_format = ['Phone numbers must be in 0X XX XX XX XX format.']
valid = {
'01 55 44 58 64': '01 55 44 58 64',
'0155445864': '01 55 44 58 64',
'01 5544 5864': '01 55 44 58 64',
'01 55.44.58.64': '01 55 44 58 64',
'01.55.44.58.64': '01 55 44 58 64',
}
invalid = {
'01,55,44,58,64': error_format,
'555 015 544': error_format,
}
self.assertFieldOutput(FRPhoneNumberField, valid, invalid)
def test_FRDepartmentSelect(self):
f = FRDepartmentSelect()
out = '''<select name="dep">
<option value="01">01 - Ain</option>
<option value="02">02 - Aisne</option>
<option value="03">03 - Allier</option>
<option value="04">04 - Alpes-de-Haute-Provence</option>
<option value="05">05 - Hautes-Alpes</option>
<option value="06">06 - Alpes-Maritimes</option>
<option value="07">07 - Ardèche</option>
<option value="08">08 - Ardennes</option>
<option value="09">09 - Ariège</option>
<option value="10">10 - Aube</option>
<option value="11">11 - Aude</option>
<option value="12">12 - Aveyron</option>
<option value="13">13 - Bouches-du-Rhône</option>
<option value="14">14 - Calvados</option>
<option value="15">15 - Cantal</option>
<option value="16">16 - Charente</option>
<option value="17">17 - Charente-Maritime</option>
<option value="18">18 - Cher</option>
<option value="19">19 - Corrèze</option>
<option value="2A">2A - Corse-du-Sud</option>
<option value="2B">2B - Haute-Corse</option>
<option value="21">21 - Côte-d&#39;Or</option>
<option value="22">22 - Côtes-d&#39;Armor</option>
<option value="23">23 - Creuse</option>
<option value="24">24 - Dordogne</option>
<option value="25">25 - Doubs</option>
<option value="26">26 - Drôme</option>
<option value="27">27 - Eure</option>
<option value="28">28 - Eure-et-Loir</option>
<option value="29">29 - Finistère</option>
<option value="30">30 - Gard</option>
<option value="31">31 - Haute-Garonne</option>
<option value="32">32 - Gers</option>
<option value="33">33 - Gironde</option>
<option value="34">34 - Hérault</option>
<option value="35">35 - Ille-et-Vilaine</option>
<option value="36">36 - Indre</option>
<option value="37">37 - Indre-et-Loire</option>
<option value="38">38 - Isère</option>
<option value="39">39 - Jura</option>
<option value="40">40 - Landes</option>
<option value="41">41 - Loir-et-Cher</option>
<option value="42">42 - Loire</option>
<option value="43">43 - Haute-Loire</option>
<option value="44">44 - Loire-Atlantique</option>
<option value="45">45 - Loiret</option>
<option value="46">46 - Lot</option>
<option value="47">47 - Lot-et-Garonne</option>
<option value="48">48 - Lozère</option>
<option value="49">49 - Maine-et-Loire</option>
<option value="50">50 - Manche</option>
<option value="51">51 - Marne</option>
<option value="52">52 - Haute-Marne</option>
<option value="53">53 - Mayenne</option>
<option value="54">54 - Meurthe-et-Moselle</option>
<option value="55">55 - Meuse</option>
<option value="56">56 - Morbihan</option>
<option value="57">57 - Moselle</option>
<option value="58">58 - Nièvre</option>
<option value="59">59 - Nord</option>
<option value="60">60 - Oise</option>
<option value="61">61 - Orne</option>
<option value="62">62 - Pas-de-Calais</option>
<option value="63">63 - Puy-de-Dôme</option>
<option value="64">64 - Pyrénées-Atlantiques</option>
<option value="65">65 - Hautes-Pyrénées</option>
<option value="66">66 - Pyrénées-Orientales</option>
<option value="67">67 - Bas-Rhin</option>
<option value="68">68 - Haut-Rhin</option>
<option value="69">69 - Rhône</option>
<option value="70">70 - Haute-Saône</option>
<option value="71">71 - Saône-et-Loire</option>
<option value="72">72 - Sarthe</option>
<option value="73">73 - Savoie</option>
<option value="74">74 - Haute-Savoie</option>
<option value="75" selected="selected">75 - Paris</option>
<option value="76">76 - Seine-Maritime</option>
<option value="77">77 - Seine-et-Marne</option>
<option value="78">78 - Yvelines</option>
<option value="79">79 - Deux-Sèvres</option>
<option value="80">80 - Somme</option>
<option value="81">81 - Tarn</option>
<option value="82">82 - Tarn-et-Garonne</option>
<option value="83">83 - Var</option>
<option value="84">84 - Vaucluse</option>
<option value="85">85 - Vendée</option>
<option value="86">86 - Vienne</option>
<option value="87">87 - Haute-Vienne</option>
<option value="88">88 - Vosges</option>
<option value="89">89 - Yonne</option>
<option value="90">90 - Territoire de Belfort</option>
<option value="91">91 - Essonne</option>
<option value="92">92 - Hauts-de-Seine</option>
<option value="93">93 - Seine-Saint-Denis</option>
<option value="94">94 - Val-de-Marne</option>
<option value="95">95 - Val-d&#39;Oise</option>
<option value="971">971 - Guadeloupe</option>
<option value="972">972 - Martinique</option>
<option value="973">973 - Guyane</option>
<option value="974">974 - La Réunion</option>
<option value="975">975 - Saint-Pierre-et-Miquelon</option>
<option value="976">976 - Mayotte</option>
<option value="977">977 - Saint-Barthélemy</option>
<option value="978">978 - Saint-Martin</option>
<option value="984">984 - Terres australes et antarctiques françaises</option>
<option value="986">986 - Wallis et Futuna</option>
<option value="987">987 - Polynésie française</option>
<option value="988">988 - Nouvelle-Calédonie</option>
<option value="989">989 - Île de Clipperton</option>
</select>'''
self.assertHTMLEqual(f.render('dep', '75'), out)

View File

@ -1,32 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.gb.forms import GBPostcodeField
from django.test import SimpleTestCase
class GBLocalFlavorTests(SimpleTestCase):
def test_GBPostcodeField(self):
error_invalid = ['Enter a valid postcode.']
valid = {
'BT32 4PX': 'BT32 4PX',
'GIR 0AA': 'GIR 0AA',
'BT324PX': 'BT32 4PX',
' so11aa ': 'SO1 1AA',
' so1 1aa ': 'SO1 1AA',
'G2 3wt': 'G2 3WT',
'EC1A 1BB': 'EC1A 1BB',
'Ec1a1BB': 'EC1A 1BB',
}
invalid = {
'1NV 4L1D': error_invalid,
'1NV4L1D': error_invalid,
' b0gUS': error_invalid,
}
self.assertFieldOutput(GBPostcodeField, valid, invalid)
valid = {}
invalid = {
'1NV 4L1D': ['Enter a bloody postcode!'],
}
kwargs = {'error_messages': {'invalid': 'Enter a bloody postcode!'}}
self.assertFieldOutput(GBPostcodeField, valid, invalid, field_kwargs=kwargs)

View File

@ -1,11 +0,0 @@
from __future__ import absolute_import
from django.forms import ModelForm
from .models import HKPlace
class HKPlaceForm(ModelForm):
class Meta:
model = HKPlace

View File

@ -1,35 +0,0 @@
from __future__ import absolute_import
from django.contrib.localflavor.hk.forms import HKPhoneNumberField
from django.test import SimpleTestCase
class HKLocalFlavorTests(SimpleTestCase):
"""Tests for Hong Kong Local Flavors"""
def test_HKPhoneNumberField(self):
error_msgs = HKPhoneNumberField.default_error_messages
valid = {
'2111-1111': '2111-1111',
'3111 1111': '3111-1111',
'51111111': '5111-1111',
'852-6111-1111': '6111-1111',
'(+852) 8111-1111': '8111-1111',
'(+852) 9111-1111': '9111-1111',
'85291111111': '9111-1111',
}
invalid = {
'9991-1111': [error_msgs['disguise'], ],
'9921-1111': [error_msgs['disguise'], ],
'1121-1111': [error_msgs['disguise'], ],
'99987654': [error_msgs['disguise'], ],
'99287654': [error_msgs['disguise'], ],
'11287654': [error_msgs['disguise'], ],
'1': [error_msgs['invalid'], ],
'2111--1111': [error_msgs['invalid'], ],
'11111111': [error_msgs['prefix'], ],
'00000000': [error_msgs['prefix'], ],
'44444444': [error_msgs['prefix'], ],
'77777777': [error_msgs['prefix'], ],
}
self.assertFieldOutput(HKPhoneNumberField, valid, invalid)

View File

@ -1,192 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.localflavor.hr.forms import (HRCountySelect,
HRPhoneNumberPrefixSelect, HRLicensePlatePrefixSelect, HRPhoneNumberField,
HRLicensePlateField, HRPostalCodeField, HROIBField, HRJMBGField,
HRJMBAGField)
from django.test import SimpleTestCase
class HRLocalFlavorTests(SimpleTestCase):
def test_HRCountySelect(self):
f = HRCountySelect()
out = '''<select name="county">
<option value="GZG" selected="selected">Grad Zagreb</option>
<option value="BBŽ">Bjelovarsko-bilogorska županija</option>
<option value="BPŽ">Brodsko-posavska županija</option>
<option value="DNŽ">Dubrovačko-neretvanska županija</option>
<option value="">Istarska županija</option>
<option value="">Karlovačka županija</option>
<option value="KKŽ">Koprivničko-križevačka županija</option>
<option value="KZŽ">Krapinsko-zagorska županija</option>
<option value="LSŽ">Ličko-senjska županija</option>
<option value="">Međimurska županija</option>
<option value="OBŽ">Osječko-baranjska županija</option>
<option value="PSŽ">Požeško-slavonska županija</option>
<option value="PGŽ">Primorsko-goranska županija</option>
<option value="SMŽ">Sisačko-moslavačka županija</option>
<option value="SDŽ">Splitsko-dalmatinska županija</option>
<option value="ŠKŽ">Šibensko-kninska županija</option>
<option value="">Varaždinska županija</option>
<option value="VPŽ">Virovitičko-podravska županija</option>
<option value="VSŽ">Vukovarsko-srijemska županija</option>
<option value="ZDŽ">Zadarska županija</option>
<option value="ZGŽ">Zagrebačka županija</option>
</select>'''
self.assertHTMLEqual(f.render('county', 'GZG'), out)
def test_HRPhoneNumberPrefixSelect(self):
f = HRPhoneNumberPrefixSelect()
out = '''<select name="phone">
<option value="1" selected="selected">01</option>
<option value="20">020</option>
<option value="21">021</option>
<option value="22">022</option>
<option value="23">023</option>
<option value="31">031</option>
<option value="32">032</option>
<option value="33">033</option>
<option value="34">034</option>
<option value="35">035</option>
<option value="40">040</option>
<option value="42">042</option>
<option value="43">043</option>
<option value="44">044</option>
<option value="47">047</option>
<option value="48">048</option>
<option value="49">049</option>
<option value="51">051</option>
<option value="52">052</option>
<option value="53">053</option>
<option value="91">091</option>
<option value="92">092</option>
<option value="95">095</option>
<option value="97">097</option>
<option value="98">098</option>
<option value="99">099</option>
</select>'''
self.assertHTMLEqual(f.render('phone', '1'), out)
def test_HRLicensePlatePrefixSelect(self):
f = HRLicensePlatePrefixSelect()
out = '''<select name="license">
<option value="BJ" selected="selected">BJ</option>
<option value="BM">BM</option>
<option value="ČK">ČK</option>
<option value="DA">DA</option>
<option value="DE">DE</option>
<option value="DJ">DJ</option>
<option value="DU">DU</option>
<option value="GS">GS</option>
<option value="IM">IM</option>
<option value="KA">KA</option>
<option value="KC">KC</option>
<option value="KR">KR</option>
<option value="KT">KT</option>
<option value=""></option>
<option value="MA">MA</option>
<option value="NA">NA</option>
<option value="NG">NG</option>
<option value="OG">OG</option>
<option value="OS">OS</option>
<option value="PU">PU</option>
<option value=""></option>
<option value="RI">RI</option>
<option value="SB">SB</option>
<option value="SK">SK</option>
<option value="SL">SL</option>
<option value="ST">ST</option>
<option value="ŠI">ŠI</option>
<option value="VK">VK</option>
<option value="VT">VT</option>
<option value="VU">VU</option>
<option value=""></option>
<option value="ZD">ZD</option>
<option value="ZG">ZG</option>
<option value="ŽU">ŽU</option>
</select>'''
self.assertHTMLEqual(f.render('license', 'BJ'), out)
def test_HRPhoneNumberField(self):
error_invalid = ['Enter a valid phone number']
error_area = ['Enter a valid area or mobile network code']
error_number = ['The phone nubmer is too long']
valid = {
'+38511234567': '+38511234567',
'0038511234567': '+38511234567',
'011234567': '+38511234567',
'+38521123456': '+38521123456',
'0038521123456': '+38521123456',
'021123456': '+38521123456',
}
invalid = {
'123456789': error_invalid,
'0811234567': error_area,
'0111234567': error_number,
}
self.assertFieldOutput(HRPhoneNumberField, valid, invalid)
def test_HRLicensePlateField(self):
error_invalid = ['Enter a valid vehicle license plate number']
error_area = ['Enter a valid location code']
error_number = ['Number part cannot be zero']
valid = {
'ZG 1234-AA': 'ZG 1234-AA',
'ZG 123-A': 'ZG 123-A',
}
invalid = {
'PV12345': error_invalid,
'PV1234AA': error_area,
'ZG0000CC': error_number,
}
self.assertFieldOutput(HRLicensePlateField, valid, invalid)
def test_HRPostalCodeField(self):
error_invalid = ['Enter a valid 5 digit postal code']
valid = {
'10000': '10000',
'35410': '35410',
}
invalid = {
'ABCD': error_invalid,
'99999': error_invalid,
}
self.assertFieldOutput(HRPostalCodeField, valid, invalid)
def test_HROIBField(self):
error_invalid = ['Enter a valid 11 digit OIB']
valid = {
'12345678901': '12345678901',
}
invalid = {
'1234567890': ['Ensure this value has at least 11 characters (it has 10).'] + error_invalid,
'ABCDEFGHIJK': error_invalid,
}
self.assertFieldOutput(HROIBField, valid, invalid)
def test_HRJMBGField(self):
error_invalid = ['Enter a valid 13 digit JMBG']
error_date = ['Error in date segment']
valid = {
'1211984302155': '1211984302155',
'2701984307107': '2701984307107',
}
invalid = {
'1211984302156': error_invalid,
'ABCDEFG': error_invalid,
'9999999123456': error_date,
}
self.assertFieldOutput(HRJMBGField, valid, invalid)
def test_HRJMBAGField(self):
error_invalid = ['Enter a valid 19 digit JMBAG starting with 601983']
error_copy = ['Card issue number cannot be zero']
valid = {
'601983 11 0130185856 4': '6019831101301858564',
}
invalid = {
'601983 11 0130185856 5': error_invalid,
'601983 01 0130185856 4': error_copy,
}
self.assertFieldOutput(HRJMBAGField, valid, invalid)

View File

@ -1,195 +0,0 @@
from __future__ import unicode_literals
import warnings
from django.contrib.localflavor.id.forms import (IDPhoneNumberField,
IDPostCodeField, IDNationalIdentityNumberField, IDLicensePlateField,
IDProvinceSelect, IDLicensePlatePrefixSelect)
from django.test import SimpleTestCase
class IDLocalFlavorTests(SimpleTestCase):
def setUp(self):
self.save_warnings_state()
warnings.filterwarnings(
"ignore",
category=RuntimeWarning,
module='django.contrib.localflavor.id.id_choices'
)
def tearDown(self):
self.restore_warnings_state()
def test_IDProvinceSelect(self):
f = IDProvinceSelect()
out = '''<select name="provinces">
<option value="ACE">Aceh</option>
<option value="BLI">Bali</option>
<option value="BTN">Banten</option>
<option value="BKL">Bengkulu</option>
<option value="DIY">Yogyakarta</option>
<option value="JKT">Jakarta</option>
<option value="GOR">Gorontalo</option>
<option value="JMB">Jambi</option>
<option value="JBR">Jawa Barat</option>
<option value="JTG">Jawa Tengah</option>
<option value="JTM">Jawa Timur</option>
<option value="KBR">Kalimantan Barat</option>
<option value="KSL">Kalimantan Selatan</option>
<option value="KTG">Kalimantan Tengah</option>
<option value="KTM">Kalimantan Timur</option>
<option value="BBL">Kepulauan Bangka-Belitung</option>
<option value="KRI">Kepulauan Riau</option>
<option value="LPG" selected="selected">Lampung</option>
<option value="MLK">Maluku</option>
<option value="MUT">Maluku Utara</option>
<option value="NTB">Nusa Tenggara Barat</option>
<option value="NTT">Nusa Tenggara Timur</option>
<option value="PPA">Papua</option>
<option value="PPB">Papua Barat</option>
<option value="RIU">Riau</option>
<option value="SLB">Sulawesi Barat</option>
<option value="SLS">Sulawesi Selatan</option>
<option value="SLT">Sulawesi Tengah</option>
<option value="SLR">Sulawesi Tenggara</option>
<option value="SLU">Sulawesi Utara</option>
<option value="SMB">Sumatera Barat</option>
<option value="SMS">Sumatera Selatan</option>
<option value="SMU">Sumatera Utara</option>
</select>'''
self.assertHTMLEqual(f.render('provinces', 'LPG'), out)
def test_IDLicensePlatePrefixSelect(self):
f = IDLicensePlatePrefixSelect()
out = '''<select name="codes">
<option value="A">Banten</option>
<option value="AA">Magelang</option>
<option value="AB">Yogyakarta</option>
<option value="AD">Surakarta - Solo</option>
<option value="AE">Madiun</option>
<option value="AG">Kediri</option>
<option value="B">Jakarta</option>
<option value="BA">Sumatera Barat</option>
<option value="BB">Tapanuli</option>
<option value="BD">Bengkulu</option>
<option value="BE" selected="selected">Lampung</option>
<option value="BG">Sumatera Selatan</option>
<option value="BH">Jambi</option>
<option value="BK">Sumatera Utara</option>
<option value="BL">Nanggroe Aceh Darussalam</option>
<option value="BM">Riau</option>
<option value="BN">Kepulauan Bangka Belitung</option>
<option value="BP">Kepulauan Riau</option>
<option value="CC">Corps Consulate</option>
<option value="CD">Corps Diplomatic</option>
<option value="D">Bandung</option>
<option value="DA">Kalimantan Selatan</option>
<option value="DB">Sulawesi Utara Daratan</option>
<option value="DC">Sulawesi Barat</option>
<option value="DD">Sulawesi Selatan</option>
<option value="DE">Maluku</option>
<option value="DG">Maluku Utara</option>
<option value="DH">NTT - Timor</option>
<option value="DK">Bali</option>
<option value="DL">Sulawesi Utara Kepulauan</option>
<option value="DM">Gorontalo</option>
<option value="DN">Sulawesi Tengah</option>
<option value="DR">NTB - Lombok</option>
<option value="DS">Papua dan Papua Barat</option>
<option value="DT">Sulawesi Tenggara</option>
<option value="E">Cirebon</option>
<option value="EA">NTB - Sumbawa</option>
<option value="EB">NTT - Flores</option>
<option value="ED">NTT - Sumba</option>
<option value="F">Bogor</option>
<option value="G">Pekalongan</option>
<option value="H">Semarang</option>
<option value="K">Pati</option>
<option value="KB">Kalimantan Barat</option>
<option value="KH">Kalimantan Tengah</option>
<option value="KT">Kalimantan Timur</option>
<option value="L">Surabaya</option>
<option value="M">Madura</option>
<option value="N">Malang</option>
<option value="P">Jember</option>
<option value="R">Banyumas</option>
<option value="RI">Federal Government</option>
<option value="S">Bojonegoro</option>
<option value="T">Purwakarta</option>
<option value="W">Sidoarjo</option>
<option value="Z">Garut</option>
</select>'''
self.assertHTMLEqual(f.render('codes', 'BE'), out)
def test_IDPhoneNumberField(self):
error_invalid = ['Enter a valid phone number']
valid = {
'0812-3456789': '0812-3456789',
'081234567890': '081234567890',
'021 345 6789': '021 345 6789',
'0213456789': '0213456789',
'+62-21-3456789': '+62-21-3456789',
'(021) 345 6789': '(021) 345 6789',
}
invalid = {
'0123456789': error_invalid,
'+62-021-3456789': error_invalid,
'+62-0812-3456789': error_invalid,
'0812345678901': error_invalid,
'foo': error_invalid,
}
self.assertFieldOutput(IDPhoneNumberField, valid, invalid)
def test_IDPostCodeField(self):
error_invalid = ['Enter a valid post code']
valid = {
'12340': '12340',
'25412': '25412',
' 12340 ': '12340',
}
invalid = {
'12 3 4 0': error_invalid,
'12345': error_invalid,
'10100': error_invalid,
'123456': error_invalid,
'foo': error_invalid,
}
self.assertFieldOutput(IDPostCodeField, valid, invalid)
def test_IDNationalIdentityNumberField(self):
error_invalid = ['Enter a valid NIK/KTP number']
valid = {
' 12.3456.010178 3456 ': '12.3456.010178.3456',
'1234560101783456': '12.3456.010178.3456',
'12.3456.010101.3456': '12.3456.010101.3456',
}
invalid = {
'12.3456.310278.3456': error_invalid,
'00.0000.010101.0000': error_invalid,
'1234567890123456': error_invalid,
'foo': error_invalid,
}
self.assertFieldOutput(IDNationalIdentityNumberField, valid, invalid)
def test_IDLicensePlateField(self):
error_invalid = ['Enter a valid vehicle license plate number']
valid = {
' b 1234 ab ': 'B 1234 AB',
'B 1234 ABC': 'B 1234 ABC',
'A 12': 'A 12',
'DK 12345 12': 'DK 12345 12',
'RI 10': 'RI 10',
'CD 12 12': 'CD 12 12',
}
invalid = {
'CD 10 12': error_invalid,
'CD 1234 12': error_invalid,
'RI 10 AB': error_invalid,
'B 12345 01': error_invalid,
'N 1234 12': error_invalid,
'A 12 XYZ': error_invalid,
'Q 1234 AB': error_invalid,
'foo': error_invalid,
}
self.assertFieldOutput(IDLicensePlateField, valid, invalid)

View File

@ -1,45 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.ie.forms import IECountySelect
from django.test import SimpleTestCase
class IELocalFlavorTests(SimpleTestCase):
def test_IECountySelect(self):
f = IECountySelect()
out = '''<select name="counties">
<option value="antrim">Antrim</option>
<option value="armagh">Armagh</option>
<option value="carlow">Carlow</option>
<option value="cavan">Cavan</option>
<option value="clare">Clare</option>
<option value="cork">Cork</option>
<option value="derry">Derry</option>
<option value="donegal">Donegal</option>
<option value="down">Down</option>
<option value="dublin" selected="selected">Dublin</option>
<option value="fermanagh">Fermanagh</option>
<option value="galway">Galway</option>
<option value="kerry">Kerry</option>
<option value="kildare">Kildare</option>
<option value="kilkenny">Kilkenny</option>
<option value="laois">Laois</option>
<option value="leitrim">Leitrim</option>
<option value="limerick">Limerick</option>
<option value="longford">Longford</option>
<option value="louth">Louth</option>
<option value="mayo">Mayo</option>
<option value="meath">Meath</option>
<option value="monaghan">Monaghan</option>
<option value="offaly">Offaly</option>
<option value="roscommon">Roscommon</option>
<option value="sligo">Sligo</option>
<option value="tipperary">Tipperary</option>
<option value="tyrone">Tyrone</option>
<option value="waterford">Waterford</option>
<option value="westmeath">Westmeath</option>
<option value="wexford">Wexford</option>
<option value="wicklow">Wicklow</option>
</select>'''
self.assertHTMLEqual(f.render('counties', 'dublin'), out)

View File

@ -1,41 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.il.forms import (ILPostalCodeField,
ILIDNumberField)
from django.test import SimpleTestCase
class ILLocalFlavorTests(SimpleTestCase):
def test_ILPostalCodeField(self):
error_format = ['Enter a postal code in the format XXXXX']
valid = {
'69973': '69973',
'699 73': '69973',
'12345': '12345',
}
invalid = {
'84545x': error_format,
'123456': error_format,
'1234': error_format,
'123 4': error_format,
}
self.assertFieldOutput(ILPostalCodeField, valid, invalid)
def test_ILIDNumberField(self):
error_invalid = ['Enter a valid ID number.']
valid = {
'3933742-3': '39337423',
'39337423': '39337423',
'039337423': '039337423',
'03933742-3': '039337423',
'0091': '0091',
}
invalid = {
'123456789': error_invalid,
'12345678-9': error_invalid,
'012346578': error_invalid,
'012346578-': error_invalid,
'0001': error_invalid,
}
self.assertFieldOutput(ILIDNumberField, valid, invalid)

View File

@ -1,178 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.in_.forms import (INZipCodeField,
INStateField, INStateSelect, INPhoneNumberField)
from django.test import SimpleTestCase
class INLocalFlavorTests(SimpleTestCase):
def test_INPhoneNumberField(self):
error_format = ['Phone numbers must be in 02X-8X or 03X-7X or 04X-6X format.']
valid = {
'0423-2443667': '0423-2443667',
'0423 2443667': '0423 2443667',
'04236-244366': '04236-244366',
'040-24436678': '040-24436678',
}
invalid = {
'04-2443667': error_format,
'423-2443667': error_format,
'0423-9442667': error_format,
'0423-0443667': error_format,
'0423-244366': error_format,
'04232442667': error_format,
'0423DJANGO': error_format,
}
self.assertFieldOutput(INPhoneNumberField, valid, invalid)
def test_INPStateSelect(self):
f = INStateSelect()
out = '''<select name="state">
<option value="KA">Karnataka</option>
<option value="AP" selected="selected">Andhra Pradesh</option>
<option value="KL">Kerala</option>
<option value="TN">Tamil Nadu</option>
<option value="MH">Maharashtra</option>
<option value="UP">Uttar Pradesh</option>
<option value="GA">Goa</option>
<option value="GJ">Gujarat</option>
<option value="RJ">Rajasthan</option>
<option value="HP">Himachal Pradesh</option>
<option value="JK">Jammu and Kashmir</option>
<option value="AR">Arunachal Pradesh</option>
<option value="AS">Assam</option>
<option value="BR">Bihar</option>
<option value="CG">Chattisgarh</option>
<option value="HR">Haryana</option>
<option value="JH">Jharkhand</option>
<option value="MP">Madhya Pradesh</option>
<option value="MN">Manipur</option>
<option value="ML">Meghalaya</option>
<option value="MZ">Mizoram</option>
<option value="NL">Nagaland</option>
<option value="OR">Orissa</option>
<option value="PB">Punjab</option>
<option value="SK">Sikkim</option>
<option value="TR">Tripura</option>
<option value="UA">Uttarakhand</option>
<option value="WB">West Bengal</option>
<option value="AN">Andaman and Nicobar</option>
<option value="CH">Chandigarh</option>
<option value="DN">Dadra and Nagar Haveli</option>
<option value="DD">Daman and Diu</option>
<option value="DL">Delhi</option>
<option value="LD">Lakshadweep</option>
<option value="PY">Pondicherry</option>
</select>'''
self.assertHTMLEqual(f.render('state', 'AP'), out)
def test_INZipCodeField(self):
error_format = ['Enter a zip code in the format XXXXXX or XXX XXX.']
valid = {
'360311': '360311',
'360 311': '360311',
}
invalid = {
'36 0311': error_format,
'3603111': error_format,
'360 31': error_format,
'36031': error_format,
'O2B 2R3': error_format
}
self.assertFieldOutput(INZipCodeField, valid, invalid)
def test_INStateField(self):
error_format = ['Enter an Indian state or territory.']
valid = {
'an': 'AN',
'AN': 'AN',
'andaman and nicobar': 'AN',
'andra pradesh': 'AP',
'andrapradesh': 'AP',
'andhrapradesh': 'AP',
'ap': 'AP',
'andhra pradesh': 'AP',
'ar': 'AR',
'arunachal pradesh': 'AR',
'assam': 'AS',
'as': 'AS',
'bihar': 'BR',
'br': 'BR',
'cg': 'CG',
'chattisgarh': 'CG',
'ch': 'CH',
'chandigarh': 'CH',
'daman and diu': 'DD',
'dd': 'DD',
'dl': 'DL',
'delhi': 'DL',
'dn': 'DN',
'dadra and nagar haveli': 'DN',
'ga': 'GA',
'goa': 'GA',
'gj': 'GJ',
'gujarat': 'GJ',
'himachal pradesh': 'HP',
'hp': 'HP',
'hr': 'HR',
'haryana': 'HR',
'jharkhand': 'JH',
'jh': 'JH',
'jammu and kashmir': 'JK',
'jk': 'JK',
'karnataka': 'KA',
'karnatka': 'KA',
'ka': 'KA',
'kerala': 'KL',
'kl': 'KL',
'ld': 'LD',
'lakshadweep': 'LD',
'maharastra': 'MH',
'mh': 'MH',
'maharashtra': 'MH',
'meghalaya': 'ML',
'ml': 'ML',
'mn': 'MN',
'manipur': 'MN',
'madhya pradesh': 'MP',
'mp': 'MP',
'mizoram': 'MZ',
'mizo': 'MZ',
'mz': 'MZ',
'nl': 'NL',
'nagaland': 'NL',
'orissa': 'OR',
'odisa': 'OR',
'orisa': 'OR',
'or': 'OR',
'pb': 'PB',
'punjab': 'PB',
'py': 'PY',
'pondicherry': 'PY',
'rajasthan': 'RJ',
'rajastan': 'RJ',
'rj': 'RJ',
'sikkim': 'SK',
'sk': 'SK',
'tamil nadu': 'TN',
'tn': 'TN',
'tamilnadu': 'TN',
'tamilnad': 'TN',
'tr': 'TR',
'tripura': 'TR',
'ua': 'UA',
'uttarakhand': 'UA',
'up': 'UP',
'uttar pradesh': 'UP',
'westbengal': 'WB',
'bengal': 'WB',
'wb': 'WB',
'west bengal': 'WB'
}
invalid = {
'florida': error_format,
'FL': error_format,
}
self.assertFieldOutput(INStateField, valid, invalid)

View File

@ -1,200 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.is_.forms import (ISIdNumberField,
ISPhoneNumberField, ISPostalCodeSelect)
from django.test import SimpleTestCase
class ISLocalFlavorTests(SimpleTestCase):
def test_ISPostalCodeSelect(self):
f = ISPostalCodeSelect()
out = '''<select name="foo">
<option value="101">101 Reykjav\xedk</option>
<option value="103">103 Reykjav\xedk</option>
<option value="104">104 Reykjav\xedk</option>
<option value="105">105 Reykjav\xedk</option>
<option value="107">107 Reykjav\xedk</option>
<option value="108">108 Reykjav\xedk</option>
<option value="109">109 Reykjav\xedk</option>
<option value="110">110 Reykjav\xedk</option>
<option value="111">111 Reykjav\xedk</option>
<option value="112">112 Reykjav\xedk</option>
<option value="113">113 Reykjav\xedk</option>
<option value="116">116 Kjalarnes</option>
<option value="121">121 Reykjav\xedk</option>
<option value="123">123 Reykjav\xedk</option>
<option value="124">124 Reykjav\xedk</option>
<option value="125">125 Reykjav\xedk</option>
<option value="127">127 Reykjav\xedk</option>
<option value="128">128 Reykjav\xedk</option>
<option value="129">129 Reykjav\xedk</option>
<option value="130">130 Reykjav\xedk</option>
<option value="132">132 Reykjav\xedk</option>
<option value="150">150 Reykjav\xedk</option>
<option value="155">155 Reykjav\xedk</option>
<option value="170">170 Seltjarnarnes</option>
<option value="172">172 Seltjarnarnes</option>
<option value="190">190 Vogar</option>
<option value="200">200 K\xf3pavogur</option>
<option value="201">201 K\xf3pavogur</option>
<option value="202">202 K\xf3pavogur</option>
<option value="203">203 K\xf3pavogur</option>
<option value="210">210 Gar\xf0ab\xe6r</option>
<option value="212">212 Gar\xf0ab\xe6r</option>
<option value="220">220 Hafnarfj\xf6r\xf0ur</option>
<option value="221">221 Hafnarfj\xf6r\xf0ur</option>
<option value="222">222 Hafnarfj\xf6r\xf0ur</option>
<option value="225">225 \xc1lftanes</option>
<option value="230">230 Reykjanesb\xe6r</option>
<option value="232">232 Reykjanesb\xe6r</option>
<option value="233">233 Reykjanesb\xe6r</option>
<option value="235">235 Keflav\xedkurflugv\xf6llur</option>
<option value="240">240 Grindav\xedk</option>
<option value="245">245 Sandger\xf0i</option>
<option value="250">250 Gar\xf0ur</option>
<option value="260">260 Reykjanesb\xe6r</option>
<option value="270">270 Mosfellsb\xe6r</option>
<option value="300">300 Akranes</option>
<option value="301">301 Akranes</option>
<option value="302">302 Akranes</option>
<option value="310">310 Borgarnes</option>
<option value="311">311 Borgarnes</option>
<option value="320">320 Reykholt \xed Borgarfir\xf0i</option>
<option value="340">340 Stykkish\xf3lmur</option>
<option value="345">345 Flatey \xe1 Brei\xf0afir\xf0i</option>
<option value="350">350 Grundarfj\xf6r\xf0ur</option>
<option value="355">355 \xd3lafsv\xedk</option>
<option value="356">356 Sn\xe6fellsb\xe6r</option>
<option value="360">360 Hellissandur</option>
<option value="370">370 B\xfa\xf0ardalur</option>
<option value="371">371 B\xfa\xf0ardalur</option>
<option value="380">380 Reykh\xf3lahreppur</option>
<option value="400">400 \xcdsafj\xf6r\xf0ur</option>
<option value="401">401 \xcdsafj\xf6r\xf0ur</option>
<option value="410">410 Hn\xedfsdalur</option>
<option value="415">415 Bolungarv\xedk</option>
<option value="420">420 S\xfa\xf0av\xedk</option>
<option value="425">425 Flateyri</option>
<option value="430">430 Su\xf0ureyri</option>
<option value="450">450 Patreksfj\xf6r\xf0ur</option>
<option value="451">451 Patreksfj\xf6r\xf0ur</option>
<option value="460">460 T\xe1lknafj\xf6r\xf0ur</option>
<option value="465">465 B\xedldudalur</option>
<option value="470">470 \xdeingeyri</option>
<option value="471">471 \xdeingeyri</option>
<option value="500">500 Sta\xf0ur</option>
<option value="510">510 H\xf3lmav\xedk</option>
<option value="512">512 H\xf3lmav\xedk</option>
<option value="520">520 Drangsnes</option>
<option value="522">522 Kj\xf6rvogur</option>
<option value="523">523 B\xe6r</option>
<option value="524">524 Nor\xf0urfj\xf6r\xf0ur</option>
<option value="530">530 Hvammstangi</option>
<option value="531">531 Hvammstangi</option>
<option value="540">540 Bl\xf6ndu\xf3s</option>
<option value="541">541 Bl\xf6ndu\xf3s</option>
<option value="545">545 Skagastr\xf6nd</option>
<option value="550">550 Sau\xf0\xe1rkr\xf3kur</option>
<option value="551">551 Sau\xf0\xe1rkr\xf3kur</option>
<option value="560">560 Varmahl\xed\xf0</option>
<option value="565">565 Hofs\xf3s</option>
<option value="566">566 Hofs\xf3s</option>
<option value="570">570 Flj\xf3t</option>
<option value="580">580 Siglufj\xf6r\xf0ur</option>
<option value="600">600 Akureyri</option>
<option value="601">601 Akureyri</option>
<option value="602">602 Akureyri</option>
<option value="603">603 Akureyri</option>
<option value="610">610 Greniv\xedk</option>
<option value="611">611 Gr\xedmsey</option>
<option value="620">620 Dalv\xedk</option>
<option value="621">621 Dalv\xedk</option>
<option value="625">625 \xd3lafsfj\xf6r\xf0ur</option>
<option value="630">630 Hr\xedsey</option>
<option value="640">640 H\xfasav\xedk</option>
<option value="641">641 H\xfasav\xedk</option>
<option value="645">645 Fossh\xf3ll</option>
<option value="650">650 Laugar</option>
<option value="660">660 M\xfdvatn</option>
<option value="670">670 K\xf3pasker</option>
<option value="671">671 K\xf3pasker</option>
<option value="675">675 Raufarh\xf6fn</option>
<option value="680">680 \xde\xf3rsh\xf6fn</option>
<option value="681">681 \xde\xf3rsh\xf6fn</option>
<option value="685">685 Bakkafj\xf6r\xf0ur</option>
<option value="690">690 Vopnafj\xf6r\xf0ur</option>
<option value="700">700 Egilssta\xf0ir</option>
<option value="701">701 Egilssta\xf0ir</option>
<option value="710">710 Sey\xf0isfj\xf6r\xf0ur</option>
<option value="715">715 Mj\xf3ifj\xf6r\xf0ur</option>
<option value="720">720 Borgarfj\xf6r\xf0ur eystri</option>
<option value="730">730 Rey\xf0arfj\xf6r\xf0ur</option>
<option value="735">735 Eskifj\xf6r\xf0ur</option>
<option value="740">740 Neskaupsta\xf0ur</option>
<option value="750">750 F\xe1skr\xfa\xf0sfj\xf6r\xf0ur</option>
<option value="755">755 St\xf6\xf0varfj\xf6r\xf0ur</option>
<option value="760">760 Brei\xf0dalsv\xedk</option>
<option value="765">765 Dj\xfapivogur</option>
<option value="780">780 H\xf6fn \xed Hornafir\xf0i</option>
<option value="781">781 H\xf6fn \xed Hornafir\xf0i</option>
<option value="785">785 \xd6r\xe6fi</option>
<option value="800">800 Selfoss</option>
<option value="801">801 Selfoss</option>
<option value="802">802 Selfoss</option>
<option value="810">810 Hverager\xf0i</option>
<option value="815">815 \xdeorl\xe1ksh\xf6fn</option>
<option value="820">820 Eyrarbakki</option>
<option value="825">825 Stokkseyri</option>
<option value="840">840 Laugarvatn</option>
<option value="845">845 Fl\xfa\xf0ir</option>
<option value="850">850 Hella</option>
<option value="851">851 Hella</option>
<option value="860">860 Hvolsv\xf6llur</option>
<option value="861">861 Hvolsv\xf6llur</option>
<option value="870">870 V\xedk</option>
<option value="871">871 V\xedk</option>
<option value="880">880 Kirkjub\xe6jarklaustur</option>
<option value="900">900 Vestmannaeyjar</option>
<option value="902">902 Vestmannaeyjar</option>
</select>'''
self.assertHTMLEqual(f.render('foo', 'bar'), out)
def test_ISIdNumberField(self):
error_atleast = ['Ensure this value has at least 10 characters (it has 9).']
error_invalid = ['Enter a valid Icelandic identification number. The format is XXXXXX-XXXX.']
error_atmost = ['Ensure this value has at most 11 characters (it has 12).']
error_notvalid = ['The Icelandic identification number is not valid.']
valid = {
'2308803449': '230880-3449',
'230880-3449': '230880-3449',
'230880 3449': '230880-3449',
'2308803440': '230880-3440',
}
invalid = {
'230880343': error_atleast + error_invalid,
'230880343234': error_atmost + error_invalid,
'abcdefghijk': error_invalid,
'2308803439': error_notvalid,
}
self.assertFieldOutput(ISIdNumberField, valid, invalid)
def test_ISPhoneNumberField(self):
error_invalid = ['Enter a valid value.']
error_atleast = ['Ensure this value has at least 7 characters (it has 6).']
error_atmost = ['Ensure this value has at most 8 characters (it has 9).']
valid = {
'1234567': '1234567',
'123 4567': '1234567',
'123-4567': '1234567',
}
invalid = {
'123-456': error_invalid,
'123456': error_atleast + error_invalid,
'123456555': error_atmost + error_invalid,
'abcdefg': error_invalid,
' 1234567 ': error_atmost + error_invalid,
' 12367 ': error_invalid
}
self.assertFieldOutput(ISPhoneNumberField, valid, invalid)

View File

@ -1,71 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.it.forms import (ITZipCodeField, ITRegionSelect,
ITSocialSecurityNumberField, ITVatNumberField)
from django.test import SimpleTestCase
class ITLocalFlavorTests(SimpleTestCase):
def test_ITRegionSelect(self):
f = ITRegionSelect()
out = '''<select name="regions">
<option value="ABR">Abruzzo</option>
<option value="BAS">Basilicata</option>
<option value="CAL">Calabria</option>
<option value="CAM">Campania</option>
<option value="EMR">Emilia-Romagna</option>
<option value="FVG">Friuli-Venezia Giulia</option>
<option value="LAZ">Lazio</option>
<option value="LIG">Liguria</option>
<option value="LOM">Lombardia</option>
<option value="MAR">Marche</option>
<option value="MOL">Molise</option>
<option value="PMN" selected="selected">Piemonte</option>
<option value="PUG">Puglia</option>
<option value="SAR">Sardegna</option>
<option value="SIC">Sicilia</option>
<option value="TOS">Toscana</option>
<option value="TAA">Trentino-Alto Adige</option>
<option value="UMB">Umbria</option>
<option value="VAO">Valle d\u2019Aosta</option>
<option value="VEN">Veneto</option>
</select>'''
self.assertHTMLEqual(f.render('regions', 'PMN'), out)
def test_ITZipCodeField(self):
error_invalid = ['Enter a valid zip code.']
valid = {
'00100': '00100',
}
invalid = {
' 00100': error_invalid,
}
self.assertFieldOutput(ITZipCodeField, valid, invalid)
def test_ITSocialSecurityNumberField(self):
error_invalid = ['Enter a valid Social Security number.']
valid = {
'LVSGDU99T71H501L': 'LVSGDU99T71H501L',
'LBRRME11A01L736W': 'LBRRME11A01L736W',
'lbrrme11a01l736w': 'LBRRME11A01L736W',
'LBR RME 11A01 L736W': 'LBRRME11A01L736W',
}
invalid = {
'LBRRME11A01L736A': error_invalid,
'%BRRME11A01L736W': error_invalid,
}
self.assertFieldOutput(ITSocialSecurityNumberField, valid, invalid)
def test_ITVatNumberField(self):
error_invalid = ['Enter a valid VAT number.']
valid = {
'07973780013': '07973780013',
'7973780013': '07973780013',
7973780013: '07973780013',
}
invalid = {
'07973780014': error_invalid,
'A7973780013': error_invalid,
}
self.assertFieldOutput(ITVatNumberField, valid, invalid)

View File

@ -1,75 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.jp.forms import (JPPostalCodeField,
JPPrefectureSelect)
from django.test import SimpleTestCase
class JPLocalFlavorTests(SimpleTestCase):
def test_JPPrefectureSelect(self):
f = JPPrefectureSelect()
out = '''<select name="prefecture">
<option value="hokkaido">Hokkaido</option>
<option value="aomori">Aomori</option>
<option value="iwate">Iwate</option>
<option value="miyagi">Miyagi</option>
<option value="akita">Akita</option>
<option value="yamagata">Yamagata</option>
<option value="fukushima">Fukushima</option>
<option value="ibaraki">Ibaraki</option>
<option value="tochigi">Tochigi</option>
<option value="gunma">Gunma</option>
<option value="saitama">Saitama</option>
<option value="chiba">Chiba</option>
<option value="tokyo">Tokyo</option>
<option value="kanagawa" selected="selected">Kanagawa</option>
<option value="yamanashi">Yamanashi</option>
<option value="nagano">Nagano</option>
<option value="niigata">Niigata</option>
<option value="toyama">Toyama</option>
<option value="ishikawa">Ishikawa</option>
<option value="fukui">Fukui</option>
<option value="gifu">Gifu</option>
<option value="shizuoka">Shizuoka</option>
<option value="aichi">Aichi</option>
<option value="mie">Mie</option>
<option value="shiga">Shiga</option>
<option value="kyoto">Kyoto</option>
<option value="osaka">Osaka</option>
<option value="hyogo">Hyogo</option>
<option value="nara">Nara</option>
<option value="wakayama">Wakayama</option>
<option value="tottori">Tottori</option>
<option value="shimane">Shimane</option>
<option value="okayama">Okayama</option>
<option value="hiroshima">Hiroshima</option>
<option value="yamaguchi">Yamaguchi</option>
<option value="tokushima">Tokushima</option>
<option value="kagawa">Kagawa</option>
<option value="ehime">Ehime</option>
<option value="kochi">Kochi</option>
<option value="fukuoka">Fukuoka</option>
<option value="saga">Saga</option>
<option value="nagasaki">Nagasaki</option>
<option value="kumamoto">Kumamoto</option>
<option value="oita">Oita</option>
<option value="miyazaki">Miyazaki</option>
<option value="kagoshima">Kagoshima</option>
<option value="okinawa">Okinawa</option>
</select>'''
self.assertHTMLEqual(f.render('prefecture', 'kanagawa'), out)
def test_JPPostalCodeField(self):
error_format = ['Enter a postal code in the format XXXXXXX or XXX-XXXX.']
valid = {
'251-0032': '2510032',
'2510032': '2510032',
}
invalid = {
'2510-032': error_format,
'251a0032': error_format,
'a51-0032': error_format,
'25100321': error_format,
}
self.assertFieldOutput(JPPostalCodeField, valid, invalid)

View File

@ -1,17 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.kw.forms import KWCivilIDNumberField
from django.test import SimpleTestCase
class KWLocalFlavorTests(SimpleTestCase):
def test_KWCivilIDNumberField(self):
error_invalid = ['Enter a valid Kuwaiti Civil ID number']
valid = {
'282040701483': '282040701483',
}
invalid = {
'289332013455': error_invalid,
}
self.assertFieldOutput(KWCivilIDNumberField, valid, invalid)

View File

@ -1,11 +0,0 @@
from __future__ import absolute_import
from django.forms import ModelForm
from .models import MKPerson
class MKPersonForm(ModelForm):
class Meta:
model = MKPerson

View File

@ -1,15 +0,0 @@
from django.contrib.localflavor.mk.models import (
MKIdentityCardNumberField, MKMunicipalityField, UMCNField)
from django.db import models
class MKPerson(models.Model):
first_name = models.CharField(max_length = 20)
last_name = models.CharField(max_length = 20)
umcn = UMCNField()
id_number = MKIdentityCardNumberField()
municipality = MKMunicipalityField(blank = True)
municipality_req = MKMunicipalityField(blank = False)
class Meta:
app_label = 'localflavor'

View File

@ -1,308 +0,0 @@
# -*- encoding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.contrib.localflavor.mk.forms import (
MKIdentityCardNumberField, MKMunicipalitySelect, UMCNField)
from django.test import SimpleTestCase
from .forms import MKPersonForm
class MKLocalFlavorTests(SimpleTestCase):
def setUp(self):
self.form = MKPersonForm({
'first_name':'Someone',
'last_name':'Something',
'umcn': '2402983450006',
'municipality':'OD',
'municipality_req':'VE',
'id_number':'A1234567',
})
def test_get_display_methods(self):
"""
Test that the get_*_display() methods are added to the model instances.
"""
person = self.form.save()
self.assertEqual(person.get_municipality_display(), 'Ohrid')
self.assertEqual(person.get_municipality_req_display(), 'Veles')
def test_municipality_required(self):
"""
Test that required MKMunicipalityFields throw appropriate errors.
"""
form = MKPersonForm({
'first_name':'Someone',
'last_name':'Something',
'umcn': '2402983450006',
'municipality':'OD',
'id_number':'A1234567',
})
self.assertFalse(form.is_valid())
self.assertEqual(
form.errors['municipality_req'], ['This field is required.'])
def test_umcn_invalid(self):
"""
Test that UMCNFields throw appropriate errors for invalid UMCNs.
"""
form = MKPersonForm({
'first_name':'Someone',
'last_name':'Something',
'umcn': '2402983450007',
'municipality':'OD',
'municipality_req':'VE',
'id_number':'A1234567',
})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors['umcn'], ['The UMCN is not valid.'])
form = MKPersonForm({
'first_name':'Someone',
'last_name':'Something',
'umcn': '3002983450007',
'municipality':'OD',
'municipality_req':'VE',
'id_number':'A1234567',
})
self.assertEqual(form.errors['umcn'],
['The first 7 digits of the UMCN must represent a valid past date.'])
def test_idnumber_invalid(self):
"""
Test that MKIdentityCardNumberFields throw
appropriate errors for invalid values
"""
form = MKPersonForm({
'first_name':'Someone',
'last_name':'Something',
'umcn': '2402983450007',
'municipality':'OD',
'municipality_req':'VE',
'id_number':'A123456a',
})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors['id_number'],
['Identity card numbers must contain either 4 to 7 '
'digits or an uppercase letter and 7 digits.'])
def test_field_blank_option(self):
"""
Test that the empty option is there.
"""
municipality_select_html = """\
<select name="municipality" id="id_municipality">
<option value="">---------</option>
<option value="AD">Aerodrom</option>
<option value="AR">Aračinovo</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čani</option>
<option value="VE">Veles</option>
<option value="NI">Vinica</option>
<option value="VC">Vraneštica</option>
<option value="VH">Vrapčište</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">Delčevo</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če Petrov</option>
<option value="ZE">Želino</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š</option>
<option value="VD">Kisela Voda</option>
<option value="KH">Kičevo</option>
<option value="KN">Konče</option>
<option value="OC">Koćani</option>
<option value="KY">Kratovo</option>
<option value="KZ">Kriva Palanka</option>
<option value="KG">Krivogaštani</option>
<option value="KS">Kruševo</option>
<option value="UM">Kumanovo</option>
<option value="LI">Lipkovo</option>
<option value="LO">Lozovo</option>
<option value="MR">Mavrovo i Rostuša</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" selected="selected">Ohrid</option>
<option value="PE">Petrovec</option>
<option value="PH">Pehčevo</option>
<option value="PN">Plasnica</option>
<option value="PP">Prilep</option>
<option value="PT">Probištip</option>
<option value="RV">Radoviš</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šte</option>
<option value="SD">Star Dojran</option>
<option value="NA">Staro Nagoričane</option>
<option value="UG">Struga</option>
<option value="RU">Strumica</option>
<option value="SU">Studeničani</option>
<option value="TR">Tearce</option>
<option value="ET">Tetovo</option>
<option value="CE">Centar</option>
<option value="CZ">Centar-Župa</option>
<option value="CI">Čair</option>
<option value="CA">Čaška</option>
<option value="CH">Češinovo-Obleševo</option>
<option value="CS">Čučer-Sandevo</option>
<option value="ST">Štip</option>
<option value="SO">Šuto Orizari</option>
</select>"""
self.assertHTMLEqual(str(self.form['municipality']), municipality_select_html)
def test_MKIdentityCardNumberField(self):
error_invalid = ['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='''<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.assertHTMLEqual(f.render('municipality', 'DL' ), out)
def test_UMCNField(self):
error_invalid = ['This field should contain exactly 13 digits.']
error_checksum = ['The UMCN is not valid.']
error_date = ['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 File

@ -1,11 +0,0 @@
from __future__ import absolute_import
from django.forms import ModelForm
from .models import MXPersonProfile
class MXPersonProfileForm(ModelForm):
class Meta:
model = MXPersonProfile

View File

@ -1,13 +0,0 @@
from django.contrib.localflavor.mx.models import (
MXStateField, MXRFCField, MXCURPField, MXZipCodeField)
from django.db import models
class MXPersonProfile(models.Model):
state = MXStateField()
rfc = MXRFCField()
curp = MXCURPField()
zip_code = MXZipCodeField()
class Meta:
app_label = 'localflavor'

View File

@ -1,198 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from django.contrib.localflavor.mx.forms import (MXZipCodeField, MXRFCField,
MXStateSelect, MXCURPField)
from django.test import SimpleTestCase
from .forms import MXPersonProfileForm
class MXLocalFlavorTests(SimpleTestCase):
def setUp(self):
self.form = MXPersonProfileForm({
'state': 'MIC',
'rfc': 'toma880125kv3',
'curp': 'toma880125hmnrrn02',
'zip_code': '58120',
})
def test_get_display_methods(self):
"""Test that the get_*_display() methods are added to the model instances."""
place = self.form.save()
self.assertEqual(place.get_state_display(), 'Michoacán')
def test_errors(self):
"""Test that required MXFields throw appropriate errors."""
form = MXPersonProfileForm({
'state': 'Invalid state',
'rfc': 'invalid rfc',
'curp': 'invalid curp',
'zip_code': 'xxx',
})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors['state'], ['Select a valid choice. Invalid state is not one of the available choices.'])
self.assertEqual(form.errors['rfc'], ['Enter a valid RFC.'])
self.assertEqual(form.errors['curp'], ['Ensure this value has at least 18 characters (it has 12).', 'Enter a valid CURP.'])
self.assertEqual(form.errors['zip_code'], ['Enter a valid zip code in the format XXXXX.'])
def test_field_blank_option(self):
"""Test that the empty option is there."""
state_select_html = """\
<select name="state" id="id_state">
<option value="">---------</option>
<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.assertHTMLEqual(str(self.form['state']), state_select_html)
def test_MXStateSelect(self):
f = MXStateSelect()
out = '''<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.assertHTMLEqual(f.render('state', 'MIC'), out)
def test_MXZipCodeField(self):
error_format = ['Enter a valid zip code in the format XXXXX.']
valid = {
'58120': '58120',
'58502': '58502',
'59310': '59310',
'99999': '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 = ['Enter a valid RFC.']
error_checksum = ['Invalid checksum for RFC.']
valid = {
'MoFN641205eX5': 'MOFN641205EX5',
'ICa060120873': 'ICA060120873',
'eUcG751104rT0': 'EUCG751104RT0',
'GME08100195A': 'GME08100195A',
'AA&060524KX5': 'AA&060524KX5',
'CAÑ0708045P7': 'CAÑ0708045P7',
'aaa000101aa9': '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 = ['Enter a valid CURP.']
error_checksum = ['Invalid checksum for CURP.']
valid = {
'AaMG890608HDFLJL00': 'AAMG890608HDFLJL00',
'BAAd890419HMNRRV07': 'BAAD890419HMNRRV07',
'VIAA900930MMNClL08': 'VIAA900930MMNCLL08',
'HEGR891009HMNRRD09': 'HEGR891009HMNRRD09',
'MARR890512HMNRMN09': 'MARR890512HMNRMN09',
'MESJ890928HMNZNS00': 'MESJ890928HMNZNS00',
'BAAA890317HDFRLL03': 'BAAA890317HDFRLL03',
'TOMA880125HMNRRNO2': 'TOMA880125HMNRRNO2',
'OOMG890727HMNRSR06': 'OOMG890727HMNRSR06',
'AAAA000101HDFCCC09': '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 File

@ -1,64 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.nl.forms import (NLPhoneNumberField,
NLZipCodeField, NLSoFiNumberField, NLProvinceSelect)
from django.test import SimpleTestCase
class NLLocalFlavorTests(SimpleTestCase):
def test_NLProvinceSelect(self):
f = NLProvinceSelect()
out = '''<select name="provinces">
<option value="DR">Drenthe</option>
<option value="FL">Flevoland</option>
<option value="FR">Friesland</option>
<option value="GL">Gelderland</option>
<option value="GR">Groningen</option>
<option value="LB">Limburg</option>
<option value="NB">Noord-Brabant</option>
<option value="NH">Noord-Holland</option>
<option value="OV" selected="selected">Overijssel</option>
<option value="UT">Utrecht</option>
<option value="ZE">Zeeland</option>
<option value="ZH">Zuid-Holland</option>
</select>'''
self.assertHTMLEqual(f.render('provinces', 'OV'), out)
def test_NLPhoneNumberField(self):
error_invalid = ['Enter a valid phone number']
valid = {
'012-3456789': '012-3456789',
'0123456789': '0123456789',
'+31-12-3456789': '+31-12-3456789',
'(0123) 456789': '(0123) 456789',
}
invalid = {
'foo': error_invalid,
}
self.assertFieldOutput(NLPhoneNumberField, valid, invalid)
def test_NLZipCodeField(self):
error_invalid = ['Enter a valid postal code']
valid = {
'1234ab': '1234 AB',
'1234 ab': '1234 AB',
'1234 AB': '1234 AB',
}
invalid = {
'0123AB': error_invalid,
'foo': error_invalid,
}
self.assertFieldOutput(NLZipCodeField, valid, invalid)
def test_NLSoFiNumberField(self):
error_invalid = ['Enter a valid SoFi number']
valid = {
'123456782': '123456782',
}
invalid = {
'000000000': error_invalid,
'123456789': error_invalid,
'foo': error_invalid,
}
self.assertFieldOutput(NLSoFiNumberField, valid, invalid)

View File

@ -1,480 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.pl.forms import (PLProvinceSelect,
PLCountySelect, PLPostalCodeField, PLNIPField, PLPESELField, PLNationalIDCardNumberField, PLREGONField)
from django.test import SimpleTestCase
class PLLocalFlavorTests(SimpleTestCase):
def test_PLProvinceSelect(self):
f = PLProvinceSelect()
out = '''<select name="voivodeships">
<option value="lower_silesia">Lower Silesia</option>
<option value="kuyavia-pomerania">Kuyavia-Pomerania</option>
<option value="lublin">Lublin</option>
<option value="lubusz">Lubusz</option>
<option value="lodz">Lodz</option>
<option value="lesser_poland">Lesser Poland</option>
<option value="masovia">Masovia</option>
<option value="opole">Opole</option>
<option value="subcarpatia">Subcarpatia</option>
<option value="podlasie">Podlasie</option>
<option value="pomerania" selected="selected">Pomerania</option>
<option value="silesia">Silesia</option>
<option value="swietokrzyskie">Swietokrzyskie</option>
<option value="warmia-masuria">Warmia-Masuria</option>
<option value="greater_poland">Greater Poland</option>
<option value="west_pomerania">West Pomerania</option>
</select>'''
self.assertHTMLEqual(f.render('voivodeships', 'pomerania'), out)
def test_PLCountrySelect(self):
f = PLCountySelect()
out = '''<select name="administrativeunit">
<option value="wroclaw">Wroc\u0142aw</option>
<option value="jeleniagora">Jelenia G\xf3ra</option>
<option value="legnica">Legnica</option>
<option value="boleslawiecki">boles\u0142awiecki</option>
<option value="dzierzoniowski">dzier\u017coniowski</option>
<option value="glogowski">g\u0142ogowski</option>
<option value="gorowski">g\xf3rowski</option>
<option value="jaworski">jaworski</option>
<option value="jeleniogorski">jeleniog\xf3rski</option>
<option value="kamiennogorski">kamiennog\xf3rski</option>
<option value="klodzki">k\u0142odzki</option>
<option value="legnicki">legnicki</option>
<option value="lubanski">luba\u0144ski</option>
<option value="lubinski">lubi\u0144ski</option>
<option value="lwowecki">lw\xf3wecki</option>
<option value="milicki">milicki</option>
<option value="olesnicki">ole\u015bnicki</option>
<option value="olawski">o\u0142awski</option>
<option value="polkowicki">polkowicki</option>
<option value="strzelinski">strzeli\u0144ski</option>
<option value="sredzki">\u015bredzki</option>
<option value="swidnicki">\u015bwidnicki</option>
<option value="trzebnicki">trzebnicki</option>
<option value="walbrzyski">wa\u0142brzyski</option>
<option value="wolowski">wo\u0142owski</option>
<option value="wroclawski">wroc\u0142awski</option>
<option value="zabkowicki">z\u0105bkowicki</option>
<option value="zgorzelecki">zgorzelecki</option>
<option value="zlotoryjski">z\u0142otoryjski</option>
<option value="bydgoszcz">Bydgoszcz</option>
<option value="torun">Toru\u0144</option>
<option value="wloclawek">W\u0142oc\u0142awek</option>
<option value="grudziadz">Grudzi\u0105dz</option>
<option value="aleksandrowski">aleksandrowski</option>
<option value="brodnicki">brodnicki</option>
<option value="bydgoski">bydgoski</option>
<option value="chelminski">che\u0142mi\u0144ski</option>
<option value="golubsko-dobrzynski">golubsko-dobrzy\u0144ski</option>
<option value="grudziadzki">grudzi\u0105dzki</option>
<option value="inowroclawski">inowroc\u0142awski</option>
<option value="lipnowski">lipnowski</option>
<option value="mogilenski">mogile\u0144ski</option>
<option value="nakielski">nakielski</option>
<option value="radziejowski">radziejowski</option>
<option value="rypinski">rypi\u0144ski</option>
<option value="sepolenski">s\u0119pole\u0144ski</option>
<option value="swiecki">\u015bwiecki</option>
<option value="torunski">toru\u0144ski</option>
<option value="tucholski">tucholski</option>
<option value="wabrzeski">w\u0105brzeski</option>
<option value="wloclawski">wroc\u0142awski</option>
<option value="zninski">\u017ani\u0144ski</option>
<option value="lublin">Lublin</option>
<option value="biala-podlaska">Bia\u0142a Podlaska</option>
<option value="chelm">Che\u0142m</option>
<option value="zamosc">Zamo\u015b\u0107</option>
<option value="bialski">bialski</option>
<option value="bilgorajski">bi\u0142gorajski</option>
<option value="chelmski">che\u0142mski</option>
<option value="hrubieszowski">hrubieszowski</option>
<option value="janowski">janowski</option>
<option value="krasnostawski">krasnostawski</option>
<option value="krasnicki">kra\u015bnicki</option>
<option value="lubartowski">lubartowski</option>
<option value="lubelski">lubelski</option>
<option value="leczynski">\u0142\u0119czy\u0144ski</option>
<option value="lukowski">\u0142ukowski</option>
<option value="opolski">opolski</option>
<option value="parczewski">parczewski</option>
<option value="pulawski">pu\u0142awski</option>
<option value="radzynski">radzy\u0144ski</option>
<option value="rycki">rycki</option>
<option value="swidnicki">\u015bwidnicki</option>
<option value="tomaszowski">tomaszowski</option>
<option value="wlodawski">w\u0142odawski</option>
<option value="zamojski">zamojski</option>
<option value="gorzow-wielkopolski">Gorz\xf3w Wielkopolski</option>
<option value="zielona-gora">Zielona G\xf3ra</option>
<option value="gorzowski">gorzowski</option>
<option value="krosnienski">kro\u015bnie\u0144ski</option>
<option value="miedzyrzecki">mi\u0119dzyrzecki</option>
<option value="nowosolski">nowosolski</option>
<option value="slubicki">s\u0142ubicki</option>
<option value="strzelecko-drezdenecki">strzelecko-drezdenecki</option>
<option value="sulecinski">sule\u0144ci\u0144ski</option>
<option value="swiebodzinski">\u015bwiebodzi\u0144ski</option>
<option value="wschowski">wschowski</option>
<option value="zielonogorski">zielonog\xf3rski</option>
<option value="zaganski">\u017caga\u0144ski</option>
<option value="zarski">\u017carski</option>
<option value="lodz">\u0141\xf3d\u017a</option>
<option value="piotrkow-trybunalski">Piotrk\xf3w Trybunalski</option>
<option value="skierniewice">Skierniewice</option>
<option value="belchatowski">be\u0142chatowski</option>
<option value="brzezinski">brzezi\u0144ski</option>
<option value="kutnowski">kutnowski</option>
<option value="laski">\u0142aski</option>
<option value="leczycki">\u0142\u0119czycki</option>
<option value="lowicki">\u0142owicki</option>
<option value="lodzki wschodni">\u0142\xf3dzki wschodni</option>
<option value="opoczynski">opoczy\u0144ski</option>
<option value="pabianicki">pabianicki</option>
<option value="pajeczanski">paj\u0119cza\u0144ski</option>
<option value="piotrkowski">piotrkowski</option>
<option value="poddebicki">podd\u0119bicki</option>
<option value="radomszczanski">radomszcza\u0144ski</option>
<option value="rawski">rawski</option>
<option value="sieradzki">sieradzki</option>
<option value="skierniewicki">skierniewicki</option>
<option value="tomaszowski">tomaszowski</option>
<option value="wielunski">wielu\u0144ski</option>
<option value="wieruszowski">wieruszowski</option>
<option value="zdunskowolski">zdu\u0144skowolski</option>
<option value="zgierski">zgierski</option>
<option value="krakow">Krak\xf3w</option>
<option value="tarnow">Tarn\xf3w</option>
<option value="nowy-sacz">Nowy S\u0105cz</option>
<option value="bochenski">boche\u0144ski</option>
<option value="brzeski">brzeski</option>
<option value="chrzanowski">chrzanowski</option>
<option value="dabrowski">d\u0105browski</option>
<option value="gorlicki">gorlicki</option>
<option value="krakowski">krakowski</option>
<option value="limanowski">limanowski</option>
<option value="miechowski">miechowski</option>
<option value="myslenicki">my\u015blenicki</option>
<option value="nowosadecki">nowos\u0105decki</option>
<option value="nowotarski">nowotarski</option>
<option value="olkuski">olkuski</option>
<option value="oswiecimski">o\u015bwi\u0119cimski</option>
<option value="proszowicki">proszowicki</option>
<option value="suski">suski</option>
<option value="tarnowski">tarnowski</option>
<option value="tatrzanski">tatrza\u0144ski</option>
<option value="wadowicki">wadowicki</option>
<option value="wielicki">wielicki</option>
<option value="warszawa">Warszawa</option>
<option value="ostroleka">Ostro\u0142\u0119ka</option>
<option value="plock">P\u0142ock</option>
<option value="radom">Radom</option>
<option value="siedlce">Siedlce</option>
<option value="bialobrzeski">bia\u0142obrzeski</option>
<option value="ciechanowski">ciechanowski</option>
<option value="garwolinski">garwoli\u0144ski</option>
<option value="gostyninski">gostyni\u0144ski</option>
<option value="grodziski">grodziski</option>
<option value="grojecki">gr\xf3jecki</option>
<option value="kozienicki">kozenicki</option>
<option value="legionowski">legionowski</option>
<option value="lipski">lipski</option>
<option value="losicki">\u0142osicki</option>
<option value="makowski">makowski</option>
<option value="minski">mi\u0144ski</option>
<option value="mlawski">m\u0142awski</option>
<option value="nowodworski">nowodworski</option>
<option value="ostrolecki">ostro\u0142\u0119cki</option>
<option value="ostrowski">ostrowski</option>
<option value="otwocki">otwocki</option>
<option value="piaseczynski">piaseczy\u0144ski</option>
<option value="plocki">p\u0142ocki</option>
<option value="plonski">p\u0142o\u0144ski</option>
<option value="pruszkowski">pruszkowski</option>
<option value="przasnyski">przasnyski</option>
<option value="przysuski">przysuski</option>
<option value="pultuski">pu\u0142tuski</option>
<option value="radomski">radomski</option>
<option value="siedlecki">siedlecki</option>
<option value="sierpecki">sierpecki</option>
<option value="sochaczewski">sochaczewski</option>
<option value="sokolowski">soko\u0142owski</option>
<option value="szydlowiecki">szyd\u0142owiecki</option>
<option value="warszawski-zachodni">warszawski zachodni</option>
<option value="wegrowski">w\u0119growski</option>
<option value="wolominski">wo\u0142omi\u0144ski</option>
<option value="wyszkowski">wyszkowski</option>
<option value="zwolenski">zwole\u0144ski</option>
<option value="zurominski">\u017curomi\u0144ski</option>
<option value="zyrardowski">\u017cyrardowski</option>
<option value="opole">Opole</option>
<option value="brzeski">brzeski</option>
<option value="glubczycki">g\u0142ubczyski</option>
<option value="kedzierzynsko-kozielski">k\u0119dzierzy\u0144ski-kozielski</option>
<option value="kluczborski">kluczborski</option>
<option value="krapkowicki">krapkowicki</option>
<option value="namyslowski">namys\u0142owski</option>
<option value="nyski">nyski</option>
<option value="oleski">oleski</option>
<option value="opolski">opolski</option>
<option value="prudnicki">prudnicki</option>
<option value="strzelecki">strzelecki</option>
<option value="rzeszow">Rzesz\xf3w</option>
<option value="krosno">Krosno</option>
<option value="przemysl">Przemy\u015bl</option>
<option value="tarnobrzeg">Tarnobrzeg</option>
<option value="bieszczadzki">bieszczadzki</option>
<option value="brzozowski">brzozowski</option>
<option value="debicki">d\u0119bicki</option>
<option value="jaroslawski">jaros\u0142awski</option>
<option value="jasielski">jasielski</option>
<option value="kolbuszowski">kolbuszowski</option>
<option value="krosnienski">kro\u015bnie\u0144ski</option>
<option value="leski">leski</option>
<option value="lezajski">le\u017cajski</option>
<option value="lubaczowski">lubaczowski</option>
<option value="lancucki">\u0142a\u0144cucki</option>
<option value="mielecki">mielecki</option>
<option value="nizanski">ni\u017ca\u0144ski</option>
<option value="przemyski">przemyski</option>
<option value="przeworski">przeworski</option>
<option value="ropczycko-sedziszowski">ropczycko-s\u0119dziszowski</option>
<option value="rzeszowski">rzeszowski</option>
<option value="sanocki">sanocki</option>
<option value="stalowowolski">stalowowolski</option>
<option value="strzyzowski">strzy\u017cowski</option>
<option value="tarnobrzeski">tarnobrzeski</option>
<option value="bialystok">Bia\u0142ystok</option>
<option value="lomza">\u0141om\u017ca</option>
<option value="suwalki">Suwa\u0142ki</option>
<option value="augustowski">augustowski</option>
<option value="bialostocki">bia\u0142ostocki</option>
<option value="bielski">bielski</option>
<option value="grajewski">grajewski</option>
<option value="hajnowski">hajnowski</option>
<option value="kolnenski">kolne\u0144ski</option>
<option value="\u0142omzynski">\u0142om\u017cy\u0144ski</option>
<option value="moniecki">moniecki</option>
<option value="sejnenski">sejne\u0144ski</option>
<option value="siemiatycki">siematycki</option>
<option value="sokolski">sok\xf3lski</option>
<option value="suwalski">suwalski</option>
<option value="wysokomazowiecki">wysokomazowiecki</option>
<option value="zambrowski">zambrowski</option>
<option value="gdansk">Gda\u0144sk</option>
<option value="gdynia">Gdynia</option>
<option value="slupsk">S\u0142upsk</option>
<option value="sopot">Sopot</option>
<option value="bytowski">bytowski</option>
<option value="chojnicki">chojnicki</option>
<option value="czluchowski">cz\u0142uchowski</option>
<option value="kartuski">kartuski</option>
<option value="koscierski">ko\u015bcierski</option>
<option value="kwidzynski">kwidzy\u0144ski</option>
<option value="leborski">l\u0119borski</option>
<option value="malborski">malborski</option>
<option value="nowodworski">nowodworski</option>
<option value="gdanski">gda\u0144ski</option>
<option value="pucki">pucki</option>
<option value="slupski">s\u0142upski</option>
<option value="starogardzki">starogardzki</option>
<option value="sztumski">sztumski</option>
<option value="tczewski">tczewski</option>
<option value="wejherowski">wejcherowski</option>
<option value="katowice" selected="selected">Katowice</option>
<option value="bielsko-biala">Bielsko-Bia\u0142a</option>
<option value="bytom">Bytom</option>
<option value="chorzow">Chorz\xf3w</option>
<option value="czestochowa">Cz\u0119stochowa</option>
<option value="dabrowa-gornicza">D\u0105browa G\xf3rnicza</option>
<option value="gliwice">Gliwice</option>
<option value="jastrzebie-zdroj">Jastrz\u0119bie Zdr\xf3j</option>
<option value="jaworzno">Jaworzno</option>
<option value="myslowice">Mys\u0142owice</option>
<option value="piekary-slaskie">Piekary \u015al\u0105skie</option>
<option value="ruda-slaska">Ruda \u015al\u0105ska</option>
<option value="rybnik">Rybnik</option>
<option value="siemianowice-slaskie">Siemianowice \u015al\u0105skie</option>
<option value="sosnowiec">Sosnowiec</option>
<option value="swietochlowice">\u015awi\u0119toch\u0142owice</option>
<option value="tychy">Tychy</option>
<option value="zabrze">Zabrze</option>
<option value="zory">\u017bory</option>
<option value="bedzinski">b\u0119dzi\u0144ski</option>
<option value="bielski">bielski</option>
<option value="bierunsko-ledzinski">bieru\u0144sko-l\u0119dzi\u0144ski</option>
<option value="cieszynski">cieszy\u0144ski</option>
<option value="czestochowski">cz\u0119stochowski</option>
<option value="gliwicki">gliwicki</option>
<option value="klobucki">k\u0142obucki</option>
<option value="lubliniecki">lubliniecki</option>
<option value="mikolowski">miko\u0142owski</option>
<option value="myszkowski">myszkowski</option>
<option value="pszczynski">pszczy\u0144ski</option>
<option value="raciborski">raciborski</option>
<option value="rybnicki">rybnicki</option>
<option value="tarnogorski">tarnog\xf3rski</option>
<option value="wodzislawski">wodzis\u0142awski</option>
<option value="zawiercianski">zawiercia\u0144ski</option>
<option value="zywiecki">\u017cywiecki</option>
<option value="kielce">Kielce</option>
<option value="buski">buski</option>
<option value="jedrzejowski">j\u0119drzejowski</option>
<option value="kazimierski">kazimierski</option>
<option value="kielecki">kielecki</option>
<option value="konecki">konecki</option>
<option value="opatowski">opatowski</option>
<option value="ostrowiecki">ostrowiecki</option>
<option value="pinczowski">pi\u0144czowski</option>
<option value="sandomierski">sandomierski</option>
<option value="skarzyski">skar\u017cyski</option>
<option value="starachowicki">starachowicki</option>
<option value="staszowski">staszowski</option>
<option value="wloszczowski">w\u0142oszczowski</option>
<option value="olsztyn">Olsztyn</option>
<option value="elblag">Elbl\u0105g</option>
<option value="bartoszycki">bartoszycki</option>
<option value="braniewski">braniewski</option>
<option value="dzialdowski">dzia\u0142dowski</option>
<option value="elblaski">elbl\u0105ski</option>
<option value="elcki">e\u0142cki</option>
<option value="gizycki">gi\u017cycki</option>
<option value="goldapski">go\u0142dapski</option>
<option value="ilawski">i\u0142awski</option>
<option value="ketrzynski">k\u0119trzy\u0144ski</option>
<option value="lidzbarski">lidzbarski</option>
<option value="mragowski">mr\u0105gowski</option>
<option value="nidzicki">nidzicki</option>
<option value="nowomiejski">nowomiejski</option>
<option value="olecki">olecki</option>
<option value="olsztynski">olszty\u0144ski</option>
<option value="ostrodzki">ostr\xf3dzki</option>
<option value="piski">piski</option>
<option value="szczycienski">szczycie\u0144ski</option>
<option value="wegorzewski">w\u0119gorzewski</option>
<option value="poznan">Pozna\u0144</option>
<option value="kalisz">Kalisz</option>
<option value="konin">Konin</option>
<option value="leszno">Leszno</option>
<option value="chodzieski">chodziejski</option>
<option value="czarnkowsko-trzcianecki">czarnkowsko-trzcianecki</option>
<option value="gnieznienski">gnie\u017anie\u0144ski</option>
<option value="gostynski">gosty\u0144ski</option>
<option value="grodziski">grodziski</option>
<option value="jarocinski">jaroci\u0144ski</option>
<option value="kaliski">kaliski</option>
<option value="kepinski">k\u0119pi\u0144ski</option>
<option value="kolski">kolski</option>
<option value="koninski">koni\u0144ski</option>
<option value="koscianski">ko\u015bcia\u0144ski</option>
<option value="krotoszynski">krotoszy\u0144ski</option>
<option value="leszczynski">leszczy\u0144ski</option>
<option value="miedzychodzki">mi\u0119dzychodzki</option>
<option value="nowotomyski">nowotomyski</option>
<option value="obornicki">obornicki</option>
<option value="ostrowski">ostrowski</option>
<option value="ostrzeszowski">ostrzeszowski</option>
<option value="pilski">pilski</option>
<option value="pleszewski">pleszewski</option>
<option value="poznanski">pozna\u0144ski</option>
<option value="rawicki">rawicki</option>
<option value="slupecki">s\u0142upecki</option>
<option value="szamotulski">szamotulski</option>
<option value="sredzki">\u015bredzki</option>
<option value="sremski">\u015bremski</option>
<option value="turecki">turecki</option>
<option value="wagrowiecki">w\u0105growiecki</option>
<option value="wolsztynski">wolszty\u0144ski</option>
<option value="wrzesinski">wrzesi\u0144ski</option>
<option value="zlotowski">z\u0142otowski</option>
<option value="bialogardzki">bia\u0142ogardzki</option>
<option value="choszczenski">choszcze\u0144ski</option>
<option value="drawski">drawski</option>
<option value="goleniowski">goleniowski</option>
<option value="gryficki">gryficki</option>
<option value="gryfinski">gryfi\u0144ski</option>
<option value="kamienski">kamie\u0144ski</option>
<option value="kolobrzeski">ko\u0142obrzeski</option>
<option value="koszalinski">koszali\u0144ski</option>
<option value="lobeski">\u0142obeski</option>
<option value="mysliborski">my\u015bliborski</option>
<option value="policki">policki</option>
<option value="pyrzycki">pyrzycki</option>
<option value="slawienski">s\u0142awie\u0144ski</option>
<option value="stargardzki">stargardzki</option>
<option value="szczecinecki">szczecinecki</option>
<option value="swidwinski">\u015bwidwi\u0144ski</option>
<option value="walecki">wa\u0142ecki</option>
</select>'''
self.assertHTMLEqual(f.render('administrativeunit', 'katowice'), out)
def test_PLPostalCodeField(self):
error_format = ['Enter a postal code in the format XX-XXX.']
valid = {
'41-403': '41-403',
}
invalid = {
'43--434': error_format,
}
self.assertFieldOutput(PLPostalCodeField, valid, invalid)
def test_PLNIPField(self):
error_format = ['Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.']
error_checksum = ['Wrong checksum for the Tax Number (NIP).']
valid = {
'646-241-41-24': '6462414124',
'646-24-14-124': '6462414124',
'6462414124': '6462414124',
}
invalid = {
'43-343-234-323': error_format,
'64-62-414-124': error_format,
'646-241-41-23': error_checksum,
}
self.assertFieldOutput(PLNIPField, valid, invalid)
def test_PLPESELField(self):
error_checksum = ['Wrong checksum for the National Identification Number.']
error_format = ['National Identification Number consists of 11 digits.']
valid = {
'80071610614': '80071610614',
}
invalid = {
'80071610610': error_checksum,
'80': error_format,
'800716106AA': error_format,
}
self.assertFieldOutput(PLPESELField, valid, invalid)
def test_PLNationalIDCardNumberField(self):
error_checksum = ['Wrong checksum for the National ID Card Number.']
error_format = ['National ID Card Number consists of 3 letters and 6 digits.']
valid = {
'ABC123458': 'ABC123458',
'abc123458': 'ABC123458',
}
invalid = {
'ABC123457': error_checksum,
'abc123457': error_checksum,
'a12Aaaaaa': error_format,
'AA1234443': error_format,
}
self.assertFieldOutput(PLNationalIDCardNumberField, valid, invalid)
def test_PLREGONField(self):
error_checksum = ['Wrong checksum for the National Business Register Number (REGON).']
error_format = ['National Business Register Number (REGON) consists of 9 or 14 digits.']
valid = {
'12345678512347': '12345678512347',
'590096454': '590096454',
}
invalid = {
'123456784': error_checksum,
'12345678412342': error_checksum,
'590096453': error_checksum,
'590096': error_format,
}
self.assertFieldOutput(PLREGONField, valid, invalid)

View File

@ -1,33 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.pt.forms import PTZipCodeField, PTPhoneNumberField
from django.test import SimpleTestCase
class PTLocalFlavorTests(SimpleTestCase):
def test_PTZipCodeField(self):
error_format = ['Enter a zip code in the format XXXX-XXX.']
valid = {
'3030-034': '3030-034',
'1003456': '1003-456',
}
invalid = {
'2A200': error_format,
'980001': error_format,
}
self.assertFieldOutput(PTZipCodeField, valid, invalid)
def test_PTPhoneNumberField(self):
error_format = ['Phone numbers must have 9 digits, or start by + or 00.']
valid = {
'917845189': '917845189',
'91 784 5189': '917845189',
'+351 91 111': '+35191111',
'00351873': '00351873',
}
invalid = {
'91 784 51 8': error_format,
'091 456 987 1': error_format,
}
self.assertFieldOutput(PTPhoneNumberField, valid, invalid)

View File

@ -1,55 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.py.forms import (PyDepartmentSelect,
PyNumberedDepartmentSelect)
from django.test import SimpleTestCase
class PYLocalFlavorTests(SimpleTestCase):
def test_PyDepartmentSelect(self):
py = PyDepartmentSelect()
out = '''<select name="department">
<option value="AG">Alto Paraguay</option>
<option value="AA">Alto Paran\xe1</option>
<option value="AM">Amambay</option>
<option value="AS">Asunci\xf3n</option>
<option value="BQ">Boquer\xf3n</option>
<option value="CG">Caaguaz\xfa</option>
<option value="CZ">Caazap\xe1</option>
<option value="CY">Canindey\xfa</option>
<option value="CE">Central</option>
<option value="CN">Concepci\xf3n</option>
<option value="CR">Cordillera</option>
<option value="GU">Guair\xe1</option>
<option value="IT">Itap\xfaa</option>
<option value="MI">Misiones</option>
<option value="NE">\xd1eembuc\xfa</option>
<option value="PG">Paraguar\xed</option>
<option value="PH">Pdte. Hayes</option>
<option value="SP">San Pedro</option>
</select>'''
self.assertHTMLEqual(py.render('department', 'M'), out)
def test_PyNumberedDepartmentSelect(self):
py = PyNumberedDepartmentSelect()
out = '''<select name="department">
<option value="CN">I Concepci\xf3n</option>
<option value="SP">II San Pedro</option>
<option value="CR">III Cordillera</option>
<option value="GU">IV Guair\xe1</option>
<option value="CG">V Caaguaz\xfa</option>
<option value="CZ">VI Caazap\xe1</option>
<option value="IT">VII Itap\xfaa</option>
<option value="MI">VIII Misiones</option>
<option value="PG">IX Paraguar\xed</option>
<option value="AA">X Alto Paran\xe1</option>
<option value="CE">XI Central</option>
<option value="NE">XII \xd1eembuc\xfa</option>
<option value="AM" selected="selected">XIII Amambay</option>
<option value="CY">XIV Canindey\xfa</option>
<option value="PH">XV Pdte. Hayes</option>
<option value="AG">XVI Alto Paraguay</option>
<option value="BQ">XVII Boquer\xf3n</option>
<option value="AS">XVIII Asunci\xf3n</option>
</select>'''
self.assertHTMLEqual(py.render('department', 'AM'), out)

View File

@ -1,144 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.localflavor.ro.forms import (ROCIFField, ROCNPField,
ROCountyField, ROCountySelect, ROIBANField, ROPhoneNumberField,
ROPostalCodeField)
from django.test import SimpleTestCase
class ROLocalFlavorTests(SimpleTestCase):
def test_ROCountySelect(self):
f = ROCountySelect()
out = '''<select name="county">
<option value="AB">Alba</option>
<option value="AR">Arad</option>
<option value="AG">Arge\u015f</option>
<option value="BC">Bac\u0103u</option>
<option value="BH">Bihor</option>
<option value="BN">Bistri\u0163a-N\u0103s\u0103ud</option>
<option value="BT">Boto\u015fani</option>
<option value="BV">Bra\u015fov</option>
<option value="BR">Br\u0103ila</option>
<option value="B">Bucure\u015fti</option>
<option value="BZ">Buz\u0103u</option>
<option value="CS">Cara\u015f-Severin</option>
<option value="CL">C\u0103l\u0103ra\u015fi</option>
<option value="CJ" selected="selected">Cluj</option>
<option value="CT">Constan\u0163a</option>
<option value="CV">Covasna</option>
<option value="DB">D\xe2mbovi\u0163a</option>
<option value="DJ">Dolj</option>
<option value="GL">Gala\u0163i</option>
<option value="GR">Giurgiu</option>
<option value="GJ">Gorj</option>
<option value="HR">Harghita</option>
<option value="HD">Hunedoara</option>
<option value="IL">Ialomi\u0163a</option>
<option value="IS">Ia\u015fi</option>
<option value="IF">Ilfov</option>
<option value="MM">Maramure\u015f</option>
<option value="MH">Mehedin\u0163i</option>
<option value="MS">Mure\u015f</option>
<option value="NT">Neam\u0163</option>
<option value="OT">Olt</option>
<option value="PH">Prahova</option>
<option value="SM">Satu Mare</option>
<option value="SJ">S\u0103laj</option>
<option value="SB">Sibiu</option>
<option value="SV">Suceava</option>
<option value="TR">Teleorman</option>
<option value="TM">Timi\u015f</option>
<option value="TL">Tulcea</option>
<option value="VS">Vaslui</option>
<option value="VL">V\xe2lcea</option>
<option value="VN">Vrancea</option>
</select>'''
self.assertHTMLEqual(f.render('county', 'CJ'), out)
def test_ROCIFField(self):
error_invalid = ['Enter a valid CIF.']
error_atmost = ['Ensure this value has at most 10 characters (it has 11).']
error_atleast = ['Ensure this value has at least 2 characters (it has 1).']
valid = {
'21694681': '21694681',
'RO21694681': '21694681',
}
invalid = {
'21694680': error_invalid,
'21694680000': error_atmost,
'0': error_atleast + error_invalid,
}
self.assertFieldOutput(ROCIFField, valid, invalid)
def test_ROCNPField(self):
error_invalid = ['Enter a valid CNP.']
error_atleast = ['Ensure this value has at least 13 characters (it has 10).']
error_atmost = ['Ensure this value has at most 13 characters (it has 14).']
valid = {
'1981211204489': '1981211204489',
}
invalid = {
'1981211204487': error_invalid,
'1981232204489': error_invalid,
'9981211204489': error_invalid,
'9981211209': error_atleast + error_invalid,
'19812112044891': error_atmost,
}
self.assertFieldOutput(ROCNPField, valid, invalid)
def test_ROCountyField(self):
error_format = ['Enter a Romanian county code or name.']
valid = {
'CJ': 'CJ',
'cj': 'CJ',
'Argeş': 'AG',
'argeş': 'AG',
}
invalid = {
'Arges': error_format,
}
self.assertFieldOutput(ROCountyField, valid, invalid)
def test_ROIBANField(self):
error_invalid = ['Enter a valid IBAN in ROXX-XXXX-XXXX-XXXX-XXXX-XXXX format']
error_atleast = ['Ensure this value has at least 24 characters (it has 23).']
valid = {
'RO56RZBR0000060003291177': 'RO56RZBR0000060003291177',
'RO56-RZBR-0000-0600-0329-1177': 'RO56RZBR0000060003291177',
}
invalid = {
'RO56RZBR0000060003291176': error_invalid,
'AT61 1904 3002 3457 3201': error_invalid,
'RO56RZBR000006000329117': error_atleast + error_invalid,
}
self.assertFieldOutput(ROIBANField, valid, invalid)
def test_ROPhoneNumberField(self):
error_format = ['Phone numbers must be in XXXX-XXXXXX format.']
error_atleast = ['Ensure this value has at least 10 characters (it has 9).']
error_invalid = ['Phone numbers must be in XXXX-XXXXXX format.']
valid = {
'0264485936': '0264485936',
'(0264)-485936': '0264485936',
}
invalid = {
'02644859368': error_format,
'026448593': error_atleast + error_invalid,
}
self.assertFieldOutput(ROPhoneNumberField, valid, invalid)
def test_ROPostalCodeField(self):
error_atleast = ['Ensure this value has at least 6 characters (it has 5).']
error_atmost = ['Ensure this value has at most 6 characters (it has 7).']
error_invalid = ['Enter a valid postal code in the format XXXXXX']
valid = {
'400473': '400473',
}
invalid = {
'40047': error_atleast + error_invalid,
'4004731': error_atmost + error_invalid,
}
self.assertFieldOutput(ROPostalCodeField, valid, invalid)

View File

@ -1,150 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.ru.forms import *
from django.test import SimpleTestCase
class RULocalFlavorTests(SimpleTestCase):
def test_RUPassportNumberField(self):
error = ['Enter a passport number in the format XXXX XXXXXX.']
valid = {
'1981 211204': '1981 211204',
'0305 967876': '0305 967876',
}
invalid = {
'1981 2112044': error,
'1981 23220': error,
'9981211201': error,
}
self.assertFieldOutput(RUPassportNumberField, valid, invalid)
def test_RUAlienPassportNumberField(self):
error = ['Enter a passport number in the format XX XXXXXXX.']
valid = {
'19 8111204': '19 8111204',
'03 0567876': '03 0567876',
}
invalid = {
'198 1112044': error,
'19 81123220': error,
'99 812112': error,
}
self.assertFieldOutput(RUAlienPassportNumberField, valid, invalid)
def test_RUPostalCodeField(self):
error = ['Enter a postal code in the format XXXXXX.']
valid = {
'987654': '987654',
'123456': '123456'
}
invalid = {
'123 34': error,
'1234567': error,
'12345': error
}
self.assertFieldOutput(RUPostalCodeField, valid, invalid)
def test_RUCountySelect(self):
f = RUCountySelect()
out = '''<select name="county">
<option value="Central Federal County">Central Federal County</option>
<option value="South Federal County">South Federal County</option>
<option value="North-West Federal County">North-West Federal County</option>
<option value="Far-East Federal County">Far-East Federal County</option>
<option value="Siberian Federal County">Siberian Federal County</option>
<option value="Ural Federal County">Ural Federal County</option>
<option value="Privolzhsky Federal County">Privolzhsky Federal County</option>
<option value="North-Caucasian Federal County">North-Caucasian Federal County</option>
</select>'''
self.assertHTMLEqual(f.render('county', None), out)
def test_RURegionSelect(self):
f = RURegionSelect()
out = '''<select name="region">
<option value="77">Moskva</option>
<option value="78">Saint-Peterburg</option>
<option value="50">Moskovskaya oblast&#39;</option>
<option value="01">Adygeya, Respublika</option>
<option value="02">Bashkortostan, Respublika</option>
<option value="03">Buryatia, Respublika</option>
<option value="04">Altay, Respublika</option>
<option value="05">Dagestan, Respublika</option>
<option value="06">Ingushskaya Respublika</option>
<option value="07">Kabardino-Balkarskaya Respublika</option>
<option value="08">Kalmykia, Respublika</option>
<option value="09">Karachaevo-Cherkesskaya Respublika</option>
<option value="10">Karelia, Respublika</option>
<option value="11">Komi, Respublika</option>
<option value="12">Mariy Ehl, Respublika</option>
<option value="13">Mordovia, Respublika</option>
<option value="14">Sakha, Respublika (Yakutiya)</option>
<option value="15">Severnaya Osetia, Respublika (Alania)</option>
<option value="16">Tatarstan, Respublika</option>
<option value="17">Tyva, Respublika (Tuva)</option>
<option value="18">Udmurtskaya Respublika</option>
<option value="19">Khakassiya, Respublika</option>
<option value="95">Chechenskaya Respublika</option>
<option value="21">Chuvashskaya Respublika</option>
<option value="22">Altayskiy Kray</option>
<option value="80">Zabaykalskiy Kray</option>
<option value="82">Kamchatskiy Kray</option>
<option value="23">Krasnodarskiy Kray</option>
<option value="24">Krasnoyarskiy Kray</option>
<option value="81">Permskiy Kray</option>
<option value="25">Primorskiy Kray</option>
<option value="26">Stavropol&#39;siyy Kray</option>
<option value="27">Khabarovskiy Kray</option>
<option value="28">Amurskaya oblast&#39;</option>
<option value="29">Arkhangel&#39;skaya oblast&#39;</option>
<option value="30">Astrakhanskaya oblast&#39;</option>
<option value="31">Belgorodskaya oblast&#39;</option>
<option value="32">Bryanskaya oblast&#39;</option>
<option value="33">Vladimirskaya oblast&#39;</option>
<option value="34">Volgogradskaya oblast&#39;</option>
<option value="35">Vologodskaya oblast&#39;</option>
<option value="36">Voronezhskaya oblast&#39;</option>
<option value="37">Ivanovskaya oblast&#39;</option>
<option value="38">Irkutskaya oblast&#39;</option>
<option value="39">Kaliningradskaya oblast&#39;</option>
<option value="40">Kaluzhskaya oblast&#39;</option>
<option value="42">Kemerovskaya oblast&#39;</option>
<option value="43">Kirovskaya oblast&#39;</option>
<option value="44">Kostromskaya oblast&#39;</option>
<option value="45">Kurganskaya oblast&#39;</option>
<option value="46">Kurskaya oblast&#39;</option>
<option value="47">Leningradskaya oblast&#39;</option>
<option value="48">Lipeckaya oblast&#39;</option>
<option value="49">Magadanskaya oblast&#39;</option>
<option value="51">Murmanskaya oblast&#39;</option>
<option value="52">Nizhegorodskaja oblast&#39;</option>
<option value="53">Novgorodskaya oblast&#39;</option>
<option value="54">Novosibirskaya oblast&#39;</option>
<option value="55">Omskaya oblast&#39;</option>
<option value="56">Orenburgskaya oblast&#39;</option>
<option value="57">Orlovskaya oblast&#39;</option>
<option value="58">Penzenskaya oblast&#39;</option>
<option value="60">Pskovskaya oblast&#39;</option>
<option value="61">Rostovskaya oblast&#39;</option>
<option value="62">Rjazanskaya oblast&#39;</option>
<option value="63">Samarskaya oblast&#39;</option>
<option value="64">Saratovskaya oblast&#39;</option>
<option value="65">Sakhalinskaya oblast&#39;</option>
<option value="66">Sverdlovskaya oblast&#39;</option>
<option value="67" selected="selected">Smolenskaya oblast&#39;</option>
<option value="68">Tambovskaya oblast&#39;</option>
<option value="69">Tverskaya oblast&#39;</option>
<option value="70">Tomskaya oblast&#39;</option>
<option value="71">Tul&#39;skaya oblast&#39;</option>
<option value="72">Tyumenskaya oblast&#39;</option>
<option value="73">Ul&#39;ianovskaya oblast&#39;</option>
<option value="74">Chelyabinskaya oblast&#39;</option>
<option value="76">Yaroslavskaya oblast&#39;</option>
<option value="79">Evreyskaya avtonomnaja oblast&#39;</option>
<option value="83">Neneckiy autonomnyy okrug</option>
<option value="86">Khanty-Mansiyskiy avtonomnyy okrug - Yugra</option>
<option value="87">Chukotskiy avtonomnyy okrug</option>
<option value="89">Yamalo-Neneckiy avtonomnyy okrug</option>
</select>'''
self.assertHTMLEqual(f.render('region', '67'), out)

View File

@ -1,166 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib.localflavor.se.forms import (SECountySelect,
SEOrganisationNumberField, SEPersonalIdentityNumberField,
SEPostalCodeField)
import datetime
from django.test import SimpleTestCase
class SELocalFlavorTests(SimpleTestCase):
def setUp(self):
# Mocking datetime.date to make sure
# localflavor.se.utils.validate_id_birthday works
class MockDate(datetime.date):
def today(cls):
return datetime.date(2008, 5, 14)
today = classmethod(today)
self._olddate = datetime.date
datetime.date = MockDate
def tearDown(self):
datetime.date = self._olddate
def test_SECountySelect(self):
f = SECountySelect()
out = '''<select name="swedish_county">
<option value="AB">Stockholm</option>
<option value="AC">V\xe4sterbotten</option>
<option value="BD">Norrbotten</option>
<option value="C">Uppsala</option>
<option value="D">S\xf6dermanland</option>
<option value="E" selected="selected">\xd6sterg\xf6tland</option>
<option value="F">J\xf6nk\xf6ping</option>
<option value="G">Kronoberg</option>
<option value="H">Kalmar</option>
<option value="I">Gotland</option>
<option value="K">Blekinge</option>
<option value="M">Sk\xe5ne</option>
<option value="N">Halland</option>
<option value="O">V\xe4stra G\xf6taland</option>
<option value="S">V\xe4rmland</option>
<option value="T">\xd6rebro</option>
<option value="U">V\xe4stmanland</option>
<option value="W">Dalarna</option>
<option value="X">G\xe4vleborg</option>
<option value="Y">V\xe4sternorrland</option>
<option value="Z">J\xe4mtland</option>
</select>'''
self.assertHTMLEqual(f.render('swedish_county', 'E'), out)
def test_SEOrganizationNumberField(self):
error_invalid = ['Enter a valid Swedish organisation number.']
valid = {
'870512-1989': '198705121989',
'19870512-1989': '198705121989',
'870512-2128': '198705122128',
'081015-6315': '190810156315',
'081015+6315': '180810156315',
'0810156315': '190810156315',
# Test some different organisation numbers
# IKEA Linköping
'556074-7569': '5560747569',
# Volvo Personvagnar
'556074-3089': '5560743089',
# LJS (organisation)
'822001-5476': '8220015476',
# LJS (organisation)
'8220015476': '8220015476',
# Katedralskolan Linköping (school)
'2120000449': '2120000449',
# Faux organisation number, which tests that the checksum can be 0
'232518-5060': '2325185060',
}
invalid = {
# Ordinary personal identity numbers for sole proprietors
# The same rules as for SEPersonalIdentityField applies here
'081015 6315': error_invalid,
'950231-4496': error_invalid,
'6914104499': error_invalid,
'950d314496': error_invalid,
'invalid!!!': error_invalid,
'870514-1111': error_invalid,
# Co-ordination number checking
# Co-ordination numbers are not valid organisation numbers
'870574-1315': error_invalid,
'870573-1311': error_invalid,
# Volvo Personvagnar, bad format
'556074+3089': error_invalid,
# Invalid checksum
'2120000441': error_invalid,
# Valid checksum but invalid organisation type
'1120000441': error_invalid,
}
self.assertFieldOutput(SEOrganisationNumberField, valid, invalid)
def test_SEPersonalIdentityNumberField(self):
error_invalid = ['Enter a valid Swedish personal identity number.']
error_coord = ['Co-ordination numbers are not allowed.']
valid = {
'870512-1989': '198705121989',
'870512-2128': '198705122128',
'19870512-1989': '198705121989',
'198705121989': '198705121989',
'081015-6315': '190810156315',
'0810156315': '190810156315',
# This is a "special-case" in the checksum calculation,
# where the sum is divisible by 10 (the checksum digit == 0)
'8705141060': '198705141060',
# + means that the person is older than 100 years
'081015+6315': '180810156315',
# Co-ordination number checking
'870574-1315': '198705741315',
'870574+1315': '188705741315',
'198705741315': '198705741315',
}
invalid = {
'081015 6315': error_invalid,
'950d314496': error_invalid,
'invalid!!!': error_invalid,
# Invalid dates
# February 31st does not exist
'950231-4496': error_invalid,
# Month 14 does not exist
'6914104499': error_invalid,
# There are no Swedish personal id numbers where year < 1800
'17430309-7135': error_invalid,
# Invalid checksum
'870514-1111': error_invalid,
# Co-ordination number with bad checksum
'870573-1311': error_invalid,
}
self.assertFieldOutput(SEPersonalIdentityNumberField, valid, invalid)
valid = {}
invalid = {
# Check valid co-ordination numbers that should not be accepted
# because of coordination_number=False
'870574-1315': error_coord,
'870574+1315': error_coord,
'8705741315': error_coord,
# Invalid co-ordination numbers should be treated as invalid, and not
# as co-ordination numbers
'870573-1311': error_invalid,
}
kwargs = {'coordination_number': False,}
self.assertFieldOutput(SEPersonalIdentityNumberField, valid, invalid,
field_kwargs=kwargs)
def test_SEPostalCodeField(self):
error_format = ['Enter a Swedish postal code in the format XXXXX.']
valid = {
'589 37': '58937',
'58937': '58937',
}
invalid = {
'abcasfassadf': error_format,
# Only one space is allowed for separation
'589 37': error_format,
# The postal code must not start with 0
'01234': error_format,
}
self.assertFieldOutput(SEPostalCodeField, valid, invalid)

View File

@ -1,557 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from datetime import date
from django.contrib.localflavor.si.forms import (SIEMSOField, SITaxNumberField,
SIPhoneNumberField, SIPostalCodeField, SIPostalCodeSelect)
from django.test import SimpleTestCase
class SILocalFlavorTests(SimpleTestCase):
def test_SITaxNumberField(self):
error_invalid = ['Enter a valid tax number in form SIXXXXXXXX']
valid = {
'15012557': '15012557',
'SI15012557': '15012557',
'22111310': '22111310',
}
invalid = {
'22241310': error_invalid,
'15012558': error_invalid,
'1501': error_invalid,
'1501123123123': error_invalid,
'abcdabcd': error_invalid,
'01234579': error_invalid,
}
self.assertFieldOutput(SITaxNumberField, valid, invalid)
def test_SIEMSOField(self):
error_invalid = ['This field should contain exactly 13 digits.']
error_invalid_date = ['The first 7 digits of the EMSO must represent a valid past date.']
error_invalid_chksum = ['The EMSO is not valid.']
valid = {
'0205951500462': '0205951500462',
'2309002500068': '2309002500068',
'1010985500400': '1010985500400',
}
invalid = {
'0205951500463': error_invalid_chksum,
'020': error_invalid,
'020020595150046020595150046': error_invalid,
'aaaabbbbccccd': error_invalid,
'1010985500800': error_invalid_chksum,
'2020095500070': error_invalid_date,
'5050095500078': error_invalid_date,
'1010889500408': error_invalid_date,
}
self.assertFieldOutput(SIEMSOField, valid, invalid)
def test_SIEMSOField_info_dict(self):
valid = {
'0205951500462': {'nationality': 50, 'gender': 'male', 'birthdate': date(1951, 5, 2)},
'2309002504063': {'nationality': 50, 'gender': 'male', 'birthdate': date(2002, 9, 23)},
'1010985505402': {'nationality': 50, 'gender': 'female', 'birthdate': date(1985, 10, 10)},
}
for input, info in valid.items():
f = SIEMSOField()
f.clean(input)
self.assertEqual(f.info, info)
def test_SIPhoneNumberField(self):
error_invalid = ['Enter phone number in form +386XXXXXXXX or 0XXXXXXXX.']
valid = {
'+38640999999': '40999999',
'+3861999999': '1999999',
'0038640999999': '40999999',
'040999999': '40999999',
'01999999': '1999999',
'059099999': '59099999',
'059 09 99 99': '59099999',
'0590/999-99': '59099999',
}
invalid = {
'03861999999': error_invalid,
'3861999999': error_invalid,
}
self.assertFieldOutput(SIPhoneNumberField, valid, invalid)
def test_SIPostalCodeField(self):
valid = {
'4000': '4000',
'1000': '1000'
}
invalid = {
'1113': ['Select a valid choice. 1113 is not one of the available choices.'],
'111': ['Select a valid choice. 111 is not one of the available choices.'],
}
self.assertFieldOutput(SIPostalCodeField, valid, invalid)
def test_SIPostalCodeSelect(self):
f = SIPostalCodeSelect()
out = '''<select name="Kranj">
<option value="8341">Adle\u0161i\u010di</option>
<option value="5270">Ajdov\u0161\u010dina</option>
<option value="6280">Ankaran - Ancarano</option>
<option value="9253">Apa\u010de</option>
<option value="8253">Arti\u010de</option>
<option value="4275">Begunje na Gorenjskem</option>
<option value="1382">Begunje pri Cerknici</option>
<option value="9231">Beltinci</option>
<option value="2234">Benedikt</option>
<option value="2345">Bistrica ob Dravi</option>
<option value="3256">Bistrica ob Sotli</option>
<option value="8259">Bizeljsko</option>
<option value="1223">Blagovica</option>
<option value="8283">Blanca</option>
<option value="4260">Bled</option>
<option value="4273">Blejska Dobrava</option>
<option value="9265">Bodonci</option>
<option value="9222">Bogojina</option>
<option value="4263">Bohinjska Bela</option>
<option value="4264">Bohinjska Bistrica</option>
<option value="4265">Bohinjsko jezero</option>
<option value="1353">Borovnica</option>
<option value="5230">Bovec</option>
<option value="8294">Bo\u0161tanj</option>
<option value="5295">Branik</option>
<option value="3314">Braslov\u010de</option>
<option value="5223">Breginj</option>
<option value="8280">Brestanica</option>
<option value="2354">Bresternica</option>
<option value="4243">Brezje</option>
<option value="1351">Brezovica pri Ljubljani</option>
<option value="8250">Bre\u017eice</option>
<option value="4210">Brnik - aerodrom</option>
<option value="8321">Brusnice</option>
<option value="3255">Bu\u010de</option>
<option value="8276">Bu\u010dka</option>
<option value="9261">Cankova</option>
<option value="3000">Celje</option>
<option value="4207">Cerklje na Gorenjskem</option>
<option value="8263">Cerklje ob Krki</option>
<option value="1380">Cerknica</option>
<option value="5282">Cerkno</option>
<option value="2236">Cerkvenjak</option>
<option value="2215">Cer\u0161ak</option>
<option value="2326">Cirkovce</option>
<option value="2282">Cirkulane</option>
<option value="5273">Col</option>
<option value="6271">Dekani</option>
<option value="5210">Deskle</option>
<option value="2253">Destrnik</option>
<option value="6215">Diva\u010da</option>
<option value="1233">Dob</option>
<option value="3224">Dobje pri Planini</option>
<option value="8257">Dobova</option>
<option value="1423">Dobovec</option>
<option value="5263">Dobravlje</option>
<option value="3204">Dobrna</option>
<option value="8211">Dobrni\u010d</option>
<option value="1356">Dobrova</option>
<option value="9223">Dobrovnik - Dobronak</option>
<option value="5212">Dobrovo v Brdih</option>
<option value="1431">Dol pri Hrastniku</option>
<option value="1262">Dol pri Ljubljani</option>
<option value="1273">Dole pri Litiji</option>
<option value="1331">Dolenja vas</option>
<option value="8350">Dolenjske Toplice</option>
<option value="1230">Dom\u017eale</option>
<option value="2252">Dornava</option>
<option value="5294">Dornberk</option>
<option value="1319">Draga</option>
<option value="8343">Dragatu\u0161</option>
<option value="3222">Dramlje</option>
<option value="2370">Dravograd</option>
<option value="4203">Duplje</option>
<option value="6221">Dutovlje</option>
<option value="8361">Dvor</option>
<option value="2343">Fala</option>
<option value="9208">Fokovci</option>
<option value="2313">Fram</option>
<option value="3213">Frankolovo</option>
<option value="1274">Gabrovka</option>
<option value="8254">Globoko</option>
<option value="5275">Godovi\u010d</option>
<option value="4204">Golnik</option>
<option value="3303">Gomilsko</option>
<option value="4224">Gorenja vas</option>
<option value="3263">Gorica pri Slivnici</option>
<option value="2272">Gori\u0161nica</option>
<option value="9250">Gornja Radgona</option>
<option value="3342">Gornji Grad</option>
<option value="4282">Gozd Martuljek</option>
<option value="9264">Grad</option>
<option value="8332">Gradac</option>
<option value="1384">Grahovo</option>
<option value="5242">Grahovo ob Ba\u010di</option>
<option value="6272">Gra\u010di\u0161\u010de</option>
<option value="5251">Grgar</option>
<option value="3302">Gri\u017ee</option>
<option value="3231">Grobelno</option>
<option value="1290">Grosuplje</option>
<option value="2288">Hajdina</option>
<option value="8362">Hinje</option>
<option value="9205">Hodo\u0161 - Hodos</option>
<option value="1354">Horjul</option>
<option value="1372">Hotedr\u0161ica</option>
<option value="2311">Ho\u010de</option>
<option value="1430">Hrastnik</option>
<option value="6225">Hru\u0161evje</option>
<option value="4276">Hru\u0161ica</option>
<option value="5280">Idrija</option>
<option value="1292">Ig</option>
<option value="6250">Ilirska Bistrica</option>
<option value="6251">Ilirska Bistrica - Trnovo</option>
<option value="2259">Ivanjkovci</option>
<option value="1295">Ivan\u010dna Gorica</option>
<option value="1411">Izlake</option>
<option value="6310">Izola - Isola</option>
<option value="2222">Jakobski Dol</option>
<option value="2221">Jarenina</option>
<option value="6254">Jel\u0161ane</option>
<option value="4270">Jesenice</option>
<option value="8261">Jesenice na Dolenjskem</option>
<option value="3273">Jurklo\u0161ter</option>
<option value="2223">Jurovski Dol</option>
<option value="2256">Jur\u0161inci</option>
<option value="5214">Kal nad Kanalom</option>
<option value="3233">Kalobje</option>
<option value="4246">Kamna Gorica</option>
<option value="2351">Kamnica</option>
<option value="1241">Kamnik</option>
<option value="5213">Kanal</option>
<option value="8258">Kapele</option>
<option value="2362">Kapla</option>
<option value="2325">Kidri\u010devo</option>
<option value="1412">Kisovec</option>
<option value="6253">Kne\u017eak</option>
<option value="5222">Kobarid</option>
<option value="9227">Kobilje</option>
<option value="2276">Kog</option>
<option value="5211">Kojsko</option>
<option value="6223">Komen</option>
<option value="1218">Komenda</option>
<option value="6000">Koper</option>
<option value="8282">Koprivnica</option>
<option value="5296">Kostanjevica na Krasu</option>
<option value="8311">Kostanjevica na Krki</option>
<option value="1336">Kostel</option>
<option value="2394">Kotlje</option>
<option value="6240">Kozina</option>
<option value="3260">Kozje</option>
<option value="1330">Ko\u010devje</option>
<option value="1338">Ko\u010devska Reka</option>
<option value="6256">Ko\u0161ana</option>
<option value="4000" selected="selected">Kranj</option>
<option value="4280">Kranjska Gora</option>
<option value="1281">Kresnice</option>
<option value="4294">Kri\u017ee</option>
<option value="9206">Kri\u017eevci</option>
<option value="9242">Kri\u017eevci pri Ljutomeru</option>
<option value="1301">Krka</option>
<option value="8296">Krmelj</option>
<option value="4245">Kropa</option>
<option value="8262">Kr\u0161ka vas</option>
<option value="8270">Kr\u0161ko</option>
<option value="9263">Kuzma</option>
<option value="2318">Laporje</option>
<option value="1219">Laze v Tuhinju</option>
<option value="3270">La\u0161ko</option>
<option value="2230">Lenart v Slovenskih goricah</option>
<option value="9220">Lendava - Lendva</option>
<option value="4248">Lesce</option>
<option value="3261">Lesi\u010dno</option>
<option value="8273">Leskovec pri Kr\u0161kem</option>
<option value="2372">Libeli\u010de</option>
<option value="2341">Limbu\u0161</option>
<option value="1270">Litija</option>
<option value="3202">Ljube\u010dna</option>
<option value="1000">Ljubljana</option>
<option value="3333">Ljubno ob Savinji</option>
<option value="9240">Ljutomer</option>
<option value="5231">Log pod Mangartom</option>
<option value="1358">Log pri Brezovici</option>
<option value="1370">Logatec</option>
<option value="1434">Loka pri Zidanem Mostu</option>
<option value="3223">Loka pri \u017dusmu</option>
<option value="6219">Lokev</option>
<option value="2324">Lovrenc na Dravskem polju</option>
<option value="2344">Lovrenc na Pohorju</option>
<option value="3215">Lo\u010de</option>
<option value="1318">Lo\u0161ki Potok</option>
<option value="1225">Lukovica</option>
<option value="3334">Lu\u010de</option>
<option value="2322">Maj\u0161perk</option>
<option value="2321">Makole</option>
<option value="9243">Mala Nedelja</option>
<option value="2229">Male\u010dnik</option>
<option value="6273">Marezige</option>
<option value="2000">Maribor</option>
<option value="2206">Marjeta na Dravskem polju</option>
<option value="2281">Markovci</option>
<option value="9221">Martjanci</option>
<option value="6242">Materija</option>
<option value="4211">Mav\u010di\u010de</option>
<option value="9202">Ma\u010dkovci</option>
<option value="1215">Medvode</option>
<option value="1234">Menge\u0161</option>
<option value="8330">Metlika</option>
<option value="2392">Me\u017eica</option>
<option value="2204">Miklav\u017e na Dravskem polju</option>
<option value="2275">Miklav\u017e pri Ormo\u017eu</option>
<option value="5291">Miren</option>
<option value="8233">Mirna</option>
<option value="8216">Mirna Pe\u010d</option>
<option value="2382">Mislinja</option>
<option value="4281">Mojstrana</option>
<option value="8230">Mokronog</option>
<option value="9226">Moravske Toplice</option>
<option value="1251">Morav\u010de</option>
<option value="5216">Most na So\u010di</option>
<option value="1221">Motnik</option>
<option value="3330">Mozirje</option>
<option value="9000">Murska Sobota</option>
<option value="2366">Muta</option>
<option value="4202">Naklo</option>
<option value="3331">Nazarje</option>
<option value="1357">Notranje Gorice</option>
<option value="3203">Nova Cerkev</option>
<option value="5000">Nova Gorica</option>
<option value="1385">Nova vas</option>
<option value="8000">Novo mesto</option>
<option value="6243">Obrov</option>
<option value="9233">Odranci</option>
<option value="2317">Oplotnica</option>
<option value="2312">Orehova vas</option>
<option value="2270">Ormo\u017e</option>
<option value="1316">Ortnek</option>
<option value="1337">Osilnica</option>
<option value="8222">Oto\u010dec</option>
<option value="2361">O\u017ebalt</option>
<option value="2231">Pernica</option>
<option value="2211">Pesnica pri Mariboru</option>
<option value="9203">Petrovci</option>
<option value="3301">Petrov\u010de</option>
<option value="6330">Piran - Pirano</option>
<option value="6257">Pivka</option>
<option value="8255">Pi\u0161ece</option>
<option value="6232">Planina</option>
<option value="3225">Planina pri Sevnici</option>
<option value="6276">Pobegi</option>
<option value="8312">Podbo\u010dje</option>
<option value="5243">Podbrdo</option>
<option value="2273">Podgorci</option>
<option value="6216">Podgorje</option>
<option value="2381">Podgorje pri Slovenj Gradcu</option>
<option value="6244">Podgrad</option>
<option value="1414">Podkum</option>
<option value="2286">Podlehnik</option>
<option value="5272">Podnanos</option>
<option value="4244">Podnart</option>
<option value="3241">Podplat</option>
<option value="3257">Podsreda</option>
<option value="2363">Podvelka</option>
<option value="3254">Pod\u010detrtek</option>
<option value="2208">Pohorje</option>
<option value="2257">Polen\u0161ak</option>
<option value="1355">Polhov Gradec</option>
<option value="4223">Poljane nad \u0160kofjo Loko</option>
<option value="2319">Polj\u010dane</option>
<option value="3313">Polzela</option>
<option value="1272">Pol\u0161nik</option>
<option value="3232">Ponikva</option>
<option value="6320">Portoro\u017e - Portorose</option>
<option value="6230">Postojna</option>
<option value="2331">Pragersko</option>
<option value="3312">Prebold</option>
<option value="4205">Preddvor</option>
<option value="6255">Prem</option>
<option value="1352">Preserje</option>
<option value="6258">Prestranek</option>
<option value="2391">Prevalje</option>
<option value="3262">Prevorje</option>
<option value="1276">Primskovo</option>
<option value="3253">Pristava pri Mestinju</option>
<option value="9207">Prosenjakovci - Partosfalva</option>
<option value="5297">Prva\u010dina</option>
<option value="2250">Ptuj</option>
<option value="2323">Ptujska Gora</option>
<option value="9201">Puconci</option>
<option value="9252">Radenci</option>
<option value="1433">Rade\u010de</option>
<option value="2360">Radlje ob Dravi</option>
<option value="1235">Radomlje</option>
<option value="4240">Radovljica</option>
<option value="8274">Raka</option>
<option value="1381">Rakek</option>
<option value="4283">Rate\u010de - Planica</option>
<option value="2390">Ravne na Koro\u0161kem</option>
<option value="2327">Ra\u010de</option>
<option value="5292">Ren\u010de</option>
<option value="3332">Re\u010dica ob Savinji</option>
<option value="1310">Ribnica</option>
<option value="2364">Ribnica na Pohorju</option>
<option value="3272">Rimske Toplice</option>
<option value="1314">Rob</option>
<option value="3252">Rogatec</option>
<option value="3250">Roga\u0161ka Slatina</option>
<option value="9262">Roga\u0161ovci</option>
<option value="1373">Rovte</option>
<option value="5215">Ro\u010dinj</option>
<option value="2342">Ru\u0161e</option>
<option value="1282">Sava</option>
<option value="4227">Selca</option>
<option value="2352">Selnica ob Dravi</option>
<option value="8333">Semi\u010d</option>
<option value="8281">Senovo</option>
<option value="6224">Seno\u017ee\u010de</option>
<option value="8290">Sevnica</option>
<option value="6333">Se\u010dovlje - Sicciole</option>
<option value="6210">Se\u017eana</option>
<option value="2214">Sladki vrh</option>
<option value="5283">Slap ob Idrijci</option>
<option value="2380">Slovenj Gradec</option>
<option value="2310">Slovenska Bistrica</option>
<option value="3210">Slovenske Konjice</option>
<option value="1216">Smlednik</option>
<option value="1317">Sodra\u017eica</option>
<option value="5250">Solkan</option>
<option value="3335">Sol\u010dava</option>
<option value="4229">Sorica</option>
<option value="4225">Sovodenj</option>
<option value="5232">So\u010da</option>
<option value="5281">Spodnja Idrija</option>
<option value="2241">Spodnji Duplek</option>
<option value="9245">Spodnji Ivanjci</option>
<option value="2277">Sredi\u0161\u010de ob Dravi</option>
<option value="4267">Srednja vas v Bohinju</option>
<option value="8256">Sromlje</option>
<option value="5224">Srpenica</option>
<option value="1242">Stahovica</option>
<option value="1332">Stara Cerkev</option>
<option value="8342">Stari trg ob Kolpi</option>
<option value="1386">Stari trg pri Lo\u017eu</option>
<option value="2205">Star\u0161e</option>
<option value="2289">Stoperce</option>
<option value="8322">Stopi\u010de</option>
<option value="3206">Stranice</option>
<option value="8351">Stra\u017ea</option>
<option value="1313">Struge</option>
<option value="8293">Studenec</option>
<option value="8331">Suhor</option>
<option value="2353">Sv. Duh na Ostrem Vrhu</option>
<option value="2233">Sveta Ana v Slovenskih goricah</option>
<option value="2235">Sveta Trojica v Slovenskih goricah</option>
<option value="9244">Sveti Jurij ob \u0160\u010davnici</option>
<option value="2258">Sveti Toma\u017e</option>
<option value="3264">Sveti \u0160tefan</option>
<option value="3304">Tabor</option>
<option value="3221">Teharje</option>
<option value="9251">Ti\u0161ina</option>
<option value="5220">Tolmin</option>
<option value="3326">Topol\u0161ica</option>
<option value="2371">Trbonje</option>
<option value="1420">Trbovlje</option>
<option value="8231">Trebelno</option>
<option value="8210">Trebnje</option>
<option value="5252">Trnovo pri Gorici</option>
<option value="2254">Trnovska vas</option>
<option value="1222">Trojane</option>
<option value="1236">Trzin</option>
<option value="4290">Tr\u017ei\u010d</option>
<option value="8295">Tr\u017ei\u0161\u010de</option>
<option value="1311">Turjak</option>
<option value="9224">Turni\u0161\u010de</option>
<option value="8323">Ur\u0161na sela</option>
<option value="1252">Va\u010de</option>
<option value="3320">Velenje - dostava</option>
<option value="3322">Velenje - po\u0161tni predali</option>
<option value="8212">Velika Loka</option>
<option value="2274">Velika Nedelja</option>
<option value="9225">Velika Polana</option>
<option value="1315">Velike La\u0161\u010de</option>
<option value="8213">Veliki Gaber</option>
<option value="9241">Ver\u017eej</option>
<option value="1312">Videm - Dobrepolje</option>
<option value="2284">Videm pri Ptuju</option>
<option value="8344">Vinica pri \u010crnomlju</option>
<option value="5271">Vipava</option>
<option value="4212">Visoko</option>
<option value="3205">Vitanje</option>
<option value="2255">Vitomarci</option>
<option value="1294">Vi\u0161nja Gora</option>
<option value="1217">Vodice</option>
<option value="3212">Vojnik</option>
<option value="2232">Voli\u010dina</option>
<option value="5293">Vol\u010dja Draga</option>
<option value="3305">Vransko</option>
<option value="6217">Vremski Britof</option>
<option value="1360">Vrhnika</option>
<option value="2365">Vuhred</option>
<option value="2367">Vuzenica</option>
<option value="8292">Zabukovje</option>
<option value="1410">Zagorje ob Savi</option>
<option value="1303">Zagradec</option>
<option value="2283">Zavr\u010d</option>
<option value="8272">Zdole</option>
<option value="4201">Zgornja Besnica</option>
<option value="2242">Zgornja Korena</option>
<option value="2201">Zgornja Kungota</option>
<option value="2316">Zgornja Lo\u017enica</option>
<option value="2314">Zgornja Polskava</option>
<option value="2213">Zgornja Velka</option>
<option value="4247">Zgornje Gorje</option>
<option value="4206">Zgornje Jezersko</option>
<option value="2285">Zgornji Leskovec</option>
<option value="1432">Zidani Most</option>
<option value="3214">Zre\u010de</option>
<option value="8251">\u010cate\u017e ob Savi</option>
<option value="1413">\u010cem\u0161enik</option>
<option value="5253">\u010cepovan</option>
<option value="9232">\u010cren\u0161ovci</option>
<option value="2393">\u010crna na Koro\u0161kem</option>
<option value="6275">\u010crni Kal</option>
<option value="5274">\u010crni Vrh nad Idrijo</option>
<option value="5262">\u010crni\u010de</option>
<option value="8340">\u010crnomelj</option>
<option value="9204">\u0160alovci</option>
<option value="5261">\u0160empas</option>
<option value="5290">\u0160empeter pri Gorici</option>
<option value="3311">\u0160empeter v Savinjski dolini</option>
<option value="2212">\u0160entilj v Slovenskih goricah</option>
<option value="8297">\u0160entjan\u017e</option>
<option value="2373">\u0160entjan\u017e pri Dravogradu</option>
<option value="8310">\u0160entjernej</option>
<option value="3230">\u0160entjur</option>
<option value="3271">\u0160entrupert</option>
<option value="8232">\u0160entrupert</option>
<option value="1296">\u0160entvid pri Sti\u010dni</option>
<option value="4208">\u0160en\u010dur</option>
<option value="8275">\u0160kocjan</option>
<option value="6281">\u0160kofije</option>
<option value="4220">\u0160kofja Loka</option>
<option value="3211">\u0160kofja vas</option>
<option value="1291">\u0160kofljica</option>
<option value="6274">\u0160marje</option>
<option value="1293">\u0160marje - Sap</option>
<option value="3240">\u0160marje pri Jel\u0161ah</option>
<option value="8220">\u0160marje\u0161ke Toplice</option>
<option value="2315">\u0160martno na Pohorju</option>
<option value="3341">\u0160martno ob Dreti</option>
<option value="3327">\u0160martno ob Paki</option>
<option value="1275">\u0160martno pri Litiji</option>
<option value="2383">\u0160martno pri Slovenj Gradcu</option>
<option value="3201">\u0160martno v Ro\u017eni dolini</option>
<option value="3325">\u0160o\u0161tanj</option>
<option value="6222">\u0160tanjel</option>
<option value="3220">\u0160tore</option>
<option value="4209">\u017dabnica</option>
<option value="3310">\u017dalec</option>
<option value="4228">\u017delezniki</option>
<option value="2287">\u017detale</option>
<option value="4226">\u017diri</option>
<option value="4274">\u017dirovnica</option>
<option value="8360">\u017du\u017eemberk</option>
</select>'''
self.assertHTMLEqual(f.render('Kranj', '4000'), out)

View File

@ -1,118 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.sk.forms import (SKRegionSelect,
SKPostalCodeField, SKDistrictSelect)
from django.test import SimpleTestCase
class SKLocalFlavorTests(SimpleTestCase):
def test_SKRegionSelect(self):
f = SKRegionSelect()
out = '''<select name="regions">
<option value="BB">Banska Bystrica region</option>
<option value="BA">Bratislava region</option>
<option value="KE">Kosice region</option>
<option value="NR">Nitra region</option>
<option value="PO">Presov region</option>
<option value="TN">Trencin region</option>
<option value="TT" selected="selected">Trnava region</option>
<option value="ZA">Zilina region</option>
</select>'''
self.assertHTMLEqual(f.render('regions', 'TT'), out)
def test_SKDistrictSelect(self):
f = SKDistrictSelect()
out = '''<select name="Districts">
<option value="BB">Banska Bystrica</option>
<option value="BS">Banska Stiavnica</option>
<option value="BJ">Bardejov</option>
<option value="BN">Banovce nad Bebravou</option>
<option value="BR">Brezno</option>
<option value="BA1">Bratislava I</option>
<option value="BA2">Bratislava II</option>
<option value="BA3">Bratislava III</option>
<option value="BA4">Bratislava IV</option>
<option value="BA5">Bratislava V</option>
<option value="BY">Bytca</option>
<option value="CA">Cadca</option>
<option value="DT">Detva</option>
<option value="DK">Dolny Kubin</option>
<option value="DS">Dunajska Streda</option>
<option value="GA">Galanta</option>
<option value="GL">Gelnica</option>
<option value="HC">Hlohovec</option>
<option value="HE">Humenne</option>
<option value="IL">Ilava</option>
<option value="KK">Kezmarok</option>
<option value="KN">Komarno</option>
<option value="KE1">Kosice I</option>
<option value="KE2">Kosice II</option>
<option value="KE3">Kosice III</option>
<option value="KE4">Kosice IV</option>
<option value="KEO">Kosice - okolie</option>
<option value="KA">Krupina</option>
<option value="KM">Kysucke Nove Mesto</option>
<option value="LV">Levice</option>
<option value="LE">Levoca</option>
<option value="LM">Liptovsky Mikulas</option>
<option value="LC">Lucenec</option>
<option value="MA">Malacky</option>
<option value="MT">Martin</option>
<option value="ML">Medzilaborce</option>
<option value="MI">Michalovce</option>
<option value="MY">Myjava</option>
<option value="NO">Namestovo</option>
<option value="NR">Nitra</option>
<option value="NM">Nove Mesto nad Vahom</option>
<option value="NZ">Nove Zamky</option>
<option value="PE">Partizanske</option>
<option value="PK">Pezinok</option>
<option value="PN">Piestany</option>
<option value="PT">Poltar</option>
<option value="PP">Poprad</option>
<option value="PB">Povazska Bystrica</option>
<option value="PO">Presov</option>
<option value="PD">Prievidza</option>
<option value="PU">Puchov</option>
<option value="RA">Revuca</option>
<option value="RS">Rimavska Sobota</option>
<option value="RV">Roznava</option>
<option value="RK" selected="selected">Ruzomberok</option>
<option value="SB">Sabinov</option>
<option value="SC">Senec</option>
<option value="SE">Senica</option>
<option value="SI">Skalica</option>
<option value="SV">Snina</option>
<option value="SO">Sobrance</option>
<option value="SN">Spisska Nova Ves</option>
<option value="SL">Stara Lubovna</option>
<option value="SP">Stropkov</option>
<option value="SK">Svidnik</option>
<option value="SA">Sala</option>
<option value="TO">Topolcany</option>
<option value="TV">Trebisov</option>
<option value="TN">Trencin</option>
<option value="TT">Trnava</option>
<option value="TR">Turcianske Teplice</option>
<option value="TS">Tvrdosin</option>
<option value="VK">Velky Krtis</option>
<option value="VT">Vranov nad Toplou</option>
<option value="ZM">Zlate Moravce</option>
<option value="ZV">Zvolen</option>
<option value="ZC">Zarnovica</option>
<option value="ZH">Ziar nad Hronom</option>
<option value="ZA">Zilina</option>
</select>'''
self.assertHTMLEqual(f.render('Districts', 'RK'), out)
def test_SKPostalCodeField(self):
error_format = ['Enter a postal code in the format XXXXX or XXX XX.']
valid = {
'91909': '91909',
'917 01': '91701',
}
invalid = {
'84545x': error_format,
}
self.assertFieldOutput(SKPostalCodeField, valid, invalid)

View File

@ -1,45 +1,3 @@
from __future__ import absolute_import
from .ar.tests import ARLocalFlavorTests
from .at.tests import ATLocalFlavorTests
from .au.tests import AULocalflavorTests
from .be.tests import BELocalFlavorTests
from .br.tests import BRLocalFlavorTests
from .ca.tests import CALocalFlavorTests
from .ch.tests import CHLocalFlavorTests
from .cl.tests import CLLocalFlavorTests
from .cn.tests import CNLocalFlavorTests
from .co.tests import COLocalFlavorTests
from .cz.tests import CZLocalFlavorTests
from .de.tests import DELocalFlavorTests
from .ec.tests import ECLocalFlavorTests
from .es.tests import ESLocalFlavorTests
from .fi.tests import FILocalFlavorTests
from .fr.tests import FRLocalFlavorTests
from .gb.tests import GBLocalFlavorTests
from .generic.tests import GenericLocalFlavorTests
from .hk.tests import HKLocalFlavorTests
from .hr.tests import HRLocalFlavorTests
from .id.tests import IDLocalFlavorTests
from .ie.tests import IELocalFlavorTests
from .il.tests import ILLocalFlavorTests
from .in_.tests import INLocalFlavorTests
from .is_.tests import ISLocalFlavorTests
from .it.tests import ITLocalFlavorTests
from .jp.tests import JPLocalFlavorTests
from .kw.tests import KWLocalFlavorTests
from .mk.tests import MKLocalFlavorTests
from .mx.tests import MXLocalFlavorTests
from .nl.tests import NLLocalFlavorTests
from .pl.tests import PLLocalFlavorTests
from .pt.tests import PTLocalFlavorTests
from .py.tests import PYLocalFlavorTests
from .ro.tests import ROLocalFlavorTests
from .ru.tests import RULocalFlavorTests
from .se.tests import SELocalFlavorTests
from .si.tests import SILocalFlavorTests
from .sk.tests import SKLocalFlavorTests
from .tr.tests import TRLocalFlavorTests
from .us.tests import USLocalFlavorTests
from .uy.tests import UYLocalFlavorTests
from .za.tests import ZALocalFlavorTests

View File

@ -1,75 +0,0 @@
# Tests for the contrib/localflavor/ TR form fields.
from django.contrib.localflavor.tr import forms as trforms
from django.core.exceptions import ValidationError
from django.utils import six
from django.utils.unittest import TestCase
class TRLocalFlavorTests(TestCase):
def test_TRPostalCodeField(self):
f = trforms.TRPostalCodeField()
self.assertEqual(f.clean("06531"), "06531")
self.assertEqual(f.clean("12345"), "12345")
six.assertRaisesRegex(self, ValidationError,
"Enter a postal code in the format XXXXX.",
f.clean, "a1234")
six.assertRaisesRegex(self, ValidationError,
"Enter a postal code in the format XXXXX.",
f.clean, "1234")
six.assertRaisesRegex(self, ValidationError,
"Enter a postal code in the format XXXXX.",
f.clean, "82123")
six.assertRaisesRegex(self, ValidationError,
"Enter a postal code in the format XXXXX.",
f.clean, "00123")
six.assertRaisesRegex(self, ValidationError,
"Enter a postal code in the format XXXXX.",
f.clean, "123456")
six.assertRaisesRegex(self, ValidationError,
"Enter a postal code in the format XXXXX.",
f.clean, "12 34")
self.assertRaises(ValidationError, f.clean, None)
def test_TRPhoneNumberField(self):
f = trforms.TRPhoneNumberField()
self.assertEqual(f.clean("312 455 56 78"), "3124555678")
self.assertEqual(f.clean("312 4555678"), "3124555678")
self.assertEqual(f.clean("3124555678"), "3124555678")
self.assertEqual(f.clean("0312 455 5678"), "3124555678")
self.assertEqual(f.clean("0 312 455 5678"), "3124555678")
self.assertEqual(f.clean("0 (312) 455 5678"), "3124555678")
self.assertEqual(f.clean("+90 312 455 4567"), "3124554567")
self.assertEqual(f.clean("+90 312 455 45 67"), "3124554567")
self.assertEqual(f.clean("+90 (312) 4554567"), "3124554567")
six.assertRaisesRegex(self, ValidationError,
'Phone numbers must be in 0XXX XXX XXXX format.',
f.clean, "1234 233 1234")
six.assertRaisesRegex(self, ValidationError,
'Phone numbers must be in 0XXX XXX XXXX format.',
f.clean, "0312 233 12345")
six.assertRaisesRegex(self, ValidationError,
'Phone numbers must be in 0XXX XXX XXXX format.',
f.clean, "0312 233 123")
six.assertRaisesRegex(self, ValidationError,
'Phone numbers must be in 0XXX XXX XXXX format.',
f.clean, "0312 233 xxxx")
def test_TRIdentificationNumberField(self):
f = trforms.TRIdentificationNumberField()
self.assertEqual(f.clean("10000000146"), "10000000146")
six.assertRaisesRegex(self, ValidationError,
'Enter a valid Turkish Identification number.',
f.clean, "10000000136")
six.assertRaisesRegex(self, ValidationError,
'Enter a valid Turkish Identification number.',
f.clean, "10000000147")
six.assertRaisesRegex(self, ValidationError,
'Turkish Identification number must be 11 digits.',
f.clean, "123456789")
six.assertRaisesRegex(self, ValidationError,
'Enter a valid Turkish Identification number.',
f.clean, "1000000014x")
six.assertRaisesRegex(self, ValidationError,
'Enter a valid Turkish Identification number.',
f.clean, "x0000000146")

View File

@ -1,11 +0,0 @@
from __future__ import absolute_import
from django.forms import ModelForm
from .models import USPlace
class USPlaceForm(ModelForm):
class Meta:
model = USPlace

View File

@ -1,15 +0,0 @@
from django.contrib.localflavor.us.models import USStateField, USPostalCodeField
from django.db import models
# When creating models you need to remember to add a app_label as
# 'localflavor', so your model can be found
class USPlace(models.Model):
state = USStateField(blank=True)
state_req = USStateField()
state_default = USStateField(default="CA", blank=True)
postal_code = USPostalCodeField(blank=True)
name = models.CharField(max_length=20)
class Meta:
app_label = 'localflavor'

View File

@ -1,286 +0,0 @@
from __future__ import absolute_import, unicode_literals
from django.contrib.localflavor.us.forms import (USZipCodeField,
USPhoneNumberField, USStateField, USStateSelect,
USSocialSecurityNumberField)
from django.test import SimpleTestCase
from .forms import USPlaceForm
class USLocalFlavorTests(SimpleTestCase):
def setUp(self):
self.form = USPlaceForm({'state':'GA', 'state_req':'NC', 'postal_code': 'GA', 'name':'impossible'})
def test_get_display_methods(self):
"""Test that the get_*_display() methods are added to the model instances."""
place = self.form.save()
self.assertEqual(place.get_state_display(), 'Georgia')
self.assertEqual(place.get_state_req_display(), 'North Carolina')
def test_required(self):
"""Test that required USStateFields throw appropriate errors."""
form = USPlaceForm({'state':'GA', 'name':'Place in GA'})
self.assertFalse(form.is_valid())
self.assertEqual(form.errors['state_req'], ['This field is required.'])
def test_field_blank_option(self):
"""Test that the empty option is there."""
state_select_html = """\
<select name="state" id="id_state">
<option value="">---------</option>
<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" selected="selected">Georgia</option>
<option value="GU">Guam</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">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.assertHTMLEqual(str(self.form['state']), state_select_html)
def test_full_postal_code_list(self):
"""Test that the full USPS code field is really the full list."""
usps_select_html = """\
<select name="postal_code" id="id_postal_code">
<option value="">---------</option>
<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="FM">Federated States of Micronesia</option>
<option value="FL">Florida</option>
<option value="GA" selected="selected">Georgia</option>
<option value="GU">Guam</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">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="MH">Marshall Islands</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="PW">Palau</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.assertHTMLEqual(str(self.form['postal_code']), usps_select_html)
def test_USStateSelect(self):
f = USStateSelect()
out = '''<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.assertHTMLEqual(f.render('state', 'IL'), out)
def test_USZipCodeField(self):
error_format = ['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 = ['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 = ['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 = ['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 File

@ -1,53 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.uy.forms import UYDepartamentSelect, UYCIField
from django.contrib.localflavor.uy.util import get_validation_digit
from django.test import SimpleTestCase
class UYLocalFlavorTests(SimpleTestCase):
def test_UYDepartmentSelect(self):
f = UYDepartamentSelect()
out = '''<select name="departamentos">
<option value="G">Artigas</option>
<option value="A">Canelones</option>
<option value="E">Cerro Largo</option>
<option value="L">Colonia</option>
<option value="Q">Durazno</option>
<option value="N">Flores</option>
<option value="O">Florida</option>
<option value="P">Lavalleja</option>
<option value="B">Maldonado</option>
<option value="S" selected="selected">Montevideo</option>
<option value="I">Paysand\xfa</option>
<option value="J">R\xedo Negro</option>
<option value="F">Rivera</option>
<option value="C">Rocha</option>
<option value="H">Salto</option>
<option value="M">San Jos\xe9</option>
<option value="K">Soriano</option>
<option value="R">Tacuaremb\xf3</option>
<option value="D">Treinta y Tres</option>
</select>'''
self.assertHTMLEqual(f.render('departamentos', 'S'), out)
def test_UYCIField(self):
error_format = ['Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.']
error_invalid = ['Enter a valid CI number.']
valid = {
'4098053': '4098053',
'409805-3': '409805-3',
'409.805-3': '409.805-3',
'10054112': '10054112',
'1005411-2': '1005411-2',
'1.005.411-2': '1.005.411-2',
}
invalid = {
'foo': ['Enter a valid CI number in X.XXX.XXX-X,XXXXXXX-X or XXXXXXXX format.'],
'409805-2': ['Enter a valid CI number.'],
'1.005.411-5': ['Enter a valid CI number.'],
}
self.assertFieldOutput(UYCIField, valid, invalid)
self.assertEqual(get_validation_digit(409805), 3)
self.assertEqual(get_validation_digit(1005411), 2)

View File

@ -1,31 +0,0 @@
from __future__ import unicode_literals
from django.contrib.localflavor.za.forms import ZAIDField, ZAPostCodeField
from django.test import SimpleTestCase
class ZALocalFlavorTests(SimpleTestCase):
def test_ZAIDField(self):
error_invalid = ['Enter a valid South African ID number']
valid = {
'0002290001003': '0002290001003',
'000229 0001 003': '0002290001003',
}
invalid = {
'0102290001001': error_invalid,
'811208': error_invalid,
'0002290001004': error_invalid,
}
self.assertFieldOutput(ZAIDField, valid, invalid)
def test_ZAPostCodeField(self):
error_invalid = ['Enter a valid South African postal code']
valid = {
'0000': '0000',
}
invalid = {
'abcd': error_invalid,
' 7530': error_invalid,
}
self.assertFieldOutput(ZAPostCodeField, valid, invalid)