2012-06-07 16:08:47 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2011-04-22 12:03:30 +00:00
|
|
|
from django.contrib.localflavor.ru.forms import *
|
2011-08-24 12:30:59 +00:00
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
from django.test import SimpleTestCase
|
2011-04-22 12:03:30 +00:00
|
|
|
|
|
|
|
|
2011-08-23 02:32:37 +00:00
|
|
|
class RULocalFlavorTests(SimpleTestCase):
|
2011-04-22 12:03:30 +00:00
|
|
|
|
|
|
|
def test_RUPassportNumberField(self):
|
2012-06-07 16:08:47 +00:00
|
|
|
error = ['Enter a passport number in the format XXXX XXXXXX.']
|
2011-04-22 12:03:30 +00:00
|
|
|
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):
|
2012-06-07 16:08:47 +00:00
|
|
|
error = ['Enter a passport number in the format XX XXXXXXX.']
|
2011-04-22 12:03:30 +00:00
|
|
|
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):
|
2012-06-07 16:08:47 +00:00
|
|
|
error = ['Enter a postal code in the format XXXXXX.']
|
2011-04-22 12:03:30 +00:00
|
|
|
valid = {
|
|
|
|
'987654': '987654',
|
|
|
|
'123456': '123456'
|
|
|
|
}
|
|
|
|
invalid = {
|
|
|
|
'123 34': error,
|
|
|
|
'1234567': error,
|
|
|
|
'12345': error
|
|
|
|
}
|
|
|
|
self.assertFieldOutput(RUPostalCodeField, valid, invalid)
|
|
|
|
|
|
|
|
def test_RUCountySelect(self):
|
|
|
|
f = RUCountySelect()
|
2012-06-07 16:08:47 +00:00
|
|
|
out = '''<select name="county">
|
2011-04-22 12:03:30 +00:00
|
|
|
<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>'''
|
2012-01-31 20:36:11 +00:00
|
|
|
self.assertHTMLEqual(f.render('county', None), out)
|
2011-04-22 12:03:30 +00:00
|
|
|
|
|
|
|
def test_RURegionSelect(self):
|
|
|
|
f = RURegionSelect()
|
2012-06-07 16:08:47 +00:00
|
|
|
out = '''<select name="region">
|
2011-04-22 12:03:30 +00:00
|
|
|
<option value="77">Moskva</option>
|
|
|
|
<option value="78">Saint-Peterburg</option>
|
|
|
|
<option value="50">Moskovskaya oblast'</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'siyy Kray</option>
|
|
|
|
<option value="27">Khabarovskiy Kray</option>
|
|
|
|
<option value="28">Amurskaya oblast'</option>
|
|
|
|
<option value="29">Arkhangel'skaya oblast'</option>
|
|
|
|
<option value="30">Astrakhanskaya oblast'</option>
|
|
|
|
<option value="31">Belgorodskaya oblast'</option>
|
|
|
|
<option value="32">Bryanskaya oblast'</option>
|
|
|
|
<option value="33">Vladimirskaya oblast'</option>
|
|
|
|
<option value="34">Volgogradskaya oblast'</option>
|
|
|
|
<option value="35">Vologodskaya oblast'</option>
|
|
|
|
<option value="36">Voronezhskaya oblast'</option>
|
|
|
|
<option value="37">Ivanovskaya oblast'</option>
|
|
|
|
<option value="38">Irkutskaya oblast'</option>
|
|
|
|
<option value="39">Kaliningradskaya oblast'</option>
|
|
|
|
<option value="40">Kaluzhskaya oblast'</option>
|
|
|
|
<option value="42">Kemerovskaya oblast'</option>
|
|
|
|
<option value="43">Kirovskaya oblast'</option>
|
|
|
|
<option value="44">Kostromskaya oblast'</option>
|
|
|
|
<option value="45">Kurganskaya oblast'</option>
|
|
|
|
<option value="46">Kurskaya oblast'</option>
|
|
|
|
<option value="47">Leningradskaya oblast'</option>
|
|
|
|
<option value="48">Lipeckaya oblast'</option>
|
|
|
|
<option value="49">Magadanskaya oblast'</option>
|
|
|
|
<option value="51">Murmanskaya oblast'</option>
|
|
|
|
<option value="52">Nizhegorodskaja oblast'</option>
|
|
|
|
<option value="53">Novgorodskaya oblast'</option>
|
|
|
|
<option value="54">Novosibirskaya oblast'</option>
|
|
|
|
<option value="55">Omskaya oblast'</option>
|
|
|
|
<option value="56">Orenburgskaya oblast'</option>
|
|
|
|
<option value="57">Orlovskaya oblast'</option>
|
|
|
|
<option value="58">Penzenskaya oblast'</option>
|
|
|
|
<option value="60">Pskovskaya oblast'</option>
|
|
|
|
<option value="61">Rostovskaya oblast'</option>
|
|
|
|
<option value="62">Rjazanskaya oblast'</option>
|
|
|
|
<option value="63">Samarskaya oblast'</option>
|
|
|
|
<option value="64">Saratovskaya oblast'</option>
|
|
|
|
<option value="65">Sakhalinskaya oblast'</option>
|
|
|
|
<option value="66">Sverdlovskaya oblast'</option>
|
|
|
|
<option value="67" selected="selected">Smolenskaya oblast'</option>
|
|
|
|
<option value="68">Tambovskaya oblast'</option>
|
|
|
|
<option value="69">Tverskaya oblast'</option>
|
|
|
|
<option value="70">Tomskaya oblast'</option>
|
|
|
|
<option value="71">Tul'skaya oblast'</option>
|
|
|
|
<option value="72">Tyumenskaya oblast'</option>
|
|
|
|
<option value="73">Ul'ianovskaya oblast'</option>
|
|
|
|
<option value="74">Chelyabinskaya oblast'</option>
|
|
|
|
<option value="76">Yaroslavskaya oblast'</option>
|
|
|
|
<option value="79">Evreyskaya avtonomnaja oblast'</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>'''
|
2012-01-31 20:36:11 +00:00
|
|
|
self.assertHTMLEqual(f.render('region', '67'), out)
|