Files
devplacepy/tests/unit/services/openai_gateway/apps.py
T
retoorandClaude Sonnet 5.5 bc11475f29 Send per-app provider attribution titles from one gateway app registry
Add openai_gateway/apps.py as the single list of internal gateway apps and
send X-OpenRouter-Title (plus legacy X-Title and HTTP-Referer) per app to
every upstream. Label the Devii agent, bots, modifier, quiz grading, SEO
metadata, community and sync callers. Shorten two app references that
exceeded the 30 character limit and were recorded as default.
Also includes the pending Muse Code, route health and Responses work.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-04 18:45:09 +01:00

44 lines
1.4 KiB
Python

# retoor <retoor@molodetz.nl>
from devplacepy import config as devplace_config
from devplacepy.services.openai_gateway.apps import (
APP_REFERENCE_PATTERN,
GATEWAY_APPS,
LEGACY_TITLE_HEADER,
REFERER_HEADER,
TITLE_HEADER,
app_title,
attribution_headers,
)
def test_every_registered_reference_is_valid_and_unique():
references = [app.reference for app in GATEWAY_APPS]
assert len(references) == len(set(references))
for reference in references:
assert APP_REFERENCE_PATTERN.match(reference), reference
def test_title_is_per_app():
assert app_title("devplace-devii-v-1-0-0") == "DevPlace Devii"
assert app_title("devplace-news-v-1-0-0") == "DevPlace News"
def test_unknown_and_default_fall_back_to_platform_title():
assert app_title("default") == "DevPlace"
assert app_title("someone-else") == "DevPlace"
assert app_title("") == "DevPlace"
def test_attribution_headers_carry_both_title_names(monkeypatch):
monkeypatch.setattr(devplace_config, "SITE_URL", "https://devplace.net")
headers = attribution_headers("devplace-bots-v-1-0-0")
assert headers[TITLE_HEADER] == "DevPlace Bots"
assert headers[LEGACY_TITLE_HEADER] == "DevPlace Bots"
assert headers[REFERER_HEADER] == "https://devplace.net"
def test_referer_omitted_without_site_url(monkeypatch):
monkeypatch.setattr(devplace_config, "SITE_URL", "")
assert REFERER_HEADER not in attribution_headers("default")