add tests, update metadatahandler

This commit is contained in:
2025-04-24 18:35:55 +02:00
parent 8f2087be5d
commit e3d8a36c9b
3 changed files with 57 additions and 0 deletions

View File

@@ -55,7 +55,9 @@ def description(metadata: Manga) -> str:
desc = metadata.description
if desc:
desc = desc.split("\n<br><br>\n(")[0]
desc = desc.split("\n<BR><BR>\n")[0]
desc = desc.replace("<br>", "")
desc = desc.replace("<BR>", "")
return desc
return metadata.description

0
tests/__init__.py Normal file
View File

55
tests/test_manga.py Normal file
View File

@@ -0,0 +1,55 @@
import pytest
from anilistapi.schemas.manga import Manga
testmanga = {
"id": 107134,
"title": {
"romaji": "Nanatsu no Maken ga Shihai Suru",
"english": "Reign of the Seven Spellblades",
"native": "七つの魔剣が支配する",
},
"type": "MANGA",
"format": "MANGA",
"synonyms": ["Seven Magic Swords Rule", "Nanatsuma", "ななつま"],
"status": "FINISHED",
"genres": ["Action", "Fantasy"],
"tags": [
{"name": "Shounen", "isAdult": False},
{"name": "School", "isAdult": False},
{"name": "Magic", "isAdult": False},
{"name": "Swordplay", "isAdult": False},
],
"description": "Its springtime at Kimberly Magic Academy, and that means the arrival of a fresh crop of first-year students. Whether its the quiet and studious Oliver Horn or Nanao Hibiya, a samurai girl from a distant land, they come with wands and swords at their waists, ready to take their first steps on the road to magical mastery. However, beneath its brilliant facade of cherry blossoms, the academy hides countless dangers and dark secrets, ready to take the lives of the unprepared…!\n<br><br>\n(Source: Yen Press) ",
"coverImage": {
"large": "https://s4.anilist.co/file/anilistcdn/media/manga/cover/medium/bx107134-VJ3gvvxKTvec.jpg"
},
"isAdult": False,
"chapters": 46,
"volumes": 8,
"externalLinks": [
{
"site": "ComicWalker",
"url": "https://comic-walker.com/contents/detail/KDCW_KS01201140010000_68/",
"type": "STREAMING",
},
{
"site": "Yen Press",
"url": "https://yenpress.com/series/reign-of-the-seven-spellblades-manga",
"type": "INFO",
},
{
"site": "Web Ace",
"url": "https://web-ace.jp/shonenace/contents/397/",
"type": "STREAMING",
},
],
"countryOfOrigin": "JP",
}
def test_manga():
manga = Manga(**testmanga)
assert manga.id == 107134
assert manga.isManga is True
assert manga.isLightNovel is False