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
2 changes: 1 addition & 1 deletion tests/mock_data/lists.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}
}
},
"lists/1248149/items": {
"lists/1248149/items?page=1&limit=100": {
"GET": [
{
"rank": 1,
Expand Down
4 changes: 2 additions & 2 deletions tests/mock_data/sync.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
}
]
},
"sync/watched/shows": {
"sync/watched/shows?extended=progress": {
"GET": [
{
"plays":56,
Expand All @@ -193,7 +193,7 @@
}
]
},
"sync/watched/shows?extended=noseasons": {
"sync/watched/shows": {
"GET": [
{
"plays":56,
Expand Down
144 changes: 138 additions & 6 deletions tests/mock_data/users.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,23 @@
}
]
},
"users/sean/collection/movies?page=1&limit=250&extended=metadata": {
"GET": [
{
"collected_at":"2014-09-01T09:10:11.000Z",
"movie":{"title":"TRON: Legacy","year":2010,"ids":{"trakt":1,"slug":"tron-legacy-2010","imdb":"tt1104001","tmdb":20526}},
"metadata":{"media_type":"bluray","resolution":"hd_1080p","audio":"dts","audio_channels":"6.1","3d":false}
},
{
"collected_at":"2014-09-01T09:10:11.000Z",
"movie":{"title":"The Dark Knight","year":2008,"ids":{"trakt":6,"slug":"the-dark-knight-2008","imdb":"tt0468569","tmdb":155}},
"metadata":{"media_type":"bluray","resolution":"hd_1080p","audio":"dts","audio_channels":"6.1","3d":false}
}
]
},
"users/sean/collection/movies?page=2&limit=250&extended=metadata": {
"GET": []
},
"users/sean/collection/shows": {
"GET": [
{
Expand Down Expand Up @@ -184,6 +201,53 @@
}
]
},
"users/sean/collection/shows?page=1&limit=250&extended=metadata": {
"GET": [
{
"last_collected_at":"2014-09-01T09:10:11.000Z",
"show":{"title":"Breaking Bad","year":2008,"ids":{"trakt":1388,"slug":"breaking-bad","tvdb":81189,"imdb":"tt0903747","tmdb":1396,"tvrage":18164}},
"seasons":[
{
"number":1,
"episodes":[
{"number":1,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}},
{"number":2,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}}
]
},
{
"number":2,
"episodes":[
{"number":1,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}},
{"number":2,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}}
]
}
]
},
{
"last_collected_at":"2014-09-01T09:10:11.000Z",
"show":{"title":"The Walking Dead","year":2010,"ids":{"trakt":1393,"slug":"the-walking-dead","tvdb":153021,"imdb":"tt1520211","tmdb":1402,"tvrage":null}},
"seasons":[
{
"number":1,
"episodes":[
{"number":1,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}},
{"number":2,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}}
]
},
{
"number":2,
"episodes":[
{"number":1,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}},
{"number":2,"collected_at":"2014-09-01T09:10:11.000Z","metadata":{"media_type":"digital","resolution":"hd_720p","audio":"aac","audio_channels":"5.1","3d":false}}
]
}
]
}
]
},
"users/sean/collection/shows?page=2&limit=250&extended=metadata": {
"GET": []
},
"users/sean/comments": {
"GET": [
{"type":"movie","movie":{"title":"Batman Begins","year":2005,"ids":{"trakt":1,"slug":"batman-begins-2005","imdb":"tt0372784","tmdb":272}},"comment":{"id":267,"comment":"Great kickoff to a new Batman trilogy!","spoiler":false,"review":false,"parent_id":0,"created_at":"2015-04-25T00:14:57.000Z","replies":0,"likes":0,"user_rating":10,"user":{"username":"justin","private":false,"name":"Justin N.","vip":true,"vip_ep":false}}},
Expand Down Expand Up @@ -307,7 +371,7 @@
"POST": "",
"DELETE": ""
},
"users/sean/lists/star-wars-in-machete-order/items": {
"users/sean/lists/star-wars-in-machete-order/items?page=1&limit=100": {
"GET": [
{"rank":"1","listed_at":"2014-06-16T06:07:12.000Z","type":"movie","movie":{"title":"Star Wars: Episode IV - A New Hope","year":1977,"ids":{"trakt":12,"slug":"star-wars-episode-iv-a-new-hope-1977","imdb":"tt0076759","tmdb":11}}},
{"rank":"2","listed_at":"2014-06-16T06:07:12.000Z","type":"show","show":{"title":"The Walking Dead","year":2010,"ids":{"trakt":1393,"slug":"the-walking-dead","tvdb":153021,"imdb":"tt1520211","tmdb":1402,"tvrage":null}}},
Expand Down Expand Up @@ -529,7 +593,7 @@
}
]
},
"users/sean/watchlist/movies": {
"users/sean/watchlist/movies?page=1&limit=100": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -543,7 +607,24 @@
}
]
},
"users/sean/watchlist/shows": {
"users/sean/watchlist/movies?page=1&limit=250": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
"type":"movie",
"movie":{"title":"TRON: Legacy","year":2010,"ids":{"trakt":1,"slug":"tron-legacy-2010","imdb":"tt1104001","tmdb":20526}}
},
{
"listed_at":"2014-09-01T09:10:11.000Z",
"type":"movie",
"movie":{"title":"The Dark Knight","year":2008,"ids":{"trakt":6,"slug":"the-dark-knight-2008","imdb":"tt0468569","tmdb":155}}
}
]
},
"users/sean/watchlist/movies?page=2&limit=250": {
"GET": []
},
"users/sean/watchlist/shows?page=1&limit=100": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
Expand All @@ -557,6 +638,23 @@
}
]
},
"users/sean/watchlist/shows?page=1&limit=250": {
"GET": [
{
"listed_at":"2014-09-01T09:10:11.000Z",
"type":"show",
"show":{"title":"Breaking Bad","year":2008,"ids":{"trakt":1388,"slug":"breaking-bad","tvdb":81189,"imdb":"tt0903747","tmdb":1396,"tvrage":18164}}
},
{
"listed_at":"2014-09-01T09:10:11.000Z",
"type":"show",
"show":{"title":"The Walking Dead","year":2010,"ids":{"trakt":1393,"slug":"the-walking-dead","tvdb":153021,"imdb":"tt1520211","tmdb":1402,"tvrage":null}}
}
]
},
"users/sean/watchlist/shows?page=2&limit=250": {
"GET": []
},
"users/sean/watchlist/seasons": {
"GET": [
{
Expand Down Expand Up @@ -598,7 +696,7 @@
"users/sean-nothing/watching": {
"GET": ""
},
"users/sean/watched/movies": {
"users/sean/watched/movies?page=1&limit=100": {
"GET": [
{
"plays":4,
Expand All @@ -612,7 +710,24 @@
}
]
},
"users/sean/watched/shows": {
"users/sean/watched/movies?page=1&limit=250": {
"GET": [
{
"plays":4,
"last_watched_at":"2014-10-11T17:00:54.000Z",
"movie":{"title":"Batman Begins","year":2005,"ids":{"trakt":6,"slug":"batman-begins-2005","imdb":"tt0372784","tmdb":272}}
},
{
"plays":2,
"last_watched_at":"2014-10-12T17:00:54.000Z",
"movie":{"title":"The Dark Knight","year":2008,"ids":{"trakt":4,"slug":"the-dark-knight-2008","imdb":"tt0468569","tmdb":155}}
}
]
},
"users/sean/watched/movies?page=2&limit=250": {
"GET": []
},
"users/sean/watched/shows?page=1&limit=100&extended=progress": {
"GET": [
{
"plays":56,
Expand All @@ -634,7 +749,7 @@
}
]
},
"users/sean/watched/shows?extended=noseasons": {
"users/sean/watched/shows?page=1&limit=100": {
"GET": [
{
"plays":56,
Expand All @@ -648,6 +763,23 @@
}
]
},
"users/sean/watched/shows?page=1&limit=250": {
"GET": [
{
"plays":56,
"last_watched_at":"2014-10-11T17:00:54.000Z",
"show":{"title":"Breaking Bad","year":2008,"ids":{"trakt":1388,"slug":"breaking-bad","tvdb":81189,"imdb":"tt0903747","tmdb":1396,"tvrage":18164}}
},
{
"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}}
}
]
},
"users/sean/watched/shows?page=2&limit=250": {
"GET": []
},
"users/sean/stats": {
"GET": {"movies":{"plays":155,"watched":114,"minutes":15650,"collected":933,"ratings":256,"comments":28},"shows":{"watched":16,"collected":7,"ratings":63,"comments":20},"seasons":{"ratings":6,"comments":1},"episodes":{"plays":552,"watched":534,"minutes":17330,"collected":117,"ratings":64,"comments":14},"network":{"friends":1,"followers":4,"following":11},"ratings":{"total":389,"distribution":{"1":18,"2":1,"3":4,"4":1,"5":10,"6":9,"7":37,"8":37,"9":57,"10":215}}}
}
Expand Down
21 changes: 21 additions & 0 deletions tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def test_user_collections():
assert all([isinstance(m, Movie) for m in sean.movie_collection])
assert all([isinstance(s, TVShow) for s in sean.show_collection])

movie_page = sean.collection('movies', page=1, limit=250)
show_page = sean.collection('shows', page=1, limit=250)
assert all(['movie' in item for item in movie_page])
assert all(['show' in item for item in show_page])
assert sean.collection('movies', page=2, limit=250) == []
assert sean.collection('shows', page=2, limit=250) == []


def test_user_list():
sean = User('sean')
Expand Down Expand Up @@ -107,6 +114,13 @@ def test_user_watchlists():
assert all([isinstance(m, Movie) for m in sean.watchlist_movies])
assert all([isinstance(s, TVShow) for s in sean.watchlist_shows])

movie_page = sean.watchlist('movies', page=1, limit=250)
show_page = sean.watchlist('shows', page=1, limit=250)
assert all([item['type'] == 'movie' for item in movie_page])
assert all([item['type'] == 'show' for item in show_page])
assert sean.watchlist('movies', page=2, limit=250) == []
assert sean.watchlist('shows', page=2, limit=250) == []


def test_watching():
sean = User('sean')
Expand All @@ -124,6 +138,13 @@ def test_watched():
assert all([isinstance(m, Movie) for m in sean.watched_movies])
assert all([isinstance(s, TVShow) for s in sean.watched_shows])

movie_page = sean.watched('movies', page=1, limit=250)
show_page = sean.watched('shows', page=1, limit=250)
assert all(['movie' in item for item in movie_page])
assert all(['show' in item for item in show_page])
assert sean.watched('movies', page=2, limit=250) == []
assert sean.watched('shows', page=2, limit=250) == []


def test_stats():
sean = User('sean')
Expand Down
Loading