mirror of
https://github.com/Screenly/Anthias.git
synced 2026-07-30 17:25:50 -04:00
- Add an "Anthias/<version>" product token to QtWebEngine's default User-Agent so requests still read as Mozilla/Chrome/Safari while identifying the source screen and release - Inject ANTHIAS_VERSION into the webview env from get_anthias_release(), falling back to "unknown" when unavailable Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
954 B
Python
31 lines
954 B
Python
from unittest import mock
|
|
|
|
from anthias_common.http import (
|
|
ANTHIAS_HOMEPAGE,
|
|
get_anthias_product_token,
|
|
get_user_agent,
|
|
)
|
|
|
|
|
|
def test_product_token_uses_release() -> None:
|
|
with mock.patch(
|
|
'anthias_common.http.get_anthias_release', return_value='2026.6.3'
|
|
):
|
|
assert get_anthias_product_token() == 'Anthias/2026.6.3'
|
|
|
|
|
|
def test_product_token_falls_back_to_unknown() -> None:
|
|
# get_anthias_release() returns '' when neither the installed package
|
|
# metadata nor the repo-root pyproject.toml can be read.
|
|
with mock.patch(
|
|
'anthias_common.http.get_anthias_release', return_value=''
|
|
):
|
|
assert get_anthias_product_token() == 'Anthias/unknown'
|
|
|
|
|
|
def test_user_agent_wraps_product_token_with_homepage() -> None:
|
|
with mock.patch(
|
|
'anthias_common.http.get_anthias_release', return_value='2026.6.3'
|
|
):
|
|
assert get_user_agent() == (f'Anthias/2026.6.3 (+{ANTHIAS_HOMEPAGE})')
|