Skip to content

Commit

Permalink
Add PublicList tests (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc committed Mar 9, 2024
2 parents b741249 + 5443269 commit 0ccf394
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
os.path.join(MOCK_DATA_DIR, 'episodes.json'),
os.path.join(MOCK_DATA_DIR, 'sync.json'),
os.path.join(MOCK_DATA_DIR, 'users.json'),
os.path.join(MOCK_DATA_DIR, 'lists.json'),
]


Expand Down
133 changes: 133 additions & 0 deletions tests/mock_data/lists.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"lists/1248149": {
"GET": {
"name": "MARVEL Cinematic Universe",
"description": "**UPDATED** _2024-01-19_\n**Chronological order**",
"privacy": "public",
"share_link": "https://trakt.tv/lists/1248149",
"type": "personal",
"display_numbers": true,
"allow_comments": true,
"sort_by": "rank",
"sort_how": "asc",
"created_at": "2015-07-16T14:59:57.000Z",
"updated_at": "2024-03-07T10:54:58.000Z",
"item_count": 218,
"comment_count": 32,
"likes": 4368,
"ids": {
"trakt": 1248149,
"slug": "marvel-cinematic-universe"
},
"user": {
"username": "Donxy",
"private": false,
"name": "Donxy",
"vip": false,
"vip_ep": true,
"ids": {
"slug": "donxy"
}
}
}
},
"lists/1248149/items": {
"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
}
}
}
]
}
}
24 changes: 24 additions & 0 deletions tests/test_lists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
from trakt.movies import Movie
from trakt.tv import TVEpisode, TVSeason, TVShow
from trakt.users import PublicList


def test_public_list():
trakt_id = 1248149
l = PublicList.load(trakt_id)

assert isinstance(l, PublicList)
assert l.name == "MARVEL Cinematic Universe"
assert l.privacy == "public"
assert l.share_link == "https://trakt.tv/lists/1248149"

# Test iter
assert len(l) == 4

# enumerate list items
instancetypes = (Movie, TVShow, TVSeason, TVEpisode)
assert all([isinstance(k.item, instancetypes) for k in l])

# trakt id is a number
assert all([isinstance(k.trakt, int) for k in l])

0 comments on commit 0ccf394

Please sign in to comment.