Пример #1
0
 def test_michigan(self):
     dl_state = 'MI'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('L123456789012', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #2
0
 def test_massachusetts(self):
     dl_state = 'MA'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('s12345678', dl_state))
     self.assertTrue(is_valid('S12345678', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #3
0
 def test_minnesota(self):
     dl_state = 'MN'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('M123456789012', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #4
0
 def test_maryland(self):
     dl_state = 'MD'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('M123456789012', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #5
0
 def test_idaho(self):
     dl_state = 'ID'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('ab123456a', dl_state))
     self.assertTrue(is_valid('AB123456A', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('ab1234', dl_state))
Пример #6
0
 def test_idaho(self):
     dl_state = 'ID'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('ab123456a', dl_state))
     self.assertTrue(is_valid('AB123456A', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('ab1234', dl_state))
Пример #7
0
 def test_new_hampshire(self):
     dl_state = 'NH'
     self.assertFalse(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('a12345', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
     self.assertTrue(is_valid('12abc12345', dl_state))
     self.assertTrue(is_valid('12ABC12345', dl_state))
Пример #8
0
 def test_colorado(self):
     dl_state = 'CO'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('a123456', dl_state))
     self.assertTrue(is_valid('A123', dl_state))
     self.assertFalse(is_valid('Ab12345', dl_state))
Пример #9
0
 def test_new_jersey(self):
     dl_state = 'NJ'
     self.assertFalse(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('a12345678901234', dl_state))
     self.assertTrue(is_valid('N12345678901234', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #10
0
 def test_nebraska(self):
     dl_state = 'NE'
     self.assertTrue(is_valid('a123456', dl_state))
     self.assertTrue(is_valid('a123', dl_state))
     self.assertTrue(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
     self.assertFalse(is_valid('12345678a', dl_state))
Пример #11
0
 def test_colorado(self):
     dl_state = 'CO'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('a123456', dl_state))
     self.assertTrue(is_valid('A123', dl_state))
     self.assertFalse(is_valid('Ab12345', dl_state))
Пример #12
0
 def test_tennessee(self):
     dl_state = 'TN'
     self.assertTrue(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #13
0
 def test_tennessee(self):
     dl_state = 'TN'
     self.assertTrue(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #14
0
 def test_texas(self):
     dl_state = 'TX'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #15
0
 def test_south_carolina(self):
     dl_state = 'SC'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('1234567890', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #16
0
 def test_rhode_island(self):
     dl_state = 'RI'
     self.assertTrue(is_valid('1234567', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertTrue(is_valid('v123456', dl_state))
     self.assertTrue(is_valid('V123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #17
0
 def test_oregon(self):
     dl_state = 'OR'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('a123456', dl_state))
     self.assertTrue(is_valid('OR12345', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #18
0
 def test_utah(self):
     dl_state = 'UT'
     self.assertTrue(is_valid('1234', dl_state))
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #19
0
 def test_iowa(self):
     dl_state = 'IA'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
     self.assertTrue(is_valid('123ab1234', 'IA'))
     self.assertTrue(is_valid('123AB1234', 'IA'))
Пример #20
0
 def test_massachusetts(self):
     dl_state = 'MA'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('s12345678', dl_state))
     self.assertTrue(is_valid('S12345678', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #21
0
 def test_wisconsin(self):
     dl_state = 'WI'
     self.assertTrue(is_valid('a1234567890123', dl_state))
     self.assertTrue(is_valid('W1234567890123', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #22
0
 def test_west_virginia(self):
     dl_state = 'WV'
     self.assertTrue(is_valid('1234567', dl_state))
     self.assertFalse(is_valid('a12345', dl_state))
     self.assertFalse(is_valid('WV123456', dl_state))
     self.assertFalse(is_valid('a1234567', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #23
0
 def test_iowa(self):
     dl_state = 'IA'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
     self.assertTrue(is_valid('123ab1234', 'IA'))
     self.assertTrue(is_valid('123AB1234', 'IA'))
Пример #24
0
 def test_utah(self):
     dl_state = 'UT'
     self.assertTrue(is_valid('1234', dl_state))
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #25
0
 def test_oklahoma(self):
     dl_state = 'OK'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertTrue(is_valid('a123456789', dl_state))
     self.assertTrue(is_valid('O123456789', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #26
0
 def test_south_carolina(self):
     dl_state = 'SC'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('1234567890', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #27
0
 def test_oklahoma(self):
     dl_state = 'OK'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertTrue(is_valid('a123456789', dl_state))
     self.assertTrue(is_valid('O123456789', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #28
0
 def test_wisconsin(self):
     dl_state = 'WI'
     self.assertTrue(is_valid('a1234567890123', dl_state))
     self.assertTrue(is_valid('W1234567890123', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #29
0
 def test_texas(self):
     dl_state = 'TX'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #30
0
 def test_arizona(self):
     dl_state = 'AZ'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a12345678', dl_state))
     self.assertTrue(is_valid('A12345678', dl_state))
     self.assertFalse(is_valid('aB12345', dl_state))
     self.assertTrue(is_valid('123456789', dl_state))
Пример #31
0
 def test_maryland(self):
     dl_state = 'MD'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('M123456789012', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #32
0
 def test_montana(self):
     dl_state = 'MT'
     self.assertTrue(is_valid('abcdefghi', dl_state))
     self.assertTrue(is_valid('1234567890123', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #33
0
 def test_michigan(self):
     dl_state = 'MI'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('L123456789012', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #34
0
 def test_new_hampshire(self):
     dl_state = 'NH'
     self.assertFalse(is_valid('123456789', dl_state))
     self.assertFalse(is_valid('a12345', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
     self.assertTrue(is_valid('12abc12345', dl_state))
     self.assertTrue(is_valid('12ABC12345', dl_state))
Пример #35
0
 def test_new_jersey(self):
     dl_state = 'NJ'
     self.assertFalse(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('a12345678901234', dl_state))
     self.assertTrue(is_valid('N12345678901234', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #36
0
 def test_nebraska(self):
     dl_state = 'NE'
     self.assertTrue(is_valid('a123456', dl_state))
     self.assertTrue(is_valid('a123', dl_state))
     self.assertTrue(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
     self.assertFalse(is_valid('12345678a', dl_state))
Пример #37
0
 def test_oregon(self):
     dl_state = 'OR'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('a123456', dl_state))
     self.assertTrue(is_valid('OR12345', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #38
0
 def test_montana(self):
     dl_state = 'MT'
     self.assertTrue(is_valid('abcdefghi', dl_state))
     self.assertTrue(is_valid('1234567890123', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #39
0
 def test_rhode_island(self):
     dl_state = 'RI'
     self.assertTrue(is_valid('1234567', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertTrue(is_valid('v123456', dl_state))
     self.assertTrue(is_valid('V123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #40
0
 def test_minnesota(self):
     dl_state = 'MN'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('M123456789012', dl_state))
     self.assertFalse(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #41
0
 def test_arizona(self):
     dl_state = 'AZ'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a12345678', dl_state))
     self.assertTrue(is_valid('A12345678', dl_state))
     self.assertFalse(is_valid('aB12345', dl_state))
     self.assertTrue(is_valid('123456789', dl_state))
Пример #42
0
 def test_territories(self):
     for dl_state in OTHER_STATES:
         self.assertTrue(is_valid('1234567890', dl_state, True))
         self.assertTrue(is_valid('ab123', dl_state, True))
         self.assertTrue(is_valid('**--  ', dl_state, True))
         self.assertTrue(is_valid('.', dl_state, True))
         self.assertTrue(is_valid('icantbelieveijustwroteallthesetests',
                                  dl_state, True))
Пример #43
0
 def test_allow_territories(self):
     dl_num = "doesnt_matter"
     self.assertRaises(Exception, is_valid, dl_num, "AS", False)
     self.assertRaises(Exception, is_valid, dl_num, "FM", False)
     self.assertRaises(Exception, is_valid, dl_num, "AA", False)
     self.assertTrue(is_valid(dl_num, "AS", True))
     self.assertTrue(is_valid(dl_num, "FM", True))
     self.assertTrue(is_valid(dl_num, "AA", True))
Пример #44
0
 def test_allow_territories(self):
     dl_num = "doesnt_matter"
     self.assertRaises(Exception, is_valid, dl_num, "AS", False)
     self.assertRaises(Exception, is_valid, dl_num, "FM", False)
     self.assertRaises(Exception, is_valid, dl_num, "AA", False)
     self.assertTrue(is_valid(dl_num, "AS", True))
     self.assertTrue(is_valid(dl_num, "FM", True))
     self.assertTrue(is_valid(dl_num, "AA", True))
Пример #45
0
 def test_territories(self):
     for dl_state in OTHER_STATES:
         self.assertTrue(is_valid('1234567890', dl_state, True))
         self.assertTrue(is_valid('ab123', dl_state, True))
         self.assertTrue(is_valid('**--  ', dl_state, True))
         self.assertTrue(is_valid('.', dl_state, True))
         self.assertTrue(
             is_valid('icantbelieveijustwroteallthesetests', dl_state,
                      True))
Пример #46
0
 def test_west_virginia(self):
     dl_state = 'WV'
     self.assertTrue(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('F478888', dl_state))
     self.assertTrue(is_valid('A12345', dl_state))
     self.assertTrue(is_valid('c123456', dl_state))
     self.assertTrue(is_valid('zb12345', dl_state))
     self.assertTrue(is_valid('aZ123456', dl_state))
     self.assertFalse(is_valid('WV1234567', dl_state))
     self.assertFalse(is_valid('a1234567', dl_state))
     self.assertFalse(is_valid('12345', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #47
0
    def clean_license_id_number(self):
        
        state = self.cleaned_data.get('registered_state')
        license = self.cleaned_data.get('license_id_number')
        if not is_valid(license, state):

            raise forms.ValidationError("License # is not valid for registered state.")

        return license
Пример #48
0
    def test_missouri(self):
        dl_state = 'MO'
        self.assertTrue(is_valid('123456789', dl_state))
        self.assertTrue(is_valid('a12345678', dl_state))
        self.assertTrue(is_valid('a12345', dl_state))
        self.assertTrue(is_valid('A12345678', dl_state))
        self.assertTrue(is_valid('A123456', dl_state))

        self.assertFalse(is_valid('12345678ab', dl_state))
        self.assertFalse(is_valid('123456789a', dl_state))
        self.assertFalse(is_valid('ab1234567', dl_state))
Пример #49
0
    def test_missouri(self):
        dl_state = 'MO'
        self.assertTrue(is_valid('123456789', dl_state))
        self.assertTrue(is_valid('a12345678', dl_state))
        self.assertTrue(is_valid('a12345', dl_state))
        self.assertTrue(is_valid('A12345678', dl_state))
        self.assertTrue(is_valid('A123456', dl_state))

        self.assertFalse(is_valid('12345678ab', dl_state))
        self.assertFalse(is_valid('123456789a', dl_state))
        self.assertFalse(is_valid('ab1234567', dl_state))
Пример #50
0
 def test_nevada(self):
     dl_state = 'NV'
     self.assertFalse(is_valid('1234', dl_state))
     self.assertTrue(is_valid('1234567890', dl_state))
     self.assertTrue(is_valid('x12345678', dl_state))
     self.assertTrue(is_valid('X12345678', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
Пример #51
0
 def test_nevada(self):
     dl_state = 'NV'
     self.assertFalse(is_valid('1234', dl_state))
     self.assertTrue(is_valid('1234567890', dl_state))
     self.assertTrue(is_valid('x12345678', dl_state))
     self.assertTrue(is_valid('X12345678', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('a12345678', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
Пример #52
0
 def test_new_york(self):
     dl_state = 'NY'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('A123456789012345678', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
     self.assertFalse(is_valid('1234567890123456', dl_state))
     self.assertFalse(is_valid('a1234567', dl_state))
     self.assertFalse(is_valid('NEWaYORK', dl_state))
     self.assertFalse(is_valid('123456', dl_state))
Пример #53
0
 def test_washington(self):
     dl_state = 'WA'
     self.assertTrue(is_valid('abcdefg12345', dl_state))
     self.assertTrue(is_valid('ab*****123ab', dl_state))
     self.assertTrue(is_valid('WASH*AB12345', dl_state))
     self.assertTrue(is_valid('ab*INGT1234b', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('abcd123456789', dl_state))
Пример #54
0
 def test_washington(self):
     dl_state = 'WA'
     self.assertTrue(is_valid('abcdefg12345', dl_state))
     self.assertTrue(is_valid('ab*****123ab', dl_state))
     self.assertTrue(is_valid('WASH*AB12345', dl_state))
     self.assertTrue(is_valid('ab*INGT1234b', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('abcd123456789', dl_state))
Пример #55
0
 def test_new_york(self):
     dl_state = 'NY'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('A123456789012345678', dl_state))
     self.assertFalse(is_valid('12345678', dl_state))
     self.assertFalse(is_valid('1234567890123456', dl_state))
     self.assertFalse(is_valid('a1234567', dl_state))
     self.assertFalse(is_valid('NEWaYORK', dl_state))
     self.assertFalse(is_valid('123456', dl_state))
Пример #56
0
 def test_florida(self):
     dl_state = 'FL'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('C123456789012', dl_state))
     self.assertTrue(is_valid('a12', dl_state))
     self.assertTrue(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #57
0
 def test_virginia(self):
     dl_state = 'VA'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('a12345678', dl_state))
     self.assertTrue(is_valid('V12345678', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #58
0
 def test_florida(self):
     dl_state = 'FL'
     self.assertFalse(is_valid('1234567', dl_state))
     self.assertTrue(is_valid('a123456789012', dl_state))
     self.assertTrue(is_valid('C123456789012', dl_state))
     self.assertTrue(is_valid('a12', dl_state))
     self.assertTrue(is_valid('a1234567890', dl_state))
     self.assertFalse(is_valid('ab1234567', dl_state))
Пример #59
0
 def test_virginia(self):
     dl_state = 'VA'
     self.assertTrue(is_valid('123456789', dl_state))
     self.assertTrue(is_valid('a12345678', dl_state))
     self.assertTrue(is_valid('V12345678', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))
Пример #60
0
 def test_vermont(self):
     dl_state = 'VT'
     self.assertTrue(is_valid('12345678', dl_state))
     self.assertTrue(is_valid('1234567a', dl_state))
     self.assertTrue(is_valid('1234567A', dl_state))
     self.assertFalse(is_valid('ab123', dl_state))
     self.assertFalse(is_valid('a123456', dl_state))
     self.assertFalse(is_valid('1234567890123', dl_state))