コード例 #1
0
    def test_database_tableexists(self):
        """ Makes sure that database.tableexists functions the same as the base sql.Table.tableexists function """
        ## Real table
        tablename = "testtable"
        ## This will fail automatically if table doesn't exist
        table = self.connection.gettable(tablename)
        self.assertEqual(self.connection.tableexists(tablename),
                         Table.tableexists(self.connection, tablename))

        ## Fake Table
        tablename = "notarealtable"
        self.assertRaises(ValueError, self.connection.gettable, tablename)
        self.assertEqual(self.connection.tableexists(tablename),
                         Table.tableexists(self.connection, tablename))
コード例 #2
0
ファイル: Connection.py プロジェクト: AdamantLife/alcustoms
 def tableexists(self,tablename):
     """ Tests that a table exists """
     if isinstance(tablename,(Table.Table,Table.TableConstructor)):
         tablename = tablename.fullname
     if not isinstance(tablename,str):
         raise ValueError("tablename must be a string or a table")
     return Table.tableexists(self,tablename)
コード例 #3
0
    def test_removetable(self):
        """ Tests that remove table can remove a table based on its table name """
        tablename = "testtable"
        ## This will fail if the table was not already created (thus rendering this test invalid)
        self.connection.gettable(tablename)

        self.connection.removetable(tablename)
        self.assertFalse(Table.tableexists(self.connection, tablename))
        self.assertRaisesRegex(ValueError, "Table .* does not exist",
                               self.connection.gettable, tablename)
コード例 #4
0
 def test_removetable_object(self):
     """ Tests that tables can be removed using Tables and Table Subclasses """
     for table in [
             self.connection.gettable("testtable"),
             self.connection.getadvancedtable("testtable")
     ]:
         with self.subTest(table=table):
             self.connection.removetable(table)
             self.assertFalse(Table.tableexists(self.connection, table))
             self.assertRaisesRegex(ValueError, "Table .* does not exist",
                                    self.connection.gettable, table)
コード例 #5
0
ファイル: test_sql.py プロジェクト: AdamantLife/alcustoms
 def test_tableexists_object(self):
     """ Tests that tableexists accepts Tables and Table Subclasses """
     for table in [self.connection.gettable("testtable"),
                   self.connection.getadvancedtable("testtable")]:
         self.assertTrue(Table.tableexists(self.connection,table))
コード例 #6
0
ファイル: test_sql.py プロジェクト: AdamantLife/alcustoms
 def test_tableexists(self):
     """ Tests that tableexists works as expected"""
     self.assertTrue(Table.tableexists(self.connection,"testtable"))
コード例 #7
0
 def test_remove(self):
     """ Tests that AdvancedTables can use their parents to remove themselves """
     table = self.connection.getadvancedtable("testtable")
     table.remove()
     self.assertFalse(Table.tableexists(self.connection,table),table)
     self.assertRaisesRegex(ValueError,"Table .* does not exist.",self.connection.gettable,table)