2007-09-19 23:40:47 +00:00
# -*- coding: utf-8 -*-
# Tests for the contrib/localflavor/ IS form fields.
tests = r """
## ISIdNumberField #############################################################
>> > from django . contrib . localflavor . is_ . forms import *
>> > f = ISIdNumberField ( )
>> > f . clean ( ' 2308803449 ' )
u ' 230880-3449 '
>> > f . clean ( ' 230880-3449 ' )
u ' 230880-3449 '
>> > f . clean ( ' 230880 3449 ' )
u ' 230880-3449 '
>> > f . clean ( ' 230880343 ' )
Traceback ( most recent call last ) :
. . .
2010-01-05 03:56:19 +00:00
ValidationError : [ u ' Ensure this value has at least 10 characters (it has 9). ' , u ' Enter a valid Icelandic identification number. The format is XXXXXX-XXXX. ' ]
2007-09-19 23:40:47 +00:00
>> > f . clean ( ' 230880343234 ' )
Traceback ( most recent call last ) :
. . .
2010-01-05 03:56:19 +00:00
ValidationError : [ u ' Ensure this value has at most 11 characters (it has 12). ' , u ' Enter a valid Icelandic identification number. The format is XXXXXX-XXXX. ' ]
2007-09-19 23:40:47 +00:00
>> > f . clean ( ' abcdefghijk ' )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' Enter a valid Icelandic identification number. The format is XXXXXX-XXXX. ' ]
>> > f . clean ( ' ' )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' This field is required. ' ]
>> > f . clean ( None )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' This field is required. ' ]
>> > f . clean ( ' 2308803439 ' )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' The Icelandic identification number is not valid. ' ]
>> > f . clean ( ' 2308803440 ' )
u ' 230880-3440 '
>> > f = ISIdNumberField ( required = False )
>> > f . clean ( None )
u ' '
>> > f . clean ( ' ' )
u ' '
## ISPhoneNumberField #############################################################
>> > from django . contrib . localflavor . is_ . forms import *
>> > f = ISPhoneNumberField ( )
>> > f . clean ( ' 1234567 ' )
u ' 1234567 '
>> > f . clean ( ' 123 4567 ' )
u ' 1234567 '
>> > f . clean ( ' 123-4567 ' )
u ' 1234567 '
>> > f . clean ( ' 123-456 ' )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' Enter a valid value. ' ]
>> > f . clean ( ' 123456 ' )
Traceback ( most recent call last ) :
. . .
2010-01-05 03:56:19 +00:00
ValidationError : [ u ' Ensure this value has at least 7 characters (it has 6). ' , u ' Enter a valid value. ' ]
2007-09-19 23:40:47 +00:00
>> > f . clean ( ' 123456555 ' )
Traceback ( most recent call last ) :
. . .
2010-01-05 03:56:19 +00:00
ValidationError : [ u ' Ensure this value has at most 8 characters (it has 9). ' , u ' Enter a valid value. ' ]
2007-09-19 23:40:47 +00:00
>> > f . clean ( ' abcdefg ' )
Traceback ( most recent call last ) :
ValidationError : [ u ' Enter a valid value. ' ]
>> > f . clean ( ' 1234567 ' )
Traceback ( most recent call last ) :
. . .
2010-01-05 03:56:19 +00:00
ValidationError : [ u ' Ensure this value has at most 8 characters (it has 9). ' , u ' Enter a valid value. ' ]
2007-09-19 23:40:47 +00:00
>> > f . clean ( ' 12367 ' )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' Enter a valid value. ' ]
>> > f . clean ( ' ' )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' This field is required. ' ]
>> > f . clean ( None )
Traceback ( most recent call last ) :
. . .
ValidationError : [ u ' This field is required. ' ]
>> > f = ISPhoneNumberField ( required = False )
>> > f . clean ( None )
u ' '
>> > f . clean ( ' ' )
u ' '
## ISPostalCodeSelect #############################################################
>> > from django . contrib . localflavor . is_ . forms import *
>> > f = ISPostalCodeSelect ( )
>> > f . render ( ' foo ' , ' bar ' )
u ' <select name= " foo " > \n <option value= " 101 " >101 Reykjav \xed k</option> \n <option value= " 103 " >103 Reykjav \xed k</option> \n <option value= " 104 " >104 Reykjav \xed k</option> \n <option value= " 105 " >105 Reykjav \xed k</option> \n <option value= " 107 " >107 Reykjav \xed k</option> \n <option value= " 108 " >108 Reykjav \xed k</option> \n <option value= " 109 " >109 Reykjav \xed k</option> \n <option value= " 110 " >110 Reykjav \xed k</option> \n <option value= " 111 " >111 Reykjav \xed k</option> \n <option value= " 112 " >112 Reykjav \xed k</option> \n <option value= " 113 " >113 Reykjav \xed k</option> \n <option value= " 116 " >116 Kjalarnes</option> \n <option value= " 121 " >121 Reykjav \xed k</option> \n <option value= " 123 " >123 Reykjav \xed k</option> \n <option value= " 124 " >124 Reykjav \xed k</option> \n <option value= " 125 " >125 Reykjav \xed k</option> \n <option value= " 127 " >127 Reykjav \xed k</option> \n <option value= " 128 " >128 Reykjav \xed k</option> \n <option value= " 129 " >129 Reykjav \xed k</option> \n <option value= " 130 " >130 Reykjav \xed k</option> \n <option value= " 132 " >132 Reykjav \xed k</option> \n <option value= " 150 " >150 Reykjav \xed k</option> \n <option value= " 155 " >155 Reykjav \xed k</option> \n <option value= " 170 " >170 Seltjarnarnes</option> \n <option value= " 172 " >172 Seltjarnarnes</option> \n <option value= " 190 " >190 Vogar</option> \n <option value= " 200 " >200 K \xf3 pavogur</option> \n <option value= " 201 " >201 K \xf3 pavogur</option> \n <option value= " 202 " >202 K \xf3 pavogur</option> \n <option value= " 203 " >203 K \xf3 pavogur</option> \n <option value= " 210 " >210 Gar \xf0 ab \xe6 r</option> \n <option value= " 212 " >212 Gar \xf0 ab \xe6 r</option> \n <option value= " 220 " >220 Hafnarfj \xf6 r \xf0 ur</option> \n <option value= " 221 " >221 Hafnarfj \xf6 r \xf0 ur</option> \n <option value= " 222 " >222 Hafnarfj \xf6 r \xf0 ur</option> \n <option value= " 225 " >225 \xc1 lftanes</option> \n <option value= " 230 " >230 Reykjanesb \xe6 r</option> \n <option value= " 232 " >232 Reykjanesb \xe6 r</option> \n <option value= " 233 " >233 Reykjanesb \xe6 r</option> \n <option value= " 235 " >235 Keflav \xed kurflugv \xf6 llur</option> \n <option value= " 240 " >240 Grindav \xed k</option> \n <option value= " 245 " >245 Sandger \xf0 i</option> \n <option value= " 250 " >250 Gar \xf0 ur</option> \n <option value= " 260 " >260 Reykjanesb \xe6 r</option> \n <option value= " 270 " >270 Mosfellsb \xe6 r</option> \n <option value= " 300 " >300 Akranes</option> \n <option value= " 301 " >301 Akranes</option> \n <option value= " 302 " >302 Akranes</option> \n <option value= " 310 " >310 Borgarnes</option> \n <option value= " 311 " >311 Borgarnes</option> \n <option value= " 320 " >320 Reykholt \xed Borgarfir \xf0 i</option> \n <option value= " 340 " >340 Stykkish \xf3 lmur</option> \n <option value= " 345 " >345 Flatey \xe1 Brei \xf0 afir \xf0 i</option> \n <option value= " 350 " >350 Grundarfj \xf6 r \xf0 ur</option> \n <option value= " 355 " >355 \xd3 lafsv \xed k</option> \n <option value= " 356 " >356 Sn \xe6 fellsb \xe6 r</option> \n <option value= " 360 " >360 Hellissandur</option> \n <option value= " 370 " >370 B \xfa \xf0 ardalur</option> \n <option value= " 371 " >371 B \xfa \xf0 ardalur</option> \n <option value= " 380 " >380 Reykh \xf3 lahreppur</option> \n <option value= " 400 " >400 \xcd safj \xf6 r \xf0 ur</option> \n <option value= " 401 " >401 \xcd safj \xf6 r \xf0 ur</option> \n <option value= " 410 " >410 Hn \xed fsdalur</option> \n <option value= " 415 " >415 Bolungarv \xed k</option> \n <option value= " 420 " >420 S \xfa \xf0 av \xed k</option> \n <option value= " 425 " >425 Flateyri</option> \n <option value= " 430 " >430 Su \xf0 ureyri</option> \n <option value= " 450 " >450 Patreksfj \xf6 r \xf0 ur</option> \n <option value= " 451 " >451 Patreksfj \xf6 r \xf0 ur</option> \n <option value= " 460 " >460 T \xe1 lknafj \xf6 r \xf0 ur</option> \n <option value= " 465 " >465 B \xed ldudalur</option> \n <option value= " 470 " >470 \xde ingeyri</option> \n <option value= " 471 " >471 \xde ingeyri</option> \n <option value= " 500 " >500 Sta \xf0 ur</option> \n <option value= " 510 " >510 H \xf3 lmav \xed k</option> \n <option value= " 512 " >512 H \xf3 lmav \xed k</option> \n <option value= " 520 " >520 Drangsnes</option> \n <option value= " 522 " >522 Kj \xf6 rvogur</option> \n <option value= " 523 " >523 B \xe6 r</option> \n <option value= " 524 " >524 Nor \xf0 urfj \xf6 r \xf0 ur</option> \n <option value= " 530 " >530 Hvammstangi</option> \n <option value= " 531 " >531 Hvammstangi</option> \n <option value= " 540 " >540 Bl \xf6 ndu \xf3 s</option> \n <option value= " 541 " >541 Bl \xf6 ndu \xf3 s</o
"""