Ticket #7763: ro_localflavor_tests.patch

File ro_localflavor_tests.patch, 7.2 KB (added by Mihai Damian, 16 years ago)

regression tests

  • forms/localflavor/ro.py

     
     1# -*- coding: utf-8 -*-
     2# Tests for the contrib/localflavor/ RO form fields.
     3
     4tests = r"""
     5>>> from django.contrib.localflavor.ro.forms import *
     6
     7##ROCIFField ################################################################
     8
     9f = ROCIFField()
     10f.clean('21694681')
     11u'21694681'
     12f.clean('RO21694681')
     13u'21694681'
     14f.clean('21694680')
     15Traceback (most recent call last):
     16...
     17ValidationError: [u'Enter a valid CIF']
     18f.clean('21694680000')
     19Traceback (most recent call last):
     20...
     21ValidationError: [u'Ensure this value has at most 10 characters (it has 11).']
     22f.clean('0')
     23Traceback (most recent call last):
     24...
     25ValidationError: [u'Ensure this value has at least 2 characters (it has 1).']
     26f.clean(None)
     27Traceback (most recent call last):
     28...
     29ValidationError: [u'This field is required.']
     30f.clean('')
     31Traceback (most recent call last):
     32...
     33ValidationError: [u'This field is required.']
     34
     35##ROCNPField #################################################################
     36
     37f = ROCNPField()
     38f.clean('1981211204489')
     39u'1981211204489'
     40f.clean('1981211204487')
     41Traceback (most recent call last):
     42...
     43ValidationError: [u'Enter a valid CNP']
     44f.clean('1981232204489')
     45Traceback (most recent call last):
     46...
     47ValidationError: [u'Enter a valid CNP']
     48f.clean('9981211204489')
     49Traceback (most recent call last):
     50...
     51ValidationError: [u'Enter a valid CNP']
     52f.clean('9981211209')
     53Traceback (most recent call last):
     54...
     55ValidationError: [u'Ensure this value has at least 13 characters (it has 10).']
     56f.clean('19812112044891')
     57Traceback (most recent call last):
     58...
     59ValidationError: [u'Ensure this value has at most 13 characters (it has 14).']
     60f.clean('')
     61Traceback (most recent call last):
     62...
     63ValidationError: [u'This field is required.']
     64
     65##ROCountyField ##############################################################
     66
     67f = ROCountyField()
     68f.clean('CJ')
     69'CJ'
     70f.clean('cj')
     71'CJ'
     72f.clean('Argeş')
     73'AG'
     74f.clean('argeş')
     75'AG'
     76f.clean('Arges')
     77Traceback (most recent call last):
     78...
     79ValidationError: [u'Enter a Romanian county code or name.']
     80f.clean('')
     81Traceback (most recent call last):
     82...
     83ValidationError: [u'This field is required.']
     84
     85##ROCountySelect #############################################################
     86
     87f = ROCountySelect()
     88f.render('county','CJ')
     89u'<select name="county">\n<option value="AB">Alba</option>\n<option value="AR">A
     90rad</option>\n<option value="AG">Arge\u015f</option>\n<option value="BC">Bac\u01
     9103u</option>\n<option value="BH">Bihor</option>\n<option value="BN">Bistri\u0163
     92a-N\u0103s\u0103ud</option>\n<option value="BT">Boto\u015fani</option>\n<option
     93value="BV">Bra\u015fov</option>\n<option value="BR">Br\u0103ila</option>\n<optio
     94n value="B">Bucure\u015fti</option>\n<option value="BZ">Buz\u0103u</option>\n<op
     95tion value="CS">Cara\u015f-Severin</option>\n<option value="CL">C\u0103l\u0103ra
     96\u015fi</option>\n<option value="CJ" selected="selected">Cluj</option>\n<option
     97value="CT">Constan\u0163a</option>\n<option value="CV">Covasna</option>\n<option
     98 value="DB">D\xe2mbovi\u0163a</option>\n<option value="DJ">Dolj</option>\n<optio
     99n value="GL">Gala\u0163i</option>\n<option value="GR">Giurgiu</option>\n<option
     100value="GJ">Gorj</option>\n<option value="HR">Harghita</option>\n<option value="H
     101D">Hunedoara</option>\n<option value="IL">Ialomi\u0163a</option>\n<option value=
     102"IS">Ia\u015fi</option>\n<option value="IF">Ilfov</option>\n<option value="MM">M
     103aramure\u015f</option>\n<option value="MH">Mehedin\u0163i</option>\n<option valu
     104e="MS">Mure\u015f</option>\n<option value="NT">Neam\u0163</option>\n<option valu
     105e="OT">Olt</option>\n<option value="PH">Prahova</option>\n<option value="SM">Sat
     106u Mare</option>\n<option value="SJ">S\u0103laj</option>\n<option value="SB">Sibi
     107u</option>\n<option value="SV">Suceava</option>\n<option value="TR">Teleorman</o
     108ption>\n<option value="TM">Timi\u015f</option>\n<option value="TL">Tulcea</optio
     109n>\n<option value="VS">Vaslui</option>\n<option value="VL">V\xe2lcea</option>\n<
     110option value="VN">Vrancea</option>\n</select>'
     111
     112##ROIBANField #################################################################
     113
     114f = ROIBANField()
     115f.clean('RO56RZBR0000060003291177')
     116u'RO56RZBR0000060003291177'
     117f.clean('RO56RZBR0000060003291176')
     118Traceback (most recent call last):
     119...
     120ValidationError: [u'Enter a valid IBAN in ROXX-XXXX-XXXX-XXXX-XXXX-XXXX format']
     121
     122f.clean('RO56-RZBR-0000-0600-0329-1177')
     123u'RO56RZBR0000060003291177'
     124f.clean('AT61 1904 3002 3457 3201')
     125Traceback (most recent call last):
     126...
     127ValidationError: [u'Enter a valid IBAN in ROXX-XXXX-XXXX-XXXX-XXXX-XXXX format']
     128
     129f.clean('RO56RZBR000006000329117')
     130Traceback (most recent call last):
     131...
     132ValidationError: [u'Ensure this value has at least 24 characters (it has 23).']
     133f.clean('')
     134Traceback (most recent call last):
     135...
     136ValidationError: [u'This field is required.']
     137
     138##ROPhoneNumberField ##########################################################
     139
     140f = ROPhoneNumberField()
     141f.clean('0264485936')
     142u'0264485936'
     143f.clean('(0264)-485936')
     144u'0264485936'
     145f.clean('02644859368')
     146Traceback (most recent call last):
     147...
     148ValidationError: [u'Phone numbers must be in XXXX-XXXXXX format.']
     149f.clean('026448593')
     150Traceback (most recent call last):
     151...
     152ValidationError: [u'Ensure this value has at least 10 characters (it has 9).']
     153f.clean(None)
     154Traceback (most recent call last):
     155...
     156ValidationError: [u'This field is required.']
     157
     158##ROPostalCodeField ###########################################################
     159
     160f = ROPostalCodeField()
     161f.clean('400473')
     162u'400473'
     163f.clean('40047')
     164Traceback (most recent call last):
     165...
     166ValidationError: [u'Ensure this value has at least 6 characters (it has 5).']
     167f.clean('4004731')
     168Traceback (most recent call last):
     169...
     170ValidationError: [u'Ensure this value has at most 6 characters (it has 7).']
     171f.clean('')
     172Traceback (most recent call last):
     173...
     174ValidationError: [u'This field is required.']
     175"""
  • forms/tests.py

     
    1919from localflavor.jp import tests as localflavor_jp_tests
    2020from localflavor.nl import tests as localflavor_nl_tests
    2121from localflavor.pl import tests as localflavor_pl_tests
     22from localflavor.ro import tests as localflavor_ro_tests
    2223from localflavor.sk import tests as localflavor_sk_tests
    2324from localflavor.uk import tests as localflavor_uk_tests
    2425from localflavor.us import tests as localflavor_us_tests
     
    4849    'localflavor_jp_tests': localflavor_jp_tests,
    4950    'localflavor_nl_tests': localflavor_nl_tests,
    5051    'localflavor_pl_tests': localflavor_pl_tests,
     52    'localflavor_ro_tests': localflavor_ro_tests,
    5153    'localflavor_sk_tests': localflavor_sk_tests,
    5254    'localflavor_uk_tests': localflavor_uk_tests,
    5355    'localflavor_us_tests': localflavor_us_tests,
Back to Top