Пример #1
0
    def test_address2index_baddata(self):
        with self.assertRaises(ValueError) as e:
            address2index(address=1)
            self.assertEqual(e, 'Error - Address (1) must be a string.')

        with self.assertRaises(ValueError) as e:
            address2index('')
            self.assertEqual(e, 'Error - Address ('
                             ') cannot be an empty str.')

        with self.assertRaises(ValueError) as e:
            address2index('1')
            self.assertEqual(
                e,
                'Error - Incorrect address (1) entry. Address must be an alphanumeric '
                'where the starting character(s) are alpha characters a-z')

        with self.assertRaises(ValueError) as e:
            address2index('1A')
            self.assertEqual(
                e,
                'Error - Incorrect address (1A) entry. Address must be an alphanumeric '
                'where the starting character(s) are alpha characters a-z')

        with self.assertRaises(ValueError) as e:
            address2index('AA')
            self.assertEqual(
                e,
                'Error - Incorrect address (AA) entry. Address must be an alphanumeric '
                'where the trailing character(s) are numeric characters 1-9')
Пример #2
0
    def test_address2index(self):
        self.assertEqual(address2index('A1'), [1, 1])
        self.assertEqual(address2index('A1000'), [1000, 1])
        self.assertEqual(address2index('A1048576'), [1048576, 1])

        self.assertEqual(address2index('Z1'), [1, 26])
        self.assertEqual(address2index('AA1'), [1, 27])
        self.assertEqual(address2index('BA1'), [1, 53])
        self.assertEqual(address2index('YQ1'), [1, 667])
        self.assertEqual(address2index('AAA1'), [1, 703])
        self.assertEqual(address2index('PZD1'), [1, 11496])
        self.assertEqual(address2index('QGK1'), [1, 11685])
        self.assertEqual(address2index('XFD1'), [1, 16384])

        self.assertEqual(address2index('XFD1048576'), [1048576, 16384])