always call test files explicitly: tests/standard (=sqlite) or tests/postgres
This commit is contained in:
parent
a4158e96d8
commit
23f9b1c384
5 changed files with 71 additions and 50 deletions
|
@ -8,16 +8,10 @@ server_port = '8999'
|
||||||
|
|
||||||
# storage settings
|
# storage settings
|
||||||
|
|
||||||
# PostgreSQL
|
|
||||||
#import scopes.storage.db.postgres
|
|
||||||
dbengine = 'postgresql+psycopg'
|
|
||||||
dbname = 'testdb'
|
|
||||||
dbuser = 'testuser'
|
|
||||||
dbpassword = 'secret'
|
|
||||||
dbschema = 'testing'
|
|
||||||
|
|
||||||
# SQLite
|
# SQLite
|
||||||
dbengine = 'sqlite'
|
dbengine = 'sqlite'
|
||||||
dbname = 'var/test.db'
|
dbname = 'var/test.db'
|
||||||
|
dbuser = None
|
||||||
|
dbpassword = None
|
||||||
dbschema = None
|
dbschema = None
|
||||||
|
|
||||||
|
|
33
tests/postgres.py
Normal file
33
tests/postgres.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#! /usr/bin/python
|
||||||
|
|
||||||
|
"""Tests for the 'scopes.storage' package - using PostgreSQL."""
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
# PostgreSQL-specific settings
|
||||||
|
import scopes.storage.db.postgres
|
||||||
|
import config
|
||||||
|
config.dbengine = 'postgresql+psycopg'
|
||||||
|
config.dbname = 'testdb'
|
||||||
|
config.dbuser = 'testuser'
|
||||||
|
config.dbpassword = 'secret'
|
||||||
|
config.dbschema = 'testing'
|
||||||
|
|
||||||
|
import tlib
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_001_tracking(self):
|
||||||
|
tlib.test_tracking(self)
|
||||||
|
|
||||||
|
def test_002_folder(self):
|
||||||
|
tlib.test_folder(self)
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
return unittest.TestSuite((
|
||||||
|
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||||
|
))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(defaultTest='suite')
|
24
tests/standard.py
Normal file
24
tests/standard.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#! /usr/bin/python
|
||||||
|
|
||||||
|
"""Tests for the 'scopes.storage' package."""
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
import tlib
|
||||||
|
|
||||||
|
class Test(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_001_tracking(self):
|
||||||
|
tlib.test_tracking(self)
|
||||||
|
|
||||||
|
def test_002_folder(self):
|
||||||
|
tlib.test_folder(self)
|
||||||
|
|
||||||
|
def suite():
|
||||||
|
return unittest.TestSuite((
|
||||||
|
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||||
|
))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main(defaultTest='suite')
|
|
@ -1,38 +0,0 @@
|
||||||
#! /usr/bin/python
|
|
||||||
|
|
||||||
"""Tests for the 'scopes.storage' package."""
|
|
||||||
|
|
||||||
import config
|
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
import scopes.storage.common
|
|
||||||
from scopes.storage.common import commit, Storage, getEngine, sessionFactory
|
|
||||||
#from scopes.storage import proxy
|
|
||||||
from scopes.storage import folder, tracking
|
|
||||||
|
|
||||||
engine = getEngine(config.dbengine, config.dbname, config.dbuser, config.dbpassword)
|
|
||||||
scopes.storage.common.engine = engine
|
|
||||||
scopes.storage.common.Session = sessionFactory(engine)
|
|
||||||
|
|
||||||
storage = Storage(schema=config.dbschema)
|
|
||||||
|
|
||||||
import tlib
|
|
||||||
|
|
||||||
class Test(unittest.TestCase):
|
|
||||||
"Basic tests for the cco.storage package."
|
|
||||||
|
|
||||||
def test_001_tracking(self):
|
|
||||||
tlib.test_tracking(self, storage)
|
|
||||||
|
|
||||||
def test_002_folder(self):
|
|
||||||
tlib.test_folder(self, storage)
|
|
||||||
|
|
||||||
def suite():
|
|
||||||
return unittest.TestSuite((
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase(Test),
|
|
||||||
))
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
unittest.main(defaultTest='suite')
|
|
|
@ -1,12 +1,20 @@
|
||||||
"""The real test implementations"""
|
"""The real test implementations"""
|
||||||
|
|
||||||
|
import config
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from scopes.storage import folder, tracking
|
from scopes.storage import folder, tracking
|
||||||
from scopes.storage.common import commit
|
|
||||||
|
import scopes.storage.common
|
||||||
|
from scopes.storage.common import commit, Storage, getEngine, sessionFactory
|
||||||
|
|
||||||
|
engine = getEngine(config.dbengine, config.dbname, config.dbuser, config.dbpassword)
|
||||||
|
scopes.storage.common.engine = engine
|
||||||
|
scopes.storage.common.Session = sessionFactory(engine)
|
||||||
|
|
||||||
|
storage = Storage(schema=config.dbschema)
|
||||||
|
|
||||||
|
|
||||||
def test_tracking(self, storage):
|
def test_tracking(self):
|
||||||
storage.dropTable('tracks')
|
storage.dropTable('tracks')
|
||||||
tracks = storage.create(tracking.Container)
|
tracks = storage.create(tracking.Container)
|
||||||
|
|
||||||
|
@ -55,7 +63,7 @@ def test_tracking(self, storage):
|
||||||
commit(storage.session)
|
commit(storage.session)
|
||||||
|
|
||||||
|
|
||||||
def test_folder(self, storage):
|
def test_folder(self):
|
||||||
storage.dropTable('folders')
|
storage.dropTable('folders')
|
||||||
root = folder.Root(storage)
|
root = folder.Root(storage)
|
||||||
self.assertEqual(list(root.keys()), [])
|
self.assertEqual(list(root.keys()), [])
|
||||||
|
|
Loading…
Add table
Reference in a new issue