Flask backend with Vue 3 frontend for shop floor machine management. Includes database schema export for MySQL shopdb_flask database. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
52 lines
1.0 KiB
Python
52 lines
1.0 KiB
Python
"""Pytest configuration and fixtures."""
|
|
|
|
import pytest
|
|
from shopdb import create_app
|
|
from shopdb.extensions import db as _db
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def app():
|
|
"""Create application for testing."""
|
|
app = create_app('testing')
|
|
return app
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def db(app):
|
|
"""Create database for testing."""
|
|
with app.app_context():
|
|
_db.create_all()
|
|
yield _db
|
|
_db.drop_all()
|
|
|
|
|
|
@pytest.fixture(scope='function')
|
|
def session(db):
|
|
"""Create a new database session for a test."""
|
|
connection = db.engine.connect()
|
|
transaction = connection.begin()
|
|
|
|
options = dict(bind=connection, binds={})
|
|
session = db.create_scoped_session(options=options)
|
|
|
|
db.session = session
|
|
|
|
yield session
|
|
|
|
transaction.rollback()
|
|
connection.close()
|
|
session.remove()
|
|
|
|
|
|
@pytest.fixture
|
|
def client(app):
|
|
"""Create test client."""
|
|
return app.test_client()
|
|
|
|
|
|
@pytest.fixture
|
|
def runner(app):
|
|
"""Create CLI runner."""
|
|
return app.test_cli_runner()
|