40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
# 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()
|
|
|