import asyncio from pathlib import Path import json import re import time from types import SimpleNamespace from urllib.parse import quote from uuid import uuid4 import zipfile from fastapi.testclient import TestClient from api_server import main from api_server.html5_forms import ( form_value, html5_csv_values, 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 def create_authoring_session(client: TestClient, project_id: str, task_id: str, session_id: str, user_id: str = "dev.ivan") -> None: user = client.post("/collaboration/users", json={"user_id": user_id, "display_name": user_id}) assert user.status_code == 200 grant = client.post(f"/security/users/{user_id}/roles/developer") assert grant.status_code == 200 task = client.post( "/collaboration/tasks", json={"task_id": task_id, "project_id": project_id, "title": f"Authoring {task_id}", "assignee_user_id": user_id}, ) assert task.status_code == 200 session = client.post( "/collaboration/sessions", json={"session": {"session_id": session_id, "task_id": task_id, "user_id": user_id}}, ) assert session.status_code == 200 def assert_html5_contract(text: str, *markers: str, full_page: bool = False) -> None: assert "__next" not in text assert "unpkg.com" not in text assert 'hx-trigger="every' not in text if full_page: assert "" in text assert "