diff --git a/scopes/tests/test_api.py b/scopes/tests/test_api.py index 1b2bef8..f626c15 100644 --- a/scopes/tests/test_api.py +++ b/scopes/tests/test_api.py @@ -2,8 +2,20 @@ """Tests for the fastapi- (and asyncio-) based stuff.""" -import sys -print('***', sys.path) +import os, sys +sys.path = [os.path.dirname(__file__)] + sys.path + +import config +from scopes.storage.db.postgres import StorageFactory +from scopes.storage import concept, folder, message, topic, tracking +import transaction + +config.dbengine = 'postgresql+psycopg' +config.dbname = 'testdb' +config.dbuser = 'testuser' +config.dbpassword = 'secret' +config.dbschema = 'testing' +config.storageFactory = StorageFactory(config) import pytest from fastapi.testclient import TestClient @@ -11,6 +23,16 @@ from httpx2 import ASGITransport, AsyncClient from scopes.api.main import app +def setup(): + storage = config.storageFactory(config.dbschema) + storage.dropTable('tracks') + tracks = storage.create(tracking.Container) + tr01 = tracking.Track('t01', 'john') + tr01.update(dict(activity='testing')) + trid01 = tracks.save(tr01) + transaction.commit() + return storage + def async_client(): return AsyncClient(transport=ASGITransport(app=app), base_url='http://test') @@ -20,6 +42,7 @@ def async_client(): #response = await clt.get('/') def test_root(): + storage = setup() with TestClient(app) as clt: response = clt.get('/') assert response.status_code == 200