v1
This commit is contained in:
27
tests/test_api.py
Normal file
27
tests/test_api.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import sqlite3
|
||||
import importlib
|
||||
|
||||
import pytest
|
||||
|
||||
server_app_module = importlib.import_module("server.app")
|
||||
|
||||
# Expose app and init_db from the imported module
|
||||
app = server_app_module.app
|
||||
init_db = server_app_module.init_db
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def setup_tmp_db(tmp_path, monkeypatch):
|
||||
tmp_db = tmp_path / "forms.db"
|
||||
# Patch the module attribute directly to avoid package name collisions
|
||||
monkeypatch.setattr(server_app_module, "DB_PATH", tmp_db, raising=False)
|
||||
monkeypatch.setattr("server.settings.ADMIN_USERNAME", "admin")
|
||||
monkeypatch.setattr("server.settings.ADMIN_PASSWORD", "admin")
|
||||
init_db()
|
||||
yield
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
with app.test_client() as client:
|
||||
yield client
|
||||
Reference in New Issue
Block a user