Skip to content

Commit

Permalink
kodik tests, type annotation for id_type
Browse files Browse the repository at this point in the history
  • Loading branch information
nichind committed Dec 3, 2024
1 parent 110c373 commit dab31c8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/run_test.yml

This file was deleted.

6 changes: 3 additions & 3 deletions moe_parsers/providers/kodik.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ async def search(

return animes

async def translations(self, anime_id: str, id_type: str) -> list:
async def translations(self, anime_id: str, id_type: Literal["shikimori", "kinopoisk", "imdb"]) -> list:
data = await self.get_info(anime_id, id_type)
return data["translations"]

async def episode_count(self, anime_id: str, id_type: str) -> int:
async def episode_count(self, anime_id: str, id_type: Literal["shikimori", "kinopoisk", "imdb"]) -> int:
data = await self.get_info(anime_id, id_type)
return data["episode_count"]

Expand All @@ -264,7 +264,7 @@ async def _link_to_info(
raise Exceptions.PlayerBlocked(f'Нет данных по {id_type} id "{id}"')
return "https:" + data["link"]

async def get_info(self, anime_id: str, id_type: str) -> dict:
async def get_info(self, anime_id: str, id_type: Literal["shikimori", "kinopoisk", "imdb"]) -> dict:
link = await self._link_to_info(anime_id, id_type)
data = await self.get(link, text=True)
soup = await self.soup(data)
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/test_kodik.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
from moe_parsers.providers.kodik import KodikParser, KodikAnime, KodikEpisode, KodikIframe


@pytest.mark.asyncio
async def test_kodik_search():
parser = KodikParser()
res = await parser.search("plastic memories")
assert len(res) > 0
assert "27775" in res[0].anime_id

@pytest.mark.asyncio
async def test_kodik_get_video():
parser = KodikParser()
res = await parser.search("plastic memories")
assert len(res) > 0
await res[0].get_video(1)
assert len(res[0].episodes) > 0
assert isinstance(res[0].episodes[0], KodikEpisode)

0 comments on commit dab31c8

Please sign in to comment.