35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""
|
|
tests/conftest.py — makes backend/'s modules importable from tests/ (no
|
|
package/__init__.py, matching CLAUDE.md's flat layout) and sets the env vars
|
|
app.py's create_app() reads at import time: a throwaway tenants.json (one
|
|
fake tenant, "test-tenant") so TenantRegistry has something to load without
|
|
touching the real tenants.json, and a throwaway SQLite path so tests never
|
|
touch a real state store.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
import sys
|
|
import tempfile
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
_tmp_dir = tempfile.mkdtemp()
|
|
|
|
_tenants_path = os.path.join(_tmp_dir, "tenants.json")
|
|
with open(_tenants_path, "w") as f:
|
|
json.dump(
|
|
{
|
|
"test-tenant": {
|
|
"frappe_api_url": "http://frappe.test",
|
|
"frappe_api_key": "test_key",
|
|
"frappe_api_secret": "test_secret",
|
|
"stripe_webhook_secret": "whsec_test",
|
|
}
|
|
},
|
|
f,
|
|
)
|
|
|
|
os.environ.setdefault("TENANTS_CONFIG_PATH", _tenants_path)
|
|
os.environ.setdefault("STATE_STORE_PATH", os.path.join(_tmp_dir, "test_state.db"))
|