# -*- coding: utf-8 -*- # Tests for the contrib/localflavor/ FR form fields. tests = r""" # FRZipCodeField ############################################################# FRZipCodeField validates that the data is a valid FR zipcode. >>> from django.contrib.localflavor.fr.forms import FRZipCodeField >>> f = FRZipCodeField() >>> f.clean('75001') u'75001' >>> f.clean('93200') u'93200' >>> f.clean('2A200') Traceback (most recent call last): ... ValidationError: [u'Enter a zip code in the format XXXXX.'] >>> f.clean('980001') Traceback (most recent call last): ... ValidationError: [u'Enter a zip code in the format XXXXX.'] >>> 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 = FRZipCodeField(required=False) >>> f.clean('75001') u'75001' >>> f.clean('93200') u'93200' >>> f.clean('2A200') Traceback (most recent call last): ... ValidationError: [u'Enter a zip code in the format XXXXX.'] >>> f.clean('980001') Traceback (most recent call last): ... ValidationError: [u'Enter a zip code in the format XXXXX.'] >>> f.clean(None) u'' >>> f.clean('') u'' # FRPhoneNumberField ########################################################## FRPhoneNumberField validates that the data is a valid french phone number. It's normalized to 0X XX XX XX XX format. Dots are valid too. >>> from django.contrib.localflavor.fr.forms import FRPhoneNumberField >>> f = FRPhoneNumberField() >>> f.clean('01 55 44 58 64') u'01 55 44 58 64' >>> f.clean('0155445864') u'01 55 44 58 64' >>> f.clean('01 5544 5864') u'01 55 44 58 64' >>> f.clean('01 55.44.58.64') u'01 55 44 58 64' >>> f.clean('01.55.44.58.64') u'01 55 44 58 64' >>> f.clean('01,55,44,58,64') Traceback (most recent call last): ... ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] >>> f.clean('555 015 544') Traceback (most recent call last): ... ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] >>> 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 = FRPhoneNumberField(required=False) >>> f.clean('01 55 44 58 64') u'01 55 44 58 64' >>> f.clean('0155445864') u'01 55 44 58 64' >>> f.clean('01 5544 5864') u'01 55 44 58 64' >>> f.clean('01 55.44.58.64') u'01 55 44 58 64' >>> f.clean('01.55.44.58.64') u'01 55 44 58 64' >>> f.clean('01,55,44,58,64') Traceback (most recent call last): ... ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] >>> f.clean('555 015 544') Traceback (most recent call last): ... ValidationError: [u'Phone numbers must be in 0X XX XX XX XX format.'] >>> f.clean(None) u'' >>> f.clean('') u'' # FRDepartmentSelect ############################################################### FRDepartmentSelect is a Select widget that uses a list of french departments including DOM TOM >>> from django.contrib.localflavor.fr.forms import FRDepartmentSelect >>> w = FRDepartmentSelect() >>> print w.render('dep', 'Paris') """