add unit testing module
This commit is contained in:
0
libraries/tests/__init__.py
Normal file
0
libraries/tests/__init__.py
Normal file
30
libraries/tests/db.py
Normal file
30
libraries/tests/db.py
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import unittest
|
||||
import os
|
||||
from entropy.client.interfaces import Client
|
||||
from entropy.db import LocalRepository
|
||||
|
||||
class LocalRepositoryTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.Client = Client(noclientdb = 2, indexing = False, xcache = False,
|
||||
repo_validation = False)
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
tearDown is run after each test
|
||||
"""
|
||||
pass
|
||||
|
||||
def test_db_creation(self):
|
||||
dbname = 'test_suite'
|
||||
mdb = self.Client.open_memory_database(dbname = dbname)
|
||||
self.assert_(isinstance(mdb,LocalRepository))
|
||||
self.assertEqual(dbname,mdb.dbname)
|
||||
self.assert_(mdb.doesTableExist('baseinfo'))
|
||||
self.assert_(mdb.doesTableExist('extrainfo'))
|
||||
mdb.closeDB()
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
15
libraries/tests/run
Executable file
15
libraries/tests/run
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/python2
|
||||
import sys
|
||||
import unittest
|
||||
sys.path.insert(0,'.')
|
||||
from tests import db
|
||||
|
||||
# Add to the list the module to test
|
||||
mods = [db]
|
||||
|
||||
tests = []
|
||||
for mod in mods:
|
||||
tests.append(unittest.TestLoader().loadTestsFromModule(mod))
|
||||
|
||||
unittest.TextTestRunner(verbosity = 1).run(unittest.TestSuite(tests))
|
||||
raise SystemExit(0)
|
||||
Reference in New Issue
Block a user