diff options
Diffstat (limited to 'tests/regressiontests')
| -rw-r--r-- | tests/regressiontests/localflavor/hk/__init__.py | 0 | ||||
| -rw-r--r-- | tests/regressiontests/localflavor/hk/forms.py | 11 | ||||
| -rw-r--r-- | tests/regressiontests/localflavor/hk/tests.py | 35 | ||||
| -rw-r--r-- | tests/regressiontests/localflavor/tests.py | 1 |
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 |
