40 lines
930 B
Python
40 lines
930 B
Python
from pathlib import Path
|
|
from tempfile import TemporaryDirectory
|
|
|
|
import pytest
|
|
from grung.db import GrungDB
|
|
from tinydb.storages import MemoryStorage
|
|
|
|
import ttfrog.app
|
|
from ttfrog import schema
|
|
from ttfrog.bootstrap import bootstrap
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
with TemporaryDirectory() as path:
|
|
fixture_db = GrungDB.with_schema(schema, path=Path(path), storage=MemoryStorage)
|
|
ttfrog.app.load_config(defaults=None, IN_MEMORY_DB=1)
|
|
ttfrog.app.initialize(db=fixture_db, force=True)
|
|
ttfrog.app.web.config.update({"TESTING": True})
|
|
bootstrap()
|
|
yield ttfrog.app
|
|
ttfrog.app.db.truncate()
|
|
|
|
|
|
@pytest.fixture
|
|
def routes(app):
|
|
import ttfrog.web
|
|
|
|
return ttfrog.web
|
|
|
|
|
|
@pytest.fixture()
|
|
def client(routes):
|
|
return ttfrog.app.web.test_client()
|
|
|
|
|
|
def test_get(client, routes):
|
|
response = client.get(ttfrog.app.config.VIEW_URI)
|
|
assert response.status_code == 200
|