77 lines
3.0 KiB
Python
77 lines
3.0 KiB
Python
"""
|
|
tests/conftest.py — Shared pytest fixtures for both app factories.
|
|
"""
|
|
import pytest
|
|
from app.admin import create_admin_app
|
|
from app.tenant import create_tenant_app
|
|
from app.extensions import db as _db
|
|
from config import TestingConfig
|
|
|
|
|
|
def _seed_plans(db):
|
|
"""Insert the three base subscription plans. Called once per session."""
|
|
from app.models.platform import Plan
|
|
if Plan.query.count() > 0:
|
|
return
|
|
plans = [
|
|
Plan(name="Starter", price_monthly=29.00, max_staff=3, max_locations=1,
|
|
features_json={"pos": True, "appointments": True, "customers": True,
|
|
"services": True, "promotions": True,
|
|
"appointment_reminders": True, "customer_reviews": True,
|
|
"reconciliation": True, "basic_reports": True,
|
|
"inventory": False, "commission": False,
|
|
"full_reports": False, "multi_location": False,
|
|
"online_booking": False, "waitlist": False,
|
|
"marketing": False}),
|
|
Plan(name="Growth", price_monthly=59.00, max_staff=10, max_locations=3,
|
|
features_json={"pos": True, "appointments": True, "customers": True,
|
|
"services": True, "promotions": True,
|
|
"appointment_reminders": True, "customer_reviews": True,
|
|
"reconciliation": True, "basic_reports": True,
|
|
"inventory": True, "commission": True,
|
|
"full_reports": True, "multi_location": True,
|
|
"online_booking": True, "waitlist": True,
|
|
"marketing": False}),
|
|
Plan(name="Pro", price_monthly=99.00, max_staff=None, max_locations=None,
|
|
features_json={"pos": True, "appointments": True, "customers": True,
|
|
"services": True, "promotions": True,
|
|
"appointment_reminders": True, "customer_reviews": True,
|
|
"reconciliation": True, "basic_reports": True,
|
|
"inventory": True, "commission": True,
|
|
"full_reports": True, "multi_location": True,
|
|
"online_booking": True, "waitlist": True,
|
|
"marketing": True}),
|
|
]
|
|
db.session.add_all(plans)
|
|
db.session.commit()
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def admin_app():
|
|
app = create_admin_app(config_override=TestingConfig)
|
|
with app.app_context():
|
|
_db.create_all()
|
|
_seed_plans(_db)
|
|
yield app
|
|
_db.drop_all()
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def tenant_app():
|
|
app = create_tenant_app(config_override=TestingConfig)
|
|
with app.app_context():
|
|
_db.create_all()
|
|
_seed_plans(_db)
|
|
yield app
|
|
_db.drop_all()
|
|
|
|
|
|
@pytest.fixture
|
|
def admin_client(admin_app):
|
|
return admin_app.test_client()
|
|
|
|
|
|
@pytest.fixture
|
|
def tenant_client(tenant_app):
|
|
return tenant_app.test_client()
|