def test_prefetch_off(): data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] client = mk_mock_client({"pag_on": [data, 200]}, paginated=["pag_on"]) executor = Executor(client) p_pag = Path("pag_on", [int], pagination=True) assert get_last_req(client.http) is None req = executor.run(path=p_pag, page=2, per_page=3) assert get_last_req(client.http) is None list(req) assert get_last_req(client.http) is not None
def test_delete_checkins(): client = mk_mock_client({r".*checkin.*": [{}, 204]}, user=None) with pytest.raises(NotAuthenticated): client.checkin.delete_active_checkins() client.set_user(USER) client.checkin.delete_active_checkins() assert get_last_req(client.http)["method"] == "DELETE"
def test_prefetch_on(): data = list(range(10**3)) client = mk_mock_client({"pag_on": [data, 200]}, paginated=["pag_on"]) executor = Executor(client) p_pag = Path("pag_on", [int], pagination=True) # prefetch assert get_last_req(client.http) is None req = executor.run(path=p_pag, page=2, per_page=3) assert get_last_req(client.http) is None req.prefetch_all() assert get_last_req(client.http) is not None # reset history client.http._requests.req_stack = [] assert get_last_req(client.http) is None # execute prefetched -> assert no new requests list(req) assert get_last_req(client.http) is None
def test_hide_show(): m_id = SHOW["ids"]["trakt"] client = mk_mock_client({rf".*shows/{m_id}": [{}, 204]}, user=None) show = parse_tree(SHOW, tree_structure=Show) with pytest.raises(NotAuthenticated): client.recommendations.hide_show(show=show) client.set_user(USER) client.recommendations.hide_show(show=show) assert get_last_req(client.http)["method"] == "DELETE"
def test_hide_movie(): m_id = MOVIE1["ids"]["trakt"] client = mk_mock_client({rf".*movies/{m_id}": [{}, 204]}, user=None) movie = parse_tree(MOVIE1, tree_structure=Movie) with pytest.raises(NotAuthenticated): client.recommendations.hide_movie(movie=movie) client.set_user(USER) client.recommendations.hide_movie(movie=movie) client.recommendations.hide_movie(movie=movie.ids.trakt) assert get_last_req(client.http)["method"] == "DELETE"
def test_remove_like(): client = mk_mock_client({".*comments.*": [{}, 204]}) client.comments.remove_like(id=50) assert get_last_req(client.http)["method"] == "DELETE"
def test_like_comment(): client = mk_mock_client({".*comments.*": [{}, 200]}) client.comments.like_comment(id=50) assert get_last_req(client.http)["method"] == "POST"
def test_delete_comment(): client = mk_mock_client({".*comments.*": [{}, 204]}) client.comments.delete_comment(id=123) assert get_last_req(client.http)["method"] == "DELETE"