예제 #1
0
 def test_calculate_checksum_exceptions_isbn13(self):
     test_cases = [
         [
             '0x4343',
             'Given ISBN string is invalid: length of 0x4343 is 6 - should be 12'
         ],
         [
             '0123-45678b1129',
             'Given ISBN string is invalid: length of 0123-45678b1129 is 15 - should be 12'
         ],
         [
             '01234567B122',
             'Given ISBN string is invalid: 01234567B122 should contain numbers only'
         ],
         [
             '01ABC129-123',
             'Given ISBN string is invalid: 01ABC129-123 should contain numbers only'
         ],
         [
             'xxxxxxxxxxx1',
             'Given ISBN string is invalid: xxxxxxxxxxx1 should contain numbers only'
         ],
     ]
     for string, expected_message in test_cases:
         with self.assertRaisesRegexp(isbn.IsbnError, expected_message):
             isbn.calculate_checksum_isbn13(string)
예제 #2
0
 def test_calculate_checksum_exceptions_isbn13(self):
     test_cases = [
         ['0x4343', 'Given ISBN string is invalid: length of 0x4343 is 6 - should be 12'],
         ['0123-45678b1129', 'Given ISBN string is invalid: length of 0123-45678b1129 is 15 - should be 12'],
         ['01234567B122', 'Given ISBN string is invalid: 01234567B122 should contain numbers only'],
         ['01ABC129-123', 'Given ISBN string is invalid: 01ABC129-123 should contain numbers only'],
         ['xxxxxxxxxxx1', 'Given ISBN string is invalid: xxxxxxxxxxx1 should contain numbers only'],
     ]
     for string, expected_message in test_cases:
         with self.assertRaisesRegexp(isbn.IsbnError, expected_message):
             isbn.calculate_checksum_isbn13(string)
예제 #3
0
 def test_calculate_checksum_isbn13(self):
     test_cases = [['978144052588', '9'], ['978006057879', '4'],
                   ['978007147703', '1'], ['978096426109', '9'],
                   ['978158270223', '0'], ['978147918672', '3'],
                   ['978078945728', '8']]
     for number, expected_checksum in test_cases:
         self.assertEqual(isbn.calculate_checksum_isbn13(number),
                          expected_checksum)
예제 #4
0
 def test_calculate_checksum_isbn13(self):
     test_cases = [
         ['978144052588', '9'],
         ['978006057879', '4'],
         ['978007147703', '1'],
         ['978096426109', '9'],
         ['978158270223', '0'],
         ['978147918672', '3'],
         ['978078945728', '8']
     ]
     for number, expected_checksum in test_cases:
         self.assertEqual(isbn.calculate_checksum_isbn13(number), expected_checksum)