forked from retoor/devplacepy
docs: document server-side rendering pipeline, response timing middleware, and Telegram pairing API
- Add comprehensive documentation for backend content rendering in AGENTS.md, detailing the new `render_content` and `render_title` Jinja globals built on mistune with media processing, emoji shortcodes, and XSS protection
- Document the `X-Response-Time` header and bottom-left render time indicator in README.md
- Update bot token pricing documentation to clarify fallback vs gateway cost headers
- Add `email_accounts` to soft-delete tables and `idx_users_role` composite index in database schema
- Implement `telegram_pairings` and `telegram_links` table creation with column migration and indexes
- Add `/profile/{username}/telegram` endpoint to docs API with request/unpair actions
- Register `TelegramService` in main.py lifespan and add `response_timing` middleware emitting `X-Response-Time` header
- Introduce `TelegramPairForm` model and `guard_public_host_sync` synchronous host validation function
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
import re
|
||||
|
||||
import devplacepy.main as m
|
||||
from starlette.testclient import TestClient
|
||||
def _patch_limits(monkeypatch, limit, window=60):
|
||||
@@ -43,3 +45,29 @@ def test_rate_limit_reads_configured_setting(monkeypatch):
|
||||
second = client.post("/", headers={"X-Real-IP": "7.7.7.7"}).status_code
|
||||
assert first != 429
|
||||
assert second == 429
|
||||
|
||||
|
||||
def test_response_time_header_present():
|
||||
client = TestClient(m.app)
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
value = response.headers.get("X-Response-Time")
|
||||
assert value is not None and value.endswith("ms")
|
||||
assert float(value[:-2]) >= 0
|
||||
|
||||
|
||||
def test_response_time_indicator_rendered_on_html():
|
||||
client = TestClient(m.app)
|
||||
match = re.search(
|
||||
r'<div class="response-time-indicator"[^>]*>([\d.]+) ms</div>',
|
||||
client.get("/").text,
|
||||
)
|
||||
assert match is not None
|
||||
assert float(match.group(1)) >= 0
|
||||
|
||||
|
||||
def test_response_time_indicator_absent_from_json():
|
||||
client = TestClient(m.app)
|
||||
response = client.get("/feed", headers={"Accept": "application/json"})
|
||||
assert "response-time-indicator" not in response.text
|
||||
assert response.headers.get("X-Response-Time", "").endswith("ms")
|
||||
|
||||
Reference in New Issue
Block a user