Flask API backend for ESP32 sensor fleet: - App factory pattern with blueprints - SQLAlchemy 2.x models (Sensor, Device, Sighting, Alert, Event, Probe) - UDP collector for sensor data streams - REST API endpoints for sensors, devices, alerts, events, probes, stats - pytest setup with fixtures - Containerfile for podman deployment - Makefile for common tasks
29 lines
559 B
Python
29 lines
559 B
Python
"""Pytest fixtures."""
|
|
import pytest
|
|
from esp32_web import create_app
|
|
from esp32_web.extensions import db
|
|
from esp32_web.config import TestConfig
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
"""Create test application."""
|
|
app = create_app(TestConfig)
|
|
with app.app_context():
|
|
db.create_all()
|
|
yield app
|
|
db.drop_all()
|
|
|
|
|
|
@pytest.fixture
|
|
def client(app):
|
|
"""Create test client."""
|
|
return app.test_client()
|
|
|
|
|
|
@pytest.fixture
|
|
def db_session(app):
|
|
"""Database session for tests."""
|
|
with app.app_context():
|
|
yield db.session
|