コード例 #1
0
    def test_get_columns(self):
        self.cursor.execute('CREATE TABLE test1 ("A", "B")')
        columns = get_columns(self.cursor, 'test1')
        self.assertEqual(columns, ['A', 'B'])

        self.cursor.execute('CREATE TEMPORARY TABLE test2 ("C", "D")')
        columns = get_columns(self.cursor, 'test2')
        self.assertEqual(columns, ['C', 'D'])
コード例 #2
0
    def test_ordering_behavior(self):
        self.cursor.execute('CREATE TEMPORARY TABLE test_table ("A", "B")')
        alter_table(self.cursor, 'test_table', ['B', 'C', 'A', 'D'])

        # Columns A and B already exist in a specified order and
        # the new columns ('C' and 'D') are added in the order in
        # which they are encountered.
        columns = get_columns(self.cursor, 'test_table')
        self.assertEqual(columns, ['A', 'B', 'C', 'D'])
コード例 #3
0
    def test_existing_columns(self):
        self.cursor.execute('CREATE TEMPORARY TABLE test_table ("A", "B")')
        alter_table(self.cursor, 'test_table', ['A', 'B', 'C', 'D'])

        columns = get_columns(self.cursor, 'test_table')
        self.assertEqual(columns, ['A', 'B', 'C', 'D'])
コード例 #4
0
 def test_missing_table(self):
     with self.assertRaises(sqlite3.ProgrammingError):
         columns = get_columns(self.cursor, 'missing_table')