Skip to content

Commit

Permalink
feat: add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
potatoeggy committed Dec 31, 2023
1 parent a3855b0 commit 4b488c8
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
6 changes: 5 additions & 1 deletion mandown/sources/source_mangadex.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def fetch_metadata(self) -> BaseMetadata:

if metadata["attributes"]["description"]:
description: str = metadata["attributes"]["description"][self.lang_code]

# strip trailing spaces on each line
description = "\n".join(s.strip() for s in description.split("\n"))
else:
description = ""

Expand All @@ -68,7 +71,8 @@ def fetch_metadata(self) -> BaseMetadata:

genres: list[str] = []
for d in metadata["attributes"]["tags"]:
if d["attributes"]["group"] == "genre":
tag = d["attributes"]["group"]
if tag == "genre" or tag == "theme":
genres.append(d["attributes"]["name"][self.lang_code])

return BaseMetadata(
Expand Down
21 changes: 14 additions & 7 deletions tests/test_source_mangadex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

import mandown

URL = "https://mangadex.org/title/a3d681d7-a239-45a9-8446-5bfc61ca48fa"
COVER_URL = "https://uploads.mangadex.org/covers/a3d681d7-a239-45a9-8446-5bfc61ca48fa/f6c8523e-cc60-410a-8709-99fd3020c6e3.jpg"
DESCRIPTION = "Satoshi, a 16-year-old first year high school student just got a part time job as a housekeeper for a mansion surrounded by roses. A girl called Shizu lives there, who appears innocent and pure but lives haphazardly. However, there seems to be a mystery surrounding her: who is the other girl that looks at Satoshi with a cold blank stare?"
URL = "https://mangadex.org/title/37f5cce0-8070-4ada-96e5-fa24b1bd4ff9"
COVER_URL = "https://uploads.mangadex.org/covers/37f5cce0-8070-4ada-96e5-fa24b1bd4ff9/6bfc8f2a-7510-4746-90d6-b97d01c20796.jpg"
DESCRIPTION = """All’s fair when love is war!
Two geniuses. Two brains. Two hearts. One battle. Who will confess their love first…?!
Kaguya Shinomiya and Miyuki Shirogane are two geniuses who stand atop their prestigious academy’s student council, making them the elite among elite. But it’s lonely at the top and each has fallen for the other. There’s just one huge problem standing in the way of lovey-dovey bliss—they’re both too prideful to be the first to confess their romantic feelings and thus become the “loser” in the competition of love! And so begins their daily schemes to force the other to confess first!"""


@skip_in_ci
def test_ibarahime() -> None:
def test_kaguya_mangadex() -> None:
comic = mandown.query(URL)

expected_res = {
"title": "Good Morning, Sleeping Beauty",
"authors": ["Megumi Morino"],
"title": "Kaguya-sama: Love is War",
"authors": ["Akasaka Aka"],
"genres": [
"Psychological",
"Romance",
"Comedy",
"Drama",
"School Life",
"Slice of Life",
],
"description": DESCRIPTION,
Expand All @@ -28,3 +32,6 @@ def test_ibarahime() -> None:

assert comic.metadata.asdict() == expected_res
assert comic.chapters

first_chapter = comic.get_chapter_image_urls(comic.chapters[0])
assert first_chapter
3 changes: 3 additions & 0 deletions tests/test_source_manganato.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ def test_punpun() -> None:

assert comic.metadata.asdict() == expected_res
assert comic.chapters

first_chapter = comic.get_chapter_image_urls(comic.chapters[0])
assert first_chapter
3 changes: 3 additions & 0 deletions tests/test_source_mangasee.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ def test_kaguya() -> None:

assert comic.metadata.asdict() == expected_res
assert comic.chapters

first_chapter = comic.get_chapter_image_urls(comic.chapters[0])
assert first_chapter
3 changes: 3 additions & 0 deletions tests/test_source_manhuaes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ def test_undefeatable() -> None:

assert comic.metadata.asdict() == expected_res
assert comic.chapters

first_chapter = comic.get_chapter_image_urls(comic.chapters[0])
assert first_chapter
3 changes: 3 additions & 0 deletions tests/test_source_readcomiconline.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ def test_behemoth() -> None:

assert comic.metadata.asdict() == expected_res
assert comic.chapters

first_chapter = comic.get_chapter_image_urls(comic.chapters[0])
assert first_chapter
4 changes: 4 additions & 0 deletions tests/test_source_webtoons.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ def test_reyn() -> None:
}

assert comic.metadata.asdict() == expected_res
assert comic.chapters

first_chapter = comic.get_chapter_image_urls(comic.chapters[0])
assert first_chapter

0 comments on commit 4b488c8

Please sign in to comment.