11from django .test import SimpleTestCase
22
3- from localflavor .pl .forms import (PLCountySelect , PLNationalIDCardNumberField , PLNIPField , PLPESELField ,
4- PLPostalCodeField , PLProvinceSelect , PLREGONField )
3+ from localflavor .pl .forms import (
4+ PLCountySelect ,
5+ PLNationalIDCardNumberField ,
6+ PLNIPField ,
7+ PLPESELField ,
8+ PLPostalCodeField ,
9+ PLProvinceSelect ,
10+ PLREGONField ,
11+ )
512
613
714class PLLocalFlavorTests (SimpleTestCase ):
@@ -420,7 +427,9 @@ def test_PLPostalCodeField(self):
420427 self .assertFieldOutput (PLPostalCodeField , valid , invalid )
421428
422429 def test_PLNIPField (self ):
423- error_format = ['Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.' ]
430+ error_format = [
431+ 'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.'
432+ ]
424433 error_checksum = ['Wrong checksum for the Tax Number (NIP).' ]
425434 valid = {
426435 '646-241-41-24' : '6462414124' ,
@@ -437,7 +446,9 @@ def test_PLNIPField(self):
437446 def test_PLPESELField (self ):
438447 error_checksum = ['Wrong checksum for the National Identification Number.' ]
439448 error_format = ['National Identification Number consists of 11 digits.' ]
440- error_birthdate = ['The National Identification Number contains an invalid birth date.' ]
449+ error_birthdate = [
450+ 'The National Identification Number contains an invalid birth date.'
451+ ]
441452 valid = {
442453 '80071610614' : '80071610614' ,
443454 }
@@ -465,25 +476,34 @@ def test_PLNationalIDCardNumberField(self):
465476 self .assertFieldOutput (PLNationalIDCardNumberField , valid , invalid )
466477
467478 def test_PLREGONField (self ):
468- error_checksum = ['Wrong checksum for the National Business Register Number (REGON).' ]
469- error_format = ['National Business Register Number (REGON) consists of 9 or 14 digits.' ]
479+ VALID_LENGTHS = (9 , 14 )
480+
481+ error_checksum = [
482+ 'Wrong checksum for the National Business Register Number (REGON).'
483+ ]
484+ error_format = [
485+ 'National Business Register Number (REGON) consists of 9 or 14 digits.'
486+ ]
470487 valid = {
471488 '12345678512347' : '12345678512347' ,
472489 '590096454' : '590096454' ,
473-
474490 # A special case where the checksum == 10 and the control
475491 # digit == '0'
476492 '391023200' : '391023200' ,
493+ '00102110000342' : '00102110000342' ,
494+ # A special case where the 14 digits checksum == 10
495+ # but then 9 digits checksum is not required to be 0
496+ '00202110146340' : '00202110146340' ,
477497 }
478498 invalid = {
479499 '123456784' : error_checksum ,
480500 '12345678412342' : error_checksum ,
481501 '590096453' : error_checksum ,
482-
483502 # A special case where the checksum == 10,
484503 # but the control digit != '0'
485504 '111111111' : error_checksum ,
486-
487505 '590096' : error_format ,
506+ # 8, 10, 11, 12, 13, 15 digits
507+ ** {'1' * i : error_format for i in range (8 , 16 ) if i not in VALID_LENGTHS },
488508 }
489509 self .assertFieldOutput (PLREGONField , valid , invalid )
0 commit comments