refactor: form-core wiring, JWT sessions, slowapi, packaging, frontend rewrite, test declutter
This commit is contained in:
parent
06ab25fb47
commit
03af41e837
74 changed files with 6089 additions and 5183 deletions
|
|
@ -14,22 +14,24 @@ from app.flows.schemas import SyncReport
|
|||
from app.flows.sync import lfx_id_for
|
||||
from app.settings import settings
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures" / "flows"
|
||||
|
||||
|
||||
def load_fixture(name: str) -> dict:
|
||||
return json.loads((FIXTURES / name).read_text())
|
||||
|
||||
|
||||
def _lfx() -> LfxClient:
|
||||
return LfxClient(settings.lfx_url, api_key=settings.lfx_api_key or None)
|
||||
from .conftest import FIXTURES_DIR, langflow_export_doc, load_flow_fixture
|
||||
|
||||
|
||||
def _seed_dir(tmp_path: Path, name: str = "simple_rule.json") -> Path:
|
||||
shutil.copy(FIXTURES / name, tmp_path / name)
|
||||
shutil.copy(FIXTURES_DIR / name, tmp_path / name)
|
||||
return tmp_path
|
||||
|
||||
|
||||
def load_fixture(name: str) -> dict:
|
||||
"""Alias of the shared conftest helper (kept for call-site stability)."""
|
||||
return load_flow_fixture(name)
|
||||
|
||||
|
||||
def _lfx() -> LfxClient:
|
||||
"""Alias of the shared lfx_client fixture logic (call-site stability)."""
|
||||
return LfxClient(settings.lfx_url, api_key=settings.lfx_api_key or None)
|
||||
|
||||
|
||||
async def test_sync_adds_new_flow(session, lfx_server, tmp_path):
|
||||
_seed_dir(tmp_path)
|
||||
report = await sync.sync_from_directory(session, _lfx(), tmp_path)
|
||||
|
|
@ -145,17 +147,8 @@ async def test_sync_endpoint_returns_report(
|
|||
|
||||
|
||||
def _langflow_doc(name: str, langflow_id: str) -> dict:
|
||||
doc = load_fixture("simple_rule.json")
|
||||
return {
|
||||
"id": langflow_id,
|
||||
"name": name,
|
||||
"description": "aus Langflow",
|
||||
"endpoint_name": None,
|
||||
"data": doc["data"],
|
||||
"tags": [],
|
||||
"webhook": False,
|
||||
"is_component": False,
|
||||
}
|
||||
"""Alias of the shared conftest helper (kept for call-site stability)."""
|
||||
return langflow_export_doc(name, langflow_id)
|
||||
|
||||
|
||||
async def test_sync_endpoint_pulls_from_langflow_then_syncs(
|
||||
|
|
@ -227,24 +220,26 @@ async def test_sync_endpoint_pull_error_continues(
|
|||
assert "kaputt-id" in body["errors"]
|
||||
|
||||
|
||||
async def test_sync_endpoint_langflow_unreachable(
|
||||
client, lfx_server, tmp_path, monkeypatch, login, override_langflow
|
||||
@pytest.mark.parametrize(
|
||||
("list_status", "expected_status"),
|
||||
[(0, 503), (500, 502)],
|
||||
)
|
||||
async def test_sync_endpoint_langflow_failures(
|
||||
client,
|
||||
lfx_server,
|
||||
tmp_path,
|
||||
monkeypatch,
|
||||
login,
|
||||
override_langflow,
|
||||
list_status,
|
||||
expected_status,
|
||||
):
|
||||
"""Listing failures map to 503/502 (parametrized)."""
|
||||
await login()
|
||||
monkeypatch.setattr(settings, "flows_dir", str(tmp_path))
|
||||
override_langflow(flows=[], list_status=0)
|
||||
override_langflow(flows=[], list_status=list_status)
|
||||
response = await client.post("/api/flows/sync")
|
||||
assert response.status_code == 503
|
||||
|
||||
|
||||
async def test_sync_endpoint_langflow_error(
|
||||
client, lfx_server, tmp_path, monkeypatch, login, override_langflow
|
||||
):
|
||||
await login()
|
||||
monkeypatch.setattr(settings, "flows_dir", str(tmp_path))
|
||||
override_langflow(flows=[], list_status=500)
|
||||
response = await client.post("/api/flows/sync")
|
||||
assert response.status_code == 502
|
||||
assert response.status_code == expected_status
|
||||
|
||||
|
||||
async def test_watch_forever_triggers_on_file_change(tmp_path):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue