test_q4b_ui_performance.py
python
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
3 days ago
| 1 | """Performance tests for Track Q / Q4b Path B UI redesign (§Q4A.15).""" |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import time |
| 6 | import urllib.request |
| 7 | from pathlib import Path |
| 8 | |
| 9 | from tests.fixtures.app import seed_app_repo, start_test_app |
| 10 | |
| 11 | # Same latency class as Track Q / Q1 static/status bounds (§Q0.12 / §Q4A.15). |
| 12 | STATIC_ASSET_BOUND_SEC = 1.0 |
| 13 | INDEX_BOUND_SEC = 1.0 |
| 14 | |
| 15 | DIAGRAMS = ( |
| 16 | "lanes.svg", |
| 17 | "regimes.svg", |
| 18 | "layers.svg", |
| 19 | "kit-consumer.svg", |
| 20 | ) |
| 21 | |
| 22 | |
| 23 | def test_index_and_diagrams_within_bound(tmp_path: Path) -> None: |
| 24 | seed_app_repo(tmp_path) |
| 25 | handle, client = start_test_app(tmp_path) |
| 26 | try: |
| 27 | start = time.monotonic() |
| 28 | request = urllib.request.Request( |
| 29 | f"{client.base_url}/", |
| 30 | headers={"Authorization": f"Bearer {client.session}"}, |
| 31 | ) |
| 32 | with urllib.request.urlopen(request, timeout=5) as response: |
| 33 | assert response.status == 200 |
| 34 | assert b"Overseer Kit" in response.read() |
| 35 | assert time.monotonic() - start < INDEX_BOUND_SEC |
| 36 | |
| 37 | for name in DIAGRAMS: |
| 38 | start = time.monotonic() |
| 39 | svg_req = urllib.request.Request( |
| 40 | f"{client.base_url}/assets/diagrams/{name}", |
| 41 | headers={"Authorization": f"Bearer {client.session}"}, |
| 42 | ) |
| 43 | with urllib.request.urlopen(svg_req, timeout=5) as response: |
| 44 | assert response.status == 200 |
| 45 | assert b"<svg" in response.read() |
| 46 | assert time.monotonic() - start < STATIC_ASSET_BOUND_SEC |
| 47 | finally: |
| 48 | handle.shutdown() |
File History
1 commit
sha256:a78e7e5a8740e03315f325d19edeb3aa1b306b3337d04abbaa9a9e0f3bbeb7a1
docs: MuseHub-first before ISR #74 — staging solidify NEXT
Human
3 days ago