def test_close_connection(self):
     """
     Is the connection to the database closed?
     Author: Michael Huang
     """
     db = sqlcontrol.MyDatabase("unittest")
     query = db.close()
     self.assertTrue(query)
Beispiel #2
0
 def test_create_table(self):
     db = sqlcontrol.MyDatabase("unittest")
     db.create_database()
     query = db.query("""CREATE TABLE if not exists car (
             car_number INTEGER PRIMARY KEY auto_increment,
             carname VARCHAR(20));""")
     self.assertTrue(query)
     db.close()
 def test_database_connection(self):
     """
     Is the database connected?
     Author: Michael Huang
     """
     db = sqlcontrol.MyDatabase("unittest")
     self.assertIsNotNone(db.conn)
     db.close()
Beispiel #4
0
 def test_database_insert(self):
     db = sqlcontrol.MyDatabase("unittest")
     db.create_database()
     query = db.query("""CREATE TABLE if not exists car (
                     car_number INTEGER PRIMARY KEY auto_increment,
                     carname VARCHAR(20));""")
     query2 = db.query("""INSERT INTO car VALUES (null, "Frank")""")
     self.assertEqual(query, query2)
     db.close()
 def test_database_creation(self):
     """
     Is there a database specified to be created?
     Author: Michael Huang
     """
     db = sqlcontrol.MyDatabase("unittest")
     query = db.create_database()
     self.assertTrue(query)
     db.close()
 def test_validate_table(self):
     """
     Has the table actually been created and added?
     Author: Michael Huang
     """
     db = sqlcontrol.MyDatabase("unittest")
     db.create_database()
     query = db.validate_table("""CREATE TABLE if not exists car (
                             car_number INTEGER PRIMARY KEY auto_increment,
                             carname VARCHAR(20));""")
     query2 = True
     self.assertEqual(query, query2)
     db.close()
 def test_database_select(self):
     """
     Can you select data from a table in a database?
     Author: Michael Huang
     """
     db = sqlcontrol.MyDatabase("unittest")
     db.create_database()
     query = db.query("""CREATE TABLE if not exists car (
                     car_number INTEGER PRIMARY KEY auto_increment,
                     carname VARCHAR(20));""")
     query2 = db.query("""INSERT INTO car VALUES (null, "Frank")""")
     self.assertEqual(query, query2)
     query3 = db.query("""SELECT * FROM car""").size()
     query4 = 1
     self.assertEqual(query3, query4)
     db.close()
Beispiel #8
0
 def test_database_creation(self):
     db = sqlcontrol.MyDatabase("unittest")
     query = db.create_database()
     self.assertTrue(query)
     db.close()
Beispiel #9
0
 def test_close_connection(self):
     db = sqlcontrol.MyDatabase("unittest")
     query = db.close()
     self.assertTrue(query)
Beispiel #10
0
 def test_database_connection(self):
     db = sqlcontrol.MyDatabase("unittest")
     self.assertIsNotNone(db.conn)
     db.close()