storage testing, work in progress: use pytest, with postgres only
This commit is contained in:
parent
5df3e3fa41
commit
d8546b4a92
5 changed files with 52 additions and 7 deletions
|
|
@ -8,6 +8,5 @@ from scopes.storage.concept import Concept
|
||||||
|
|
||||||
class Task(Concept):
|
class Task(Concept):
|
||||||
|
|
||||||
headFields = ['name']
|
|
||||||
prefix = 'tsk'
|
prefix = 'tsk'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ class Settings(BaseSettings):
|
||||||
log_dateformat: str = '%Y-%m-%dT%H:%M:%S'
|
log_dateformat: str = '%Y-%m-%dT%H:%M:%S'
|
||||||
|
|
||||||
|
|
||||||
dbengine: str = 'sqlite'
|
dbengine: str = 'postgresql+psycopg'
|
||||||
dbname: str = 'var/test.db'
|
dbname: str = 'testdb'
|
||||||
dbuser: str | None = None
|
dbuser: str = 'testuser'
|
||||||
dbpassword: str | None = None
|
dbpassword: str = 'secret'
|
||||||
dbschema: str | None = None
|
dbschema: str = 'testing'
|
||||||
|
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import os, sys
|
||||||
sys.path = [os.path.dirname(__file__)] + sys.path
|
sys.path = [os.path.dirname(__file__)] + sys.path
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
from scopes.tests import tlib_storage
|
from scopes.tests import tlib_storage, tlib_web
|
||||||
|
|
||||||
from scopes.tests.util import setup_logging
|
from scopes.tests.util import setup_logging
|
||||||
from scopes.storage.db.postgres import StorageFactory
|
from scopes.storage.db.postgres import StorageFactory
|
||||||
|
|
@ -38,6 +38,12 @@ class Test(unittest.TestCase):
|
||||||
def test_005_message(self):
|
def test_005_message(self):
|
||||||
tlib_storage.test_message(self, config)
|
tlib_storage.test_message(self, config)
|
||||||
|
|
||||||
|
def test_013_web(self):
|
||||||
|
tlib_web.test_app(self, config)
|
||||||
|
tlib_web.test_auth(self, config)
|
||||||
|
tlib_web.test_user_data(self, config)
|
||||||
|
|
||||||
|
|
||||||
def test_suite():
|
def test_suite():
|
||||||
return unittest.TestSuite((
|
return unittest.TestSuite((
|
||||||
unittest.TestLoader().loadTestsFromTestCase(Test),
|
unittest.TestLoader().loadTestsFromTestCase(Test),
|
||||||
|
|
|
||||||
40
tests/test_storage.py
Normal file
40
tests/test_storage.py
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
# py-scopes: tests.test_storage
|
||||||
|
|
||||||
|
""" Tests for the (PostgreSQL) storage-related functionalities"""
|
||||||
|
|
||||||
|
from scopes import testing
|
||||||
|
import config
|
||||||
|
|
||||||
|
from datetime import datetime
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from scopes.api import main
|
||||||
|
from scopes.storage import concept, folder, message, topic, tracking
|
||||||
|
from scopes.util import keywords as k
|
||||||
|
|
||||||
|
# predefined keywords used as domain, action, class head values in messages
|
||||||
|
k('session system')
|
||||||
|
|
||||||
|
@pytest.fixture(scope='module')
|
||||||
|
def storage():
|
||||||
|
#storage = config.StorageFactory(config)(config.dbschema)
|
||||||
|
storage = main.storage()
|
||||||
|
storage.dropTable('tracks')
|
||||||
|
storage.dropTable('folders')
|
||||||
|
storage.dropTable('types')
|
||||||
|
storage.dropTable('preds')
|
||||||
|
storage.dropTable('rels')
|
||||||
|
storage.dropTable('topics')
|
||||||
|
storage.dropTable('messages')
|
||||||
|
storage.commit()
|
||||||
|
return storage
|
||||||
|
|
||||||
|
def test_tracking(storage, caplog):
|
||||||
|
tracks = storage.create(tracking.Container)
|
||||||
|
tr01 = tracking.Track('t01', 'john')
|
||||||
|
tr01.update(dict(activity='testing'))
|
||||||
|
assert tr01.head == {'taskId': 't01', 'userName': 'john'}
|
||||||
|
trid01 = tracks.save(tr01)
|
||||||
|
assert trid01 == 1
|
||||||
|
storage.commit()
|
||||||
|
|
||||||
Loading…
Add table
Reference in a new issue