mirror of
https://github.com/django/django.git
synced 2024-12-25 10:35:48 +00:00
6f7aa51b2c
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17886 bcc190cf-cafb-0310-a4f2-bffc1f526a37
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
from __future__ import absolute_import
|
|
|
|
from django.contrib.localflavor.hk.forms import HKPhoneNumberField
|
|
from django.test import SimpleTestCase
|
|
|
|
|
|
class HKLocalFlavorTests(SimpleTestCase):
|
|
"""Tests for Hong Kong Local Flavors"""
|
|
|
|
def test_HKPhoneNumberField(self):
|
|
error_msgs = HKPhoneNumberField.default_error_messages
|
|
valid = {
|
|
'2111-1111': '2111-1111',
|
|
'3111 1111': '3111-1111',
|
|
'51111111': '5111-1111',
|
|
'852-6111-1111': '6111-1111',
|
|
'(+852) 8111-1111': '8111-1111',
|
|
'(+852) 9111-1111': '9111-1111',
|
|
'85291111111': '9111-1111',
|
|
}
|
|
invalid = {
|
|
'9991-1111': [error_msgs['disguise'], ],
|
|
'9921-1111': [error_msgs['disguise'], ],
|
|
'1121-1111': [error_msgs['disguise'], ],
|
|
'99987654': [error_msgs['disguise'], ],
|
|
'99287654': [error_msgs['disguise'], ],
|
|
'11287654': [error_msgs['disguise'], ],
|
|
'1': [error_msgs['invalid'], ],
|
|
'2111--1111': [error_msgs['invalid'], ],
|
|
'11111111': [error_msgs['prefix'], ],
|
|
'00000000': [error_msgs['prefix'], ],
|
|
'44444444': [error_msgs['prefix'], ],
|
|
'77777777': [error_msgs['prefix'], ],
|
|
}
|
|
self.assertFieldOutput(HKPhoneNumberField, valid, invalid)
|