Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from copy import deepcopy

import trakt
import trakt._pagination as _pagination_store

TESTS_DIR = os.path.dirname(__file__)
MOCK_DATA_DIR = os.path.join(TESTS_DIR, "mock_data")
Expand Down Expand Up @@ -42,6 +43,9 @@ def request(self, method, uri, data=None):
response = method_responses.get(method.upper())
if response is None:
print(f"No mock for {uri}")
# Mock responses carry no HTTP headers, so clear any stale pagination
# state to ensure iter_pages stops after the first populated page.
_pagination_store.set(None)
return deepcopy(response)


Expand Down
101 changes: 100 additions & 1 deletion tests/mock_data/lists.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,106 @@
}
}
},
"lists/1248149/items": {
"lists/1248149/items?page=1&limit=100": {
"GET": [
{
"rank": 1,
"id": 37745122,
"listed_at": "2015-07-16T15:01:36.000Z",
"notes": null,
"type": "movie",
"movie": {
"title": "Captain America: The First Avenger",
"year": 2011,
"ids": {
"trakt": 1170,
"slug": "captain-america-the-first-avenger-2011",
"imdb": "tt0458339",
"tmdb": 1771
}
}
},
{
"rank": 2,
"id": 92178558,
"listed_at": "2016-04-24T15:44:25.000Z",
"notes": null,
"type": "season",
"season": {
"number": 1,
"ids": {
"trakt": 83598,
"tvdb": 585033,
"tmdb": 63213,
"tvrage": null
}
},
"show": {
"title": "Marvel's Agent Carter",
"year": 2015,
"ids": {
"trakt": 77677,
"slug": "marvel-s-agent-carter",
"tvdb": 281485,
"imdb": "tt3475734",
"tmdb": 61550,
"tvrage": null
}
}
},
{
"rank": 3,
"id": 964880087,
"listed_at": "2024-01-19T20:35:45.000Z",
"notes": null,
"type": "episode",
"episode": {
"season": 1,
"number": 1,
"title": "Stark Expo 1974",
"ids": {
"trakt": 3448545,
"tvdb": 7106488,
"imdb": null,
"tmdb": null,
"tvrage": null
}
},
"show": {
"title": "Stark Expo Shorts",
"year": 2010,
"ids": {
"trakt": 145816,
"slug": "stark-expo-shorts",
"tvdb": 361608,
"imdb": null,
"tmdb": null,
"tvrage": null
}
}
},
{
"rank": 4,
"id": 564744722,
"listed_at": "2021-01-16T12:25:07.000Z",
"notes": null,
"type": "show",
"show": {
"title": "Moon Knight",
"year": 2022,
"ids": {
"trakt": 151840,
"slug": "moon-knight",
"tvdb": 368611,
"imdb": "tt10234724",
"tmdb": 92749,
"tvrage": null
}
}
}
]
},
"lists/1248149/items?page=1&limit=250": {
"GET": [
{
"rank": 1,
Expand Down
37 changes: 16 additions & 21 deletions tests/mock_data/sync.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"sync/playback/13": {
"DELETE": ""
},
"sync/collection/movies": {
"sync/collection/movies?page=1&limit=100": {
"GET": [
{
"collected_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -23,7 +23,7 @@
}
]
},
"sync/collection/movies?extended=metadata": {
"sync/collection/movies?page=1&limit=100&extended=metadata": {
"GET": [
{
"collected_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -37,7 +37,7 @@
}
]
},
"sync/collection/shows": {
"sync/collection/shows?page=1&limit=100": {
"GET": [
{
"last_collected_at":"2014-09-01T09:10:11.000Z",
Expand Down Expand Up @@ -81,7 +81,7 @@
}
]
},
"sync/collection/shows?extended=metadata": {
"sync/collection/shows?page=1&limit=100&extended=metadata": {
"GET": [
{
"last_collected_at":"2014-09-01T09:10:11.000Z",
Expand Down Expand Up @@ -149,29 +149,21 @@
}
}
},
"sync/watched/movies": {
"sync/watched/movies?page=1&limit=100": {
"GET": [
{
"plays":56,
"last_watched_at":"2014-10-11T17:00:54.000Z",
"show":{"title":"Breaking Bad","year":2008,"ids":{"trakt":1,"slug":"breaking-bad","tvdb":81189,"imdb":"tt0903747","tmdb":1396,"tvrage":18164}},
"seasons":[
{"number":1,"episodes":[{"number":1,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"},{"number":2,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"}]},
{"number":2,"episodes":[{"number":1,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"},{"number":2,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"}]}
]
"movie":{"title":"TRON: Legacy","year":2010,"ids":{"trakt":1,"slug":"tron-legacy-2010","imdb":"tt1104001","tmdb":20526}}
},
{
"plays":23,
"last_watched_at":"2014-10-12T17:00:54.000Z",
"show":{"title":"Parks and Recreation","year":2009,"ids":{"trakt":4,"slug":"parks-and-recreation","tvdb":84912,"imdb":"tt1266020","tmdb":8592,"tvrage":21686}},
"seasons":[
{"number":1,"episodes":[{"number":1,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"},{"number":2,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"}]},
{"number":2,"episodes":[{"number":1,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"},{"number":2,"plays":1,"last_watched_at":"2014-10-11T17:00:54.000Z"}]}
]
"movie":{"title":"The Dark Knight","year":2008,"ids":{"trakt":4,"slug":"the-dark-knight-2008","imdb":"tt0468569","tmdb":155}}
}
]
},
"sync/watched/shows": {
"sync/watched/shows?page=1&limit=100&extended=progress": {
"GET": [
{
"plays":56,
Expand All @@ -193,7 +185,7 @@
}
]
},
"sync/watched/shows?extended=noseasons": {
"sync/watched/shows?page=1&limit=100": {
"GET": [
{
"plays":56,
Expand Down Expand Up @@ -397,7 +389,7 @@
}
}
},
"sync/watchlist/movies": {
"sync/watchlist/movies?page=1&limit=100": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -411,7 +403,10 @@
}
]
},
"sync/watchlist/shows": {
"sync/watchlist/movies?page=2&limit=100": {
"GET": []
},
"sync/watchlist/shows?page=1&limit=100": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -425,7 +420,7 @@
}
]
},
"sync/watchlist/seasons": {
"sync/watchlist/seasons?page=1&limit=100": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -441,7 +436,7 @@
}
]
},
"sync/watchlist/episodes": {
"sync/watchlist/episodes?page=1&limit=100": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
Expand Down
Loading