示例#1
0
 def test_calculate_checksum_exceptions_isbn10(self):
     test_cases = [
         [
             '0x4343',
             'Given ISBN string is invalid: length of 0x4343 is 6 - should be 9'
         ],
         [
             '0123-45678b',
             'Given ISBN string is invalid: length of 0123-45678b is 11 - should be 9'
         ],
         [
             '01234567B',
             'Given ISBN string is invalid: 01234567B should contain numbers only'
         ],
         [
             '01ABC129-',
             'Given ISBN string is invalid: 01ABC129- should contain numbers only'
         ],
         [
             'xxxxxxxx1',
             'Given ISBN string is invalid: xxxxxxxx1 should contain numbers only'
         ],
     ]
     for string, expected_message in test_cases:
         with self.assertRaisesRegexp(isbn.IsbnError, expected_message):
             isbn.calculate_checksum_isbn10(string)
示例#2
0
 def test_calculate_checksum_exceptions_isbn10(self):
     test_cases = [
         ['0x4343', 'Given ISBN string is invalid: length of 0x4343 is 6 - should be 9'],
         ['0123-45678b', 'Given ISBN string is invalid: length of 0123-45678b is 11 - should be 9'],
         ['01234567B', 'Given ISBN string is invalid: 01234567B should contain numbers only'],
         ['01ABC129-', 'Given ISBN string is invalid: 01ABC129- should contain numbers only'],
         ['xxxxxxxx1', 'Given ISBN string is invalid: xxxxxxxx1 should contain numbers only'],
     ]
     for string, expected_message in test_cases:
         with self.assertRaisesRegexp(isbn.IsbnError, expected_message):
             isbn.calculate_checksum_isbn10(string)
示例#3
0
 def test_calculate_checksum_isbn10(self):
     test_cases = [['006224012', '9'], ['037602067',
                                        '9'], ['155652998', '8'],
                   ['087348754', '0'], ['037353461',
                                        '2'], ['159486758', '5'],
                   ['089042556', '6'], ['193912400', 'X']]
     for number, expected_checksum in test_cases:
         self.assertEqual(isbn.calculate_checksum_isbn10(number),
                          expected_checksum)
示例#4
0
 def test_calculate_checksum_isbn10(self):
     test_cases = [
         ['006224012', '9'],
         ['037602067', '9'],
         ['155652998', '8'],
         ['087348754', '0'],
         ['037353461', '2'],
         ['159486758', '5'],
         ['089042556', '6'],
         ['193912400', 'X']
     ]
     for number, expected_checksum in test_cases:
         self.assertEqual(isbn.calculate_checksum_isbn10(number), expected_checksum)