summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJulien Phalip <jphalip@gmail.com>2012-04-09 17:25:02 +0000
committerJulien Phalip <jphalip@gmail.com>2012-04-09 17:25:02 +0000
commit6f7aa51b2c3fbcbbc76404cee3cbe511feabaf1f (patch)
tree58a647367f40898226421b4b7aaf165ef1b54f14 /tests
parent883c38c499d58ec1c8182933de88f7d1164387e3 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/localflavor/hk/__init__.py0
-rw-r--r--tests/regressiontests/localflavor/hk/forms.py11
-rw-r--r--tests/regressiontests/localflavor/hk/tests.py35
-rw-r--r--tests/regressiontests/localflavor/tests.py1
4 files changed, 47 insertions, 0 deletions
diff --git a/tests/regressiontests/localflavor/hk/__init__.py b/tests/regressiontests/localflavor/hk/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/regressiontests/localflavor/hk/__init__.py
diff --git a/tests/regressiontests/localflavor/hk/forms.py b/tests/regressiontests/localflavor/hk/forms.py
new file mode 100644
index 0000000000..a6233d4245
--- /dev/null
+++ b/tests/regressiontests/localflavor/hk/forms.py
@@ -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
diff --git a/tests/regressiontests/localflavor/hk/tests.py b/tests/regressiontests/localflavor/hk/tests.py
new file mode 100644
index 0000000000..ed5e623ee2
--- /dev/null
+++ b/tests/regressiontests/localflavor/hk/tests.py
@@ -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)
diff --git a/tests/regressiontests/localflavor/tests.py b/tests/regressiontests/localflavor/tests.py
index 0062a4f925..856e518bed 100644
--- a/tests/regressiontests/localflavor/tests.py
+++ b/tests/regressiontests/localflavor/tests.py
@@ -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