Stabilize paywall reconnect source tests on Windows#7779
Conversation
Greptile SummaryThis PR fixes a Windows-only
Confidence Score: 4/5Safe to merge — only test code changes, no production logic is touched. The UTF-8 encoding fix and assertion updates are correct and well-matched to the current production implementation. The only rough edge is that TestByokRequestEscapeHatch._setup_subscription still sets sub._TRIAL_PAYWALL_ENABLED and sub._TRIAL_PAYWALL_TEST_UIDS, which are now orphaned attributes with no effect — the same cleanup done for TestIsTrialPaywalledBehavioral was not applied to this class. Tests continue to pass regardless, but the leftover assignments are misleading about which code paths the BYOK tests actually exercise. The TestByokRequestEscapeHatch._setup_subscription fixture (lines 450–451) still carries stale attribute assignments that no longer correspond to any production globals. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Test: _read_source] -->|encoding='utf-8' fix| B[UTF-8 source file read]
B --> C{Source-level assertions}
C --> D[TestPlatformFiltering\nfilters_before_expiry_lookup]
C --> E[TestPlatformFiltering\ndelegates_to_cached_expiry]
D -->|checks ordering| F["platform.lower() not in _TRIAL_PAYWALL_DESKTOP_TOKENS\nbefore _is_trial_expired_cached(uid)"]
E -->|checks delegation| G["return _is_trial_expired_cached(uid)\npresent in fn body"]
H[TestIsTrialPaywalledBehavioral\nfixture setup] -->|removed stale globals| I[sub._is_trial_expired_cached = mock]
I --> J[Behavioral tests\ndesktop_cache_false / uid_delegates / different_uid]
K[TestByokRequestEscapeHatch\nfixture setup] -->|stale still present| L["sub._TRIAL_PAYWALL_ENABLED = True\nsub._TRIAL_PAYWALL_TEST_UIDS = set()"]
L -->|no-op, globals removed from production| M[BYOK escape-hatch tests]
F --> N[Production: is_trial_paywalled]
G --> N
N -->|platform not desktop| O[return False]
N -->|platform is desktop| P[_is_trial_expired_cached uid]
|
f6c8a20 to
608c124
Compare
|
Addressed in |
kodjima33
left a comment
There was a problem hiding this comment.
Test-only stabilization (backend/tests/unit), CI green
Summary
test_paywall_reconnect_gate.pyso the source-level checks pass on Windows non-UTF-8 localesWindows reproduction
Before this change on Windows with the default GBK locale:
python -m pytest tests\unit\test_paywall_reconnect_gate.py -q-> 25 failed, 15 passedUnicodeDecodeError: 'gbk' codec can't decode byte ...while reading UTF-8 source filesTesting
python -m pytest tests\unit\test_paywall_reconnect_gate.py -q-> 40 passedpython -m black --line-length 120 --skip-string-normalization tests\unit\test_paywall_reconnect_gate.py --checkpython -m py_compile tests\unit\test_paywall_reconnect_gate.pygit diff --check --cached