1
0
mirror of https://github.com/django/django.git synced 2025-11-07 07:15:35 +00:00

Fixed #17864 -- Added Hong Kong localflavor. Thanks to mrkschan and Adrien Lemaire.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17886 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Julien Phalip
2012-04-09 17:25:02 +00:00
parent 883c38c499
commit 6f7aa51b2c
7 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
from __future__ import absolute_import
from django.forms import ModelForm
from .models import HKPlace
class HKPlaceForm(ModelForm):
class Meta:
model = HKPlace

View File

@@ -0,0 +1,35 @@
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)

View File

@@ -18,6 +18,7 @@ from .fi.tests import FILocalFlavorTests
from .fr.tests import FRLocalFlavorTests
from .gb.tests import GBLocalFlavorTests
from .generic.tests import GenericLocalFlavorTests
from .hk.tests import HKLocalFlavorTests
from .hr.tests import HRLocalFlavorTests
from .id.tests import IDLocalFlavorTests
from .ie.tests import IELocalFlavorTests