Initial commit: Shop Database Flask Application
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>
This commit is contained in:
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Tests package."""
|
||||
51
tests/conftest.py
Normal file
51
tests/conftest.py
Normal file
@@ -0,0 +1,51 @@
|
||||
"""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()
|
||||
Reference in New Issue
Block a user