Skip to content

Commit beef1b0

Browse files
glenscCopilot
andcommitted
Add regression test for scrobble payload fields
Verify that scrobble payloads do not include undocumented app_version, app_date, or date fields that can cause 400 responses from the Trakt API. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 5afaa49 commit beef1b0

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/test_scrobble.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# -*- coding: utf-8 -*-
2+
from unittest.mock import patch
3+
24
from trakt.movies import Movie
35
from trakt.sync import Scrobbler
46

@@ -22,3 +24,28 @@ def test_scrobbler_context_manager():
2224
with Scrobbler(guardians, 0.0, '1.0.0', '2015-02-01') as scrob:
2325
for i in range(10):
2426
scrob.update(i*10)
27+
28+
29+
def test_scrobbler_payload_excludes_app_metadata():
30+
"""scrobble payload must not include undocumented app_version/date fields"""
31+
import trakt.core
32+
guardians = Movie('Guardians of the Galaxy', year=2014)
33+
scrobbler = Scrobbler(guardians, 42.0, '1.0.0', '2015-02-01')
34+
35+
with patch.object(trakt.core.api(), 'post', return_value=None) as mock_post:
36+
scrobbler.start()
37+
38+
print("call_args:", mock_post.call_args)
39+
print("args:", getattr(mock_post.call_args, "args", None))
40+
print("tuple:", tuple(mock_post.call_args))
41+
42+
args, kwargs = mock_post.call_args
43+
assert not kwargs
44+
assert len(args) >= 2
45+
payload = args[-1]
46+
47+
assert isinstance(payload, dict)
48+
assert payload['progress'] == 42.0
49+
assert 'app_version' not in payload
50+
assert 'app_date' not in payload
51+
assert 'date' not in payload

0 commit comments

Comments
 (0)