PageRenderTime 20ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/forms/localflavor/jp.py

https://code.google.com/p/mango-py/
Python | 73 lines | 70 code | 3 blank | 0 comment | 2 complexity | 57090511ad9bbde6af8eac575509ebfb MD5 | raw file
 1from django.contrib.localflavor.jp.forms import (JPPostalCodeField,
 2    JPPrefectureSelect)
 3
 4from utils import LocalFlavorTestCase
 5
 6
 7class JPLocalFlavorTests(LocalFlavorTestCase):
 8    def test_JPPrefectureSelect(self):
 9        f = JPPrefectureSelect()
10        out = u'''<select name="prefecture">
11<option value="hokkaido">Hokkaido</option>
12<option value="aomori">Aomori</option>
13<option value="iwate">Iwate</option>
14<option value="miyagi">Miyagi</option>
15<option value="akita">Akita</option>
16<option value="yamagata">Yamagata</option>
17<option value="fukushima">Fukushima</option>
18<option value="ibaraki">Ibaraki</option>
19<option value="tochigi">Tochigi</option>
20<option value="gunma">Gunma</option>
21<option value="saitama">Saitama</option>
22<option value="chiba">Chiba</option>
23<option value="tokyo">Tokyo</option>
24<option value="kanagawa" selected="selected">Kanagawa</option>
25<option value="yamanashi">Yamanashi</option>
26<option value="nagano">Nagano</option>
27<option value="niigata">Niigata</option>
28<option value="toyama">Toyama</option>
29<option value="ishikawa">Ishikawa</option>
30<option value="fukui">Fukui</option>
31<option value="gifu">Gifu</option>
32<option value="shizuoka">Shizuoka</option>
33<option value="aichi">Aichi</option>
34<option value="mie">Mie</option>
35<option value="shiga">Shiga</option>
36<option value="kyoto">Kyoto</option>
37<option value="osaka">Osaka</option>
38<option value="hyogo">Hyogo</option>
39<option value="nara">Nara</option>
40<option value="wakayama">Wakayama</option>
41<option value="tottori">Tottori</option>
42<option value="shimane">Shimane</option>
43<option value="okayama">Okayama</option>
44<option value="hiroshima">Hiroshima</option>
45<option value="yamaguchi">Yamaguchi</option>
46<option value="tokushima">Tokushima</option>
47<option value="kagawa">Kagawa</option>
48<option value="ehime">Ehime</option>
49<option value="kochi">Kochi</option>
50<option value="fukuoka">Fukuoka</option>
51<option value="saga">Saga</option>
52<option value="nagasaki">Nagasaki</option>
53<option value="kumamoto">Kumamoto</option>
54<option value="oita">Oita</option>
55<option value="miyazaki">Miyazaki</option>
56<option value="kagoshima">Kagoshima</option>
57<option value="okinawa">Okinawa</option>
58</select>'''
59        self.assertEqual(f.render('prefecture', 'kanagawa'), out)
60
61    def test_JPPostalCodeField(self):
62        error_format = [u'Enter a postal code in the format XXXXXXX or XXX-XXXX.']
63        valid = {
64                '251-0032': '2510032',
65                '2510032': '2510032',
66        }
67        invalid = {
68                '2510-032': error_format,
69                '251a0032': error_format,
70                'a51-0032': error_format,
71                '25100321': error_format,
72        }
73        self.assertFieldOutput(JPPostalCodeField, valid, invalid)