PageRenderTime 83ms CodeModel.GetById 40ms app.highlight 6ms RepoModel.GetById 35ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/fr.py

https://code.google.com/p/mango-py/
Python | 145 lines | 140 code | 5 blank | 0 comment | 0 complexity | a5cbfbaaa1a0153968fe7594cdd6e338 MD5 | raw file
  1from django.contrib.localflavor.fr.forms import (FRZipCodeField,
  2        FRPhoneNumberField, FRDepartmentSelect)
  3
  4from utils import LocalFlavorTestCase
  5
  6
  7class FRLocalFlavorTests(LocalFlavorTestCase):
  8    def test_FRZipCodeField(self):
  9        error_format = [u'Enter a zip code in the format XXXXX.']
 10        valid = {
 11            '75001': '75001',
 12            '93200': '93200',
 13        }
 14        invalid = {
 15            '2A200': error_format,
 16            '980001': error_format,
 17        }
 18        self.assertFieldOutput(FRZipCodeField, valid, invalid)
 19
 20    def test_FRPhoneNumberField(self):
 21        error_format = [u'Phone numbers must be in 0X XX XX XX XX format.']
 22        valid = {
 23            '01 55 44 58 64': '01 55 44 58 64',
 24            '0155445864': '01 55 44 58 64',
 25            '01 5544 5864': '01 55 44 58 64',
 26            '01 55.44.58.64': '01 55 44 58 64',
 27            '01.55.44.58.64': '01 55 44 58 64',
 28        }
 29        invalid = {
 30            '01,55,44,58,64': error_format,
 31            '555 015 544': error_format,
 32        }
 33        self.assertFieldOutput(FRPhoneNumberField, valid, invalid)
 34
 35    def test_FRDepartmentSelect(self):
 36        f = FRDepartmentSelect()
 37        out = u'''<select name="dep">
 38<option value="01">01 - Ain</option>
 39<option value="02">02 - Aisne</option>
 40<option value="03">03 - Allier</option>
 41<option value="04">04 - Alpes-de-Haute-Provence</option>
 42<option value="05">05 - Hautes-Alpes</option>
 43<option value="06">06 - Alpes-Maritimes</option>
 44<option value="07">07 - Ardeche</option>
 45<option value="08">08 - Ardennes</option>
 46<option value="09">09 - Ariege</option>
 47<option value="10">10 - Aube</option>
 48<option value="11">11 - Aude</option>
 49<option value="12">12 - Aveyron</option>
 50<option value="13">13 - Bouches-du-Rhone</option>
 51<option value="14">14 - Calvados</option>
 52<option value="15">15 - Cantal</option>
 53<option value="16">16 - Charente</option>
 54<option value="17">17 - Charente-Maritime</option>
 55<option value="18">18 - Cher</option>
 56<option value="19">19 - Correze</option>
 57<option value="21">21 - Cote-d&#39;Or</option>
 58<option value="22">22 - Cotes-d&#39;Armor</option>
 59<option value="23">23 - Creuse</option>
 60<option value="24">24 - Dordogne</option>
 61<option value="25">25 - Doubs</option>
 62<option value="26">26 - Drome</option>
 63<option value="27">27 - Eure</option>
 64<option value="28">28 - Eure-et-Loire</option>
 65<option value="29">29 - Finistere</option>
 66<option value="2A">2A - Corse-du-Sud</option>
 67<option value="2B">2B - Haute-Corse</option>
 68<option value="30">30 - Gard</option>
 69<option value="31">31 - Haute-Garonne</option>
 70<option value="32">32 - Gers</option>
 71<option value="33">33 - Gironde</option>
 72<option value="34">34 - Herault</option>
 73<option value="35">35 - Ille-et-Vilaine</option>
 74<option value="36">36 - Indre</option>
 75<option value="37">37 - Indre-et-Loire</option>
 76<option value="38">38 - Isere</option>
 77<option value="39">39 - Jura</option>
 78<option value="40">40 - Landes</option>
 79<option value="41">41 - Loir-et-Cher</option>
 80<option value="42">42 - Loire</option>
 81<option value="43">43 - Haute-Loire</option>
 82<option value="44">44 - Loire-Atlantique</option>
 83<option value="45">45 - Loiret</option>
 84<option value="46">46 - Lot</option>
 85<option value="47">47 - Lot-et-Garonne</option>
 86<option value="48">48 - Lozere</option>
 87<option value="49">49 - Maine-et-Loire</option>
 88<option value="50">50 - Manche</option>
 89<option value="51">51 - Marne</option>
 90<option value="52">52 - Haute-Marne</option>
 91<option value="53">53 - Mayenne</option>
 92<option value="54">54 - Meurthe-et-Moselle</option>
 93<option value="55">55 - Meuse</option>
 94<option value="56">56 - Morbihan</option>
 95<option value="57">57 - Moselle</option>
 96<option value="58">58 - Nievre</option>
 97<option value="59">59 - Nord</option>
 98<option value="60">60 - Oise</option>
 99<option value="61">61 - Orne</option>
100<option value="62">62 - Pas-de-Calais</option>
101<option value="63">63 - Puy-de-Dome</option>
102<option value="64">64 - Pyrenees-Atlantiques</option>
103<option value="65">65 - Hautes-Pyrenees</option>
104<option value="66">66 - Pyrenees-Orientales</option>
105<option value="67">67 - Bas-Rhin</option>
106<option value="68">68 - Haut-Rhin</option>
107<option value="69">69 - Rhone</option>
108<option value="70">70 - Haute-Saone</option>
109<option value="71">71 - Saone-et-Loire</option>
110<option value="72">72 - Sarthe</option>
111<option value="73">73 - Savoie</option>
112<option value="74">74 - Haute-Savoie</option>
113<option value="75">75 - Paris</option>
114<option value="76">76 - Seine-Maritime</option>
115<option value="77">77 - Seine-et-Marne</option>
116<option value="78">78 - Yvelines</option>
117<option value="79">79 - Deux-Sevres</option>
118<option value="80">80 - Somme</option>
119<option value="81">81 - Tarn</option>
120<option value="82">82 - Tarn-et-Garonne</option>
121<option value="83">83 - Var</option>
122<option value="84">84 - Vaucluse</option>
123<option value="85">85 - Vendee</option>
124<option value="86">86 - Vienne</option>
125<option value="87">87 - Haute-Vienne</option>
126<option value="88">88 - Vosges</option>
127<option value="89">89 - Yonne</option>
128<option value="90">90 - Territoire de Belfort</option>
129<option value="91">91 - Essonne</option>
130<option value="92">92 - Hauts-de-Seine</option>
131<option value="93">93 - Seine-Saint-Denis</option>
132<option value="94">94 - Val-de-Marne</option>
133<option value="95">95 - Val-d&#39;Oise</option>
134<option value="971">971 - Guadeloupe</option>
135<option value="972">972 - Martinique</option>
136<option value="973">973 - Guyane</option>
137<option value="974">974 - La Reunion</option>
138<option value="975">975 - Saint-Pierre-et-Miquelon</option>
139<option value="976">976 - Mayotte</option>
140<option value="984">984 - Terres Australes et Antarctiques</option>
141<option value="986">986 - Wallis et Futuna</option>
142<option value="987">987 - Polynesie Francaise</option>
143<option value="988">988 - Nouvelle-Caledonie</option>
144</select>'''
145        self.assertEqual(f.render('dep', 'Paris'), out)