from django.contrib.localflavor.pl.forms import (PLProvinceSelect, PLCountySelect, PLPostalCodeField, PLNIPField, PLPESELField, PLNationalIDCardNumberField, PLREGONField) from utils import LocalFlavorTestCase class PLLocalFlavorTests(LocalFlavorTestCase): def test_PLProvinceSelect(self): f = PLProvinceSelect() out = u'''''' self.assertEqual(f.render('voivodeships', 'pomerania'), out) def test_PLCountrySelect(self): f = PLCountySelect() out = u'''''' self.assertEqual(f.render('administrativeunit', 'katowice'), out) def test_PLPostalCodeField(self): error_format = [u'Enter a postal code in the format XX-XXX.'] valid = { '41-403': '41-403', } invalid = { '43--434': error_format, } self.assertFieldOutput(PLPostalCodeField, valid, invalid) def test_PLNIPField(self): error_format = [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.'] error_checksum = [u'Wrong checksum for the Tax Number (NIP).'] valid = { '64-62-414-124': '6462414124', '646-241-41-24': '6462414124', } invalid = { '43-343-234-323': error_format, '646-241-41-23': error_checksum, } self.assertFieldOutput(PLNIPField, valid, invalid) def test_PLPESELField(self): error_checksum = [u'Wrong checksum for the National Identification Number.'] error_format = [u'National Identification Number consists of 11 digits.'] valid = { '80071610614': '80071610614', } invalid = { '80071610610': error_checksum, '80': error_format, '800716106AA': error_format, } self.assertFieldOutput(PLPESELField, valid, invalid) def test_PLNationalIDCardNumberField(self): error_checksum = [u'Wrong checksum for the National ID Card Number.'] error_format = [u'National ID Card Number consists of 3 letters and 6 digits.'] valid = { 'ABC123458': 'ABC123458', 'abc123458': 'ABC123458', } invalid = { 'ABC123457': error_checksum, 'abc123457': error_checksum, 'a12Aaaaaa': error_format, 'AA1234443': error_format, } self.assertFieldOutput(PLNationalIDCardNumberField, valid, invalid) def test_PLREGONField(self): error_checksum = [u'Wrong checksum for the National Business Register Number (REGON).'] error_format = [u'National Business Register Number (REGON) consists of 9 or 14 digits.'] valid = { '12345678512347': '12345678512347', '590096454': '590096454', } invalid = { '123456784': error_checksum, '12345678412342': error_checksum, '590096453': error_checksum, '590096': error_format, } self.assertFieldOutput(PLREGONField, valid, invalid)