feat(2): discourse P3 functional tests — §4.3 create-topic round-trip + site.json config + admin-bootstrap helper
_discourse.py: bootstrap an admin (recipe seeds none) + mint an ApiKey via rails runner in the app container (class-B run-scoped). test_create_topic.py: POST /posts.json (unique marker) -> GET /t/<id>.json title+cooked round-trip. test_site_basic.py: GET /site.json asserts discourse categories config. Meets P3 (>=2 functional beyond health).
This commit is contained in:
31
tests/discourse/functional/test_site_basic.py
Normal file
31
tests/discourse/functional/test_site_basic.py
Normal file
@ -0,0 +1,31 @@
|
||||
"""discourse — Q4.6 recipe-specific functional test (2nd functional, beyond create-topic + health).
|
||||
|
||||
Asserts Discourse's Rails app emits its bootstrap JSON: GET /site.json returns 200 with the
|
||||
site-config envelope the Ember SPA needs (categories list + default trust levels). This distinguishes
|
||||
"the Discourse Rails backend is up and serving its API" from "a static/error page is served" — a
|
||||
wedged backend 5xxs, a misroute 404s. Complements test_create_topic (write path) with a read of the
|
||||
app's characteristic site config.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "..", "runner"))
|
||||
from harness import http as harness_http # noqa: E402
|
||||
|
||||
|
||||
def test_site_json_has_discourse_config(live_app):
|
||||
status, body = harness_http.retry_http_get(
|
||||
f"https://{live_app}/site.json", expect_status=200, max_wait=120, interval=5
|
||||
)
|
||||
assert status == 200 and isinstance(body, dict), (
|
||||
f"GET /site.json failed: HTTP {status}, body type={type(body).__name__}"
|
||||
)
|
||||
# /site.json carries Discourse-specific structure — `categories` (a list) and `groups` are always
|
||||
# present in a booted Discourse. A non-Discourse 200 (placeholder page) would not parse to this.
|
||||
assert "categories" in body, f"/site.json missing 'categories' key: keys={list(body)[:20]}"
|
||||
assert isinstance(body["categories"], list), (
|
||||
f"/site.json 'categories' not a list: {type(body['categories']).__name__}"
|
||||
)
|
||||
Reference in New Issue
Block a user