# -*- coding: utf-8 -*-
# Tests for the contrib/localflavor/ ID form fields.
tests = r"""
# IDPhoneNumberField ########################################################
>>> import warnings
>>> warnings.filterwarnings("ignore", category=RuntimeWarning, module='django.contrib.localflavor.id.id_choices')
>>> from django.contrib.localflavor.id.forms import IDPhoneNumberField
>>> f = IDPhoneNumberField(required=False)
>>> f.clean('')
u''
>>> f.clean('0812-3456789')
u'0812-3456789'
>>> f.clean('081234567890')
u'081234567890'
>>> f.clean('021 345 6789')
u'021 345 6789'
>>> f.clean('0213456789')
u'0213456789'
>>> f.clean('0123456789')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid phone number']
>>> f.clean('+62-21-3456789')
u'+62-21-3456789'
>>> f.clean('+62-021-3456789')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid phone number']
>>> f.clean('(021) 345 6789')
u'(021) 345 6789'
>>> f.clean('+62-021-3456789')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid phone number']
>>> f.clean('+62-0812-3456789')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid phone number']
>>> f.clean('0812345678901')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid phone number']
>>> f.clean('foo')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid phone number']
# IDPostCodeField ############################################################
>>> from django.contrib.localflavor.id.forms import IDPostCodeField
>>> f = IDPostCodeField(required=False)
>>> f.clean('')
u''
>>> f.clean('12340')
u'12340'
>>> f.clean('25412')
u'25412'
>>> f.clean(' 12340 ')
u'12340'
>>> f.clean('12 3 4 0')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid post code']
>>> f.clean('12345')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid post code']
>>> f.clean('10100')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid post code']
>>> f.clean('123456')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid post code']
>>> f.clean('foo')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid post code']
# IDNationalIdentityNumberField #########################################################
>>> from django.contrib.localflavor.id.forms import IDNationalIdentityNumberField
>>> f = IDNationalIdentityNumberField(required=False)
>>> f.clean('')
u''
>>> f.clean(' 12.3456.010178 3456 ')
u'12.3456.010178.3456'
>>> f.clean('1234560101783456')
u'12.3456.010178.3456'
>>> f.clean('12.3456.010101.3456')
u'12.3456.010101.3456'
>>> f.clean('12.3456.310278.3456')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid NIK/KTP number']
>>> f.clean('00.0000.010101.0000')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid NIK/KTP number']
>>> f.clean('1234567890123456')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid NIK/KTP number']
>>> f.clean('foo')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid NIK/KTP number']
# IDProvinceSelect ##########################################################
>>> from django.contrib.localflavor.id.forms import IDProvinceSelect
>>> s = IDProvinceSelect()
>>> s.render('provinces', 'LPG')
u''
# IDLicensePlatePrefixelect ########################################################################
>>> from django.contrib.localflavor.id.forms import IDLicensePlatePrefixSelect
>>> s = IDLicensePlatePrefixSelect()
>>> s.render('codes', 'BE')
u''
# IDLicensePlateField #######################################################################
>>> from django.contrib.localflavor.id.forms import IDLicensePlateField
>>> f = IDLicensePlateField(required=False)
>>> f.clean('')
u''
>>> f.clean(' b 1234 ab ')
u'B 1234 AB'
>>> f.clean('B 1234 ABC')
u'B 1234 ABC'
>>> f.clean('A 12')
u'A 12'
>>> f.clean('DK 12345 12')
u'DK 12345 12'
>>> f.clean('RI 10')
u'RI 10'
>>> f.clean('CD 12 12')
u'CD 12 12'
>>> f.clean('CD 10 12')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('CD 1234 12')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('RI 10 AB')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('B 12345 01')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('N 1234 12')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('A 12 XYZ')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('Q 1234 AB')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
>>> f.clean('foo')
Traceback (most recent call last):
...
ValidationError: [u'Enter a valid vehicle license plate number']
"""