-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabaseUnitTest.py
More file actions
executable file
·59 lines (46 loc) · 1.76 KB
/
Copy pathdatabaseUnitTest.py
File metadata and controls
executable file
·59 lines (46 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/python
# -*- coding: utf-8 -*-
import dbConnection as dbcon
import unittest
class TestTableFunctions(unittest.TestCase):
def setUp(self):
self.tableOneName = 'TestTableOne'
self.tableOneColumns = dict(ColumnOne='TEXT',ColumnTwo='INTEGER')
self.tableTwoName = 'TestTableTwo'
self.tableTwoColumns = ['ColumnOne', 'ColumnTwo']
def test_connection(self):
print 'Testing connection'
self.db = dbcon.Database('Test')
self.assertTrue(self.db.database, 'Test')
def test_create_table_dict(self):
print 'Testing creating a table using a dictionary'
self.test_connection()
self.db.createTable(self.tableOneName, self.tableOneColumns, [])
self.cur = dbcon.Database.getCursor(self.db)
self.assertTrue(dbcon.Database.tableExists(self.cur, self.tableOneName))
def test_create_table_list(self):
print 'Testing creating a table using a list'
self.test_connection()
self.db.createTable(self.tableTwoName, self.tableTwoColumns, [])
self.cur = dbcon.Database.getCursor(self.db)
self.assertTrue(dbcon.Database.tableExists(self.cur, self.tableTwoName))
def test_table_dict(self):
print 'Testing dictionary table'
self.test_connection()
self.db.selectFrom(self.tableOneName)
self.assertTrue(True)
def test_table_list(self):
print 'Testing list table'
self.test_connection()
self.db.selectFrom(self.tableTwoName)
self.assertTrue(True)
def tearDown(self):
print 'Testing dropping tables'
self.test_connection()
self.db.dropTable(self.tableOneName)
self.cur = dbcon.Database.getCursor(self.db)
self.assertFalse(dbcon.Database.tableExists(self.cur, self.tableOneName))
self.db.dropTable(self.tableTwoName)
self.assertFalse(dbcon.Database.tableExists(self.cur, self.tableTwoName))
if __name__ == '__main__':
unittest.main()