Extract HTML5 operation helpers
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 12:36:56 +03:00
parent 8683b136b3
commit 940d7e884b
3 changed files with 97 additions and 24 deletions
+50
View File
@@ -1,6 +1,7 @@
from pathlib import Path
import re
import time
from types import SimpleNamespace
from uuid import uuid4
import zipfile
@@ -13,6 +14,7 @@ from api_server.html5_forms import (
html5_metadata_payload,
html5_metadata_request_payload,
)
from api_server.html5_operations import filter_html5_operation_jobs, latest_html5_import_job
from api_server.html5_sse import html5_sse_comment, html5_sse_event, html5_sse_if_changed
from api_server.main import app
from one_c_normalizer import ConfigurationRoot, MetadataGroup, MetadataObject, Module, NormalizedProject
@@ -120,6 +122,54 @@ def test_html5_form_helpers_normalize_metadata_payloads():
assert "_raw_attributes" not in html5_metadata_request_payload(payload)
def test_html5_operation_helpers_filter_sort_and_find_latest_import_job():
jobs = [
SimpleNamespace(
job_id="old",
kind="SERVER_IMPORT",
status="SUCCEEDED",
payload={"project_id": "demo"},
updated_at=10,
),
SimpleNamespace(
job_id="new",
kind="SERVER_IMPORT",
status="RUNNING",
payload={"project_id": "demo"},
updated_at=30,
),
SimpleNamespace(
job_id="other-kind",
kind="REINDEX",
status="RUNNING",
payload={"project_id": "demo"},
updated_at=40,
),
SimpleNamespace(
job_id="other-project",
kind="SERVER_IMPORT",
status="RUNNING",
payload={"project_id": "other"},
updated_at=50,
),
]
filtered = filter_html5_operation_jobs(
jobs,
project_id=" DEMO ",
status="running",
kind="server_import",
)
assert [job.job_id for job in filtered] == ["new"]
assert [job.job_id for job in filter_html5_operation_jobs(jobs, project_id="demo")] == [
"other-kind",
"new",
"old",
]
assert latest_html5_import_job(jobs, "demo").job_id == "new"
def test_cors_allows_lan_panel_origin():
client = TestClient(app)
response = client.options(