fix: find next rating page
This commit is contained in:
parent
738799cc74
commit
d385860ca9
3 changed files with 78 additions and 38 deletions
BIN
tests/fixtures/ratings-ur655321.html.bz2
vendored
Normal file
BIN
tests/fixtures/ratings-ur655321.html.bz2
vendored
Normal file
Binary file not shown.
|
|
@ -65,3 +65,20 @@ async def test_load_top_250(monkeypatch):
|
|||
movie_ids = await imdb.load_top_250()
|
||||
assert len(movie_ids) == 250
|
||||
assert all(id_.startswith("tt") for id_ in movie_ids)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_load_ratings_page(monkeypatch):
|
||||
with bz2.open(fixturesdir / "ratings-ur655321.html.bz2", "rb") as f:
|
||||
html = f.read()
|
||||
soup = bs4.BeautifulSoup(html, "html5lib")
|
||||
|
||||
monkeypatch.setattr(imdb, "asoup_from_url", AsyncMock(return_value=soup))
|
||||
|
||||
page = await imdb.load_ratings_page("fakeurl")
|
||||
assert len(page.ratings) == 100
|
||||
assert page.imdb_user_id is not None
|
||||
assert page.imdb_user_id == "ur655321"
|
||||
assert page.imdb_user_name == "AlexUltra"
|
||||
assert page.next_page_url is not None
|
||||
assert page.next_page_url.startswith("/user/ur655321/ratings?")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue