# -*- coding: utf-8 -*- # Tests for the contrib/localflavor/ AR form fields. tests = r""" # ARProvinceField ############################################################# >>> from django.contrib.localflavor.ar.forms import ARProvinceSelect >>> f = ARProvinceSelect() >>> f.render('provincias', 'A') u'' # ARPostalCodeField ########################################################### >>> from django.contrib.localflavor.ar.forms import ARPostalCodeField >>> f = ARPostalCodeField() >>> f.clean('5000') u'5000' >>> f.clean('C1064AAB') u'C1064AAB' >>> f.clean('c1064AAB') u'C1064AAB' >>> f.clean('C1064aab') u'C1064AAB' >>> f.clean(u'4400') u'4400' >>> f.clean(u'C1064AAB') u'C1064AAB' >>> f.clean('C1064AABB') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at most 8 characters (it has 9).'] >>> f.clean('C1064AA') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean('C106AAB') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean('106AAB') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean('500') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at least 4 characters (it has 3).'] >>> f.clean('5PPP') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean(None) Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f.clean('') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f.clean(u'') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f = ARPostalCodeField(required=False) >>> f.clean('5000') u'5000' >>> f.clean('C1064AAB') u'C1064AAB' >>> f.clean('c1064AAB') u'C1064AAB' >>> f.clean('C1064aab') u'C1064AAB' >>> f.clean(u'4400') u'4400' >>> f.clean(u'C1064AAB') u'C1064AAB' >>> f.clean('C1064AABB') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at most 8 characters (it has 9).'] >>> f.clean('C1064AA') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean('C106AAB') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean('106AAB') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean('500') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at least 4 characters (it has 3).'] >>> f.clean('5PPP') Traceback (most recent call last): ... ValidationError: [u'Enter a postal code in the format NNNN or ANNNNAAA.'] >>> f.clean(None) u'' >>> f.clean('') u'' >>> f.clean(u'') u'' # ARDNIField ################################################################## >>> from django.contrib.localflavor.ar.forms import ARDNIField >>> f = ARDNIField() >>> f.clean('20123456') u'20123456' >>> f.clean('20.123.456') u'20123456' >>> f.clean('9123456') u'9123456' >>> f.clean('9.123.456') u'9123456' >>> f.clean(u'20123456') u'20123456' >>> f.clean(u'20.123.456') u'20123456' >>> f.clean('20.123456') u'20123456' >>> f.clean('101234566') Traceback (most recent call last): ... ValidationError: [u'This field requires 7 or 8 digits.'] >>> f.clean('W0123456') Traceback (most recent call last): ... ValidationError: [u'This field requires only numbers.'] >>> f.clean('10,123,456') Traceback (most recent call last): ... ValidationError: [u'This field requires only numbers.'] >>> f.clean(None) Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f.clean('') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f.clean(u'') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f = ARDNIField(required=False) >>> f.clean('20123456') u'20123456' >>> f.clean('20.123.456') u'20123456' >>> f.clean('9123456') u'9123456' >>> f.clean('9.123.456') u'9123456' >>> f.clean(u'20123456') u'20123456' >>> f.clean(u'20.123.456') u'20123456' >>> f.clean('20.123456') u'20123456' >>> f.clean('101234566') Traceback (most recent call last): ... ValidationError: [u'This field requires 7 or 8 digits.'] >>> f.clean('W0123456') Traceback (most recent call last): ... ValidationError: [u'This field requires only numbers.'] >>> f.clean('10,123,456') Traceback (most recent call last): ... ValidationError: [u'This field requires only numbers.'] >>> f.clean(None) u'' >>> f.clean('') u'' >>> f.clean(u'') u'' # ARCUITField ################################################################# >>> from django.contrib.localflavor.ar.forms import ARCUITField >>> f = ARCUITField() >>> f.clean('20-10123456-9') u'20-10123456-9' >>> f.clean(u'20-10123456-9') u'20-10123456-9' >>> f.clean('27-10345678-4') u'27-10345678-4' >>> f.clean('20101234569') u'20-10123456-9' >>> f.clean('27103456784') u'27-10345678-4' >>> f.clean('2-10123456-9') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('210123456-9') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('20-10123456') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('20-10123456-') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('20-10123456-5') Traceback (most recent call last): ... ValidationError: [u'Invalid CUIT.'] >>> f.clean(u'2-10123456-9') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('27-10345678-1') Traceback (most recent call last): ... ValidationError: [u'Invalid CUIT.'] >>> f.clean(u'27-10345678-1') Traceback (most recent call last): ... ValidationError: [u'Invalid CUIT.'] >>> f.clean(None) Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f.clean('') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f.clean(u'') Traceback (most recent call last): ... ValidationError: [u'This field is required.'] >>> f = ARCUITField(required=False) >>> f.clean('20-10123456-9') u'20-10123456-9' >>> f.clean(u'20-10123456-9') u'20-10123456-9' >>> f.clean('27-10345678-4') u'27-10345678-4' >>> f.clean('20101234569') u'20-10123456-9' >>> f.clean('27103456784') u'27-10345678-4' >>> f.clean('2-10123456-9') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('210123456-9') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('20-10123456') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('20-10123456-') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('20-10123456-5') Traceback (most recent call last): ... ValidationError: [u'Invalid CUIT.'] >>> f.clean(u'2-10123456-9') Traceback (most recent call last): ... ValidationError: [u'Enter a valid CUIT in XX-XXXXXXXX-X or XXXXXXXXXXXX format.'] >>> f.clean('27-10345678-1') Traceback (most recent call last): ... ValidationError: [u'Invalid CUIT.'] >>> f.clean(u'27-10345678-1') Traceback (most recent call last): ... ValidationError: [u'Invalid CUIT.'] >>> f.clean(None) u'' >>> f.clean('') u'' >>> f.clean(u'') u'' """