~nhanb/pytaku

ref: fd3f4fbbe8130926062f2e667f9692380edef507 pytaku/tests/mangoapi/test_mangasee.py -rw-r--r-- 2.2 KiB
fd3f4fbbBùi Thành Nhân apparently builds.srht now has branch in tags? 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from mangoapi.mangasee import Mangasee


def test_get_title():
    title = Mangasee().get_title("Yu-Yu-Hakusho")
    chapters = title.pop("chapters")
    assert title == {
        "id": "Yu-Yu-Hakusho",
        "name": "Yu Yu Hakusho",
        "site": "mangasee",
        "cover_ext": "jpg",
        "alt_names": [],
        "descriptions": [
            "Yusuke Urameshi was a tough teen delinquent until one selfless act changed his life... by ending it. When he died saving a little kid from a speeding car, the afterlife didn't know what to do with him, so it gave him a second chance at life. Now, Yusuke is a ghost with a mission, performing good deeds at the behest of Botan, the ferrywoman of the River Styx, and Koenma, the pacifier-sucking judge of the dead."
        ],
        "descriptions_format": "text",
        "is_webtoon": False,
    }
    assert len(chapters) == 176
    assert chapters[112] == {
        "groups": [],
        "id": "100635",
        "raw_id": "100635",
        "name": "",
        "num_major": 63,
        "num_minor": 5,
        "number": "63.5",
        "volume": "",
    }


def test_get_chapter():
    chapter = Mangasee().get_chapter("Yu-Yu-Hakusho", "100635")
    pages = chapter.pop("pages")
    pages_alt = chapter.pop("pages_alt")
    assert chapter == {
        "groups": [],
        "id": "100635",
        "raw_id": "100635",
        "name": "",
        "num_major": 63,
        "num_minor": 5,
        "number": "63.5",
        "site": "mangasee",
        "title_id": "Yu-Yu-Hakusho",
    }
    assert pages[0].endswith("/manga/Yu-Yu-Hakusho/0063.5-001.png")
    assert pages[-1].endswith("/manga/Yu-Yu-Hakusho/0063.5-031.png")
    assert pages_alt == []


def test_search_title():
    class DictKeyvalStore(dict):
        def get(self, key):
            return self[key]

        def set(self, key, val):
            self[key] = val

    ms = Mangasee()
    ms.keyval_store = DictKeyvalStore()
    results = ms.search_title("sayonara football")
    assert results == [
        {
            "id": "Sayonara-Football",
            "name": "Sayonara, Football",
            "site": "mangasee",
            "thumbnail": "https://cover.nep.li/cover/Sayonara-Football.jpg",
        }
    ]