|
1 | 1 | # -*- coding: utf-8 -*- |
| 2 | +import pytest |
2 | 3 | from trakt.movies import Movie |
3 | 4 | from trakt.people import Person |
4 | 5 | from trakt.tv import TVEpisode, TVSeason, TVShow |
@@ -132,6 +133,35 @@ def test_get_watched_movies(): |
132 | 133 | assert all([isinstance(m, Movie) for m in watched_movies]) |
133 | 134 |
|
134 | 135 |
|
| 136 | +def test_get_watched_movies_with_pagination(): |
| 137 | + sean = User('sean') |
| 138 | + watched_movies = sean.get_watched_movies(page=1, limit=1) |
| 139 | + assert isinstance(watched_movies, list) |
| 140 | + assert len(watched_movies) == 1 |
| 141 | + assert isinstance(watched_movies[0], Movie) |
| 142 | + assert watched_movies[0].title == 'Batman Begins' |
| 143 | + |
| 144 | + |
| 145 | +def test_get_watched_movies_invalid_page(): |
| 146 | + sean = User('sean') |
| 147 | + with pytest.raises(ValueError): |
| 148 | + sean.get_watched_movies(page='bad') |
| 149 | + with pytest.raises(ValueError): |
| 150 | + sean.get_watched_movies(page=0) |
| 151 | + with pytest.raises(ValueError): |
| 152 | + sean.get_watched_movies(page=True) |
| 153 | + |
| 154 | + |
| 155 | +def test_get_watched_movies_invalid_limit(): |
| 156 | + sean = User('sean') |
| 157 | + with pytest.raises(ValueError): |
| 158 | + sean.get_watched_movies(limit='bad') |
| 159 | + with pytest.raises(ValueError): |
| 160 | + sean.get_watched_movies(limit=-1) |
| 161 | + with pytest.raises(ValueError): |
| 162 | + sean.get_watched_movies(limit=False) |
| 163 | + |
| 164 | + |
135 | 165 | def test_stats(): |
136 | 166 | sean = User('sean') |
137 | 167 | assert isinstance(sean.get_stats(), dict) |
|
0 commit comments