the_works/tests/conftest.py

39 lines
702 B
Python

import pytest
from the_works import create_app
from the_works.database import db as _db
TEST_DATABASE_URI = "sqlite:///:memory:"
@pytest.fixture()
def _app():
test_config = {
"ENV": "Testing",
"SQLALCHEMY_DATABASE_URI": TEST_DATABASE_URI,
"SECRET_KEY": "This is my very secret key",
"TESTING": True
}
_app = create_app(test_config)
# other setup can go here
yield _app
# clean up / reset resources here
@pytest.fixture(scope="function")
def db(_app):
with _app.app_context():
yield _db
_db.drop_all()
_db.create_all()
@pytest.fixture()
def client(_app):
return _app.test_client()
@pytest.fixture()
def runner(_app):
return _app.test_cli_runner()