-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbtests.py
executable file
·33 lines (25 loc) · 984 Bytes
/
dbtests.py
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
__author__ = 'bernie'
from componentsmodule import dbconnect, getnextid, getid
import os
def test_dbconnect():
localcon = dbconnect(databasename='components1.db')
print 'Test for missing database.'
assert localcon is False, 'Database does exist'
localcon = dbconnect()
print 'Test for default database.'
assert localcon is not False, 'Default database does not exist'
localcon.close()
localcon = dbconnect(databasename='components1.db', readonly=False)
print 'Test empty database create.'
if not os.path.exists('components1.db'):
assert False, 'Unable to create database file.'
else:
localcon.close()
os.remove('components1.db')
con = dbconnect()
def test_getnextid():
print 'Testing getnextid.'
assert getnextid(con, 'components') > 0, 'getnextid failed on table components'
def test_getid():
print 'Testing getid.'
assert getid(con, 'Test Value', 'components') is not 'None', 'getid failed'