# -*- 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): ... ValidationError: [u'Ensure this value has at least 10 characters (it has 9).'] >>> f.clean('230880343234') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at most 11 characters (it has 12).'] >>> 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): ... ValidationError: [u'Ensure this value has at least 7 characters (it has 6).'] >>> f.clean('123456555') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at most 8 characters (it has 9).'] >>> f.clean('abcdefg') Traceback (most recent call last): ValidationError: [u'Enter a valid value.'] >>> f.clean(' 1234567 ') Traceback (most recent call last): ... ValidationError: [u'Ensure this value has at most 8 characters (it has 9).'] >>> 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'' """