feat: add full project - backend, frontend, docker, specs and configs
This commit is contained in:
parent
b77c7d5a01
commit
e6cb06255b
24489 changed files with 61341 additions and 36 deletions
34
backend/tests/conftest.py
Normal file
34
backend/tests/conftest.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import pytest
|
||||
|
||||
from app import create_app
|
||||
from app.extensions import db as _db
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def app():
|
||||
"""Create application for testing."""
|
||||
flask_app = create_app("testing")
|
||||
flask_app.config["TESTING"] = True
|
||||
|
||||
with flask_app.app_context():
|
||||
_db.create_all()
|
||||
yield flask_app
|
||||
_db.drop_all()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def db(app):
|
||||
"""Provide a clean database for each test."""
|
||||
with app.app_context():
|
||||
yield _db
|
||||
_db.session.rollback()
|
||||
# Clean all tables
|
||||
for table in reversed(_db.metadata.sorted_tables):
|
||||
_db.session.execute(table.delete())
|
||||
_db.session.commit()
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def client(app, db):
|
||||
"""Create test client."""
|
||||
return app.test_client()
|
||||
Loading…
Add table
Add a link
Reference in a new issue