Skip to content

Commit 21b58bc

Browse files
authored
Remove undocumented app metadata from scrobble payloads (#105)
2 parents af4cbb1 + 677f32f commit 21b58bc

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

tests/test_scrobble.py

Lines changed: 23 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,24 @@ 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+
34+
with patch.object(trakt.core.api(), 'post', return_value=None) as mock_post:
35+
scrobbler = Scrobbler(guardians, 0.0, '1.0.0', '2015-02-01')
36+
scrobbler.start(42.0)
37+
38+
args, kwargs = mock_post.call_args
39+
assert not kwargs
40+
assert len(args) >= 2
41+
payload = args[-1]
42+
43+
assert isinstance(payload, dict)
44+
assert payload['progress'] == 42.0
45+
assert 'app_version' not in payload
46+
assert 'app_date' not in payload
47+
assert 'date' not in payload

trakt/sync.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,7 @@ def _post(self, uri):
607607
608608
:param uri: The uri to post to
609609
"""
610-
payload = dict(progress=self.progress, app_version=self.version,
611-
date=self.date)
610+
payload = dict(progress=self.progress)
612611
payload.update(self.media.to_json_singular())
613612
response = yield uri, payload
614613
yield response

0 commit comments

Comments
 (0)