Esempio n. 1
0
def test_get_main_url_with_extension():
    assert (
        utils.get_main_url(
            utils.BASE_URL, "manga", 2, extension="characters", page=None
        )
        == "https://api.jikan.moe/v3/manga/2/characters"
    )
Esempio n. 2
0
 def _get(
     self,
     endpoint: str,
     id: int,
     extension: Optional[str],
     page: Optional[int] = None,
 ) -> Dict[str, Any]:
     """Gets the response from Jikan API given the endpoint:
     anime, manga, character, person, club
     """
     url = utils.get_main_url(self.base, endpoint, id, extension, page)
     return self._request(url, id=id, endpoint=endpoint)
Esempio n. 3
0
async def test_wrap_response(aio_jikan):
    anime_info = await aio_jikan.anime(MUSHISHI_ID)
    mushishi_url = utils.get_main_url(
        aio_jikan.base, "anime", MUSHISHI_ID, extension=None, page=None
    )

    assert isinstance(anime_info, dict)
    assert "jikan_url" in anime_info
    assert "headers" in anime_info
    assert isinstance(anime_info["headers"], dict)
    assert mushishi_url == anime_info["jikan_url"]
    await aio_jikan.close()
Esempio n. 4
0
def test_wrap_response(header_keys, jikan):
    anime_info = jikan.anime(MUSHISHI_ID)
    mushishi_url = utils.get_main_url(jikan.base,
                                      "anime",
                                      MUSHISHI_ID,
                                      extension=None,
                                      page=None)

    assert isinstance(anime_info, dict)
    assert "jikan_url" in anime_info
    assert "headers" in anime_info
    assert isinstance(anime_info["headers"], dict)
    assert mushishi_url == anime_info["jikan_url"]
    # Test against headers mentioned in documentation
    # https://jikan.docs.apiary.io/#introduction/information/caching
    assert header_keys.issubset(anime_info["headers"].keys())
Esempio n. 5
0
def test_get_main_url_with_no_extension_and_page():
    assert (
        utils.get_main_url(utils.BASE_URL, "manga", 2, extension=None, page=2)
        == "https://api.jikan.moe/v3/manga/2"
    )
Esempio n. 6
0
def test_get_main_url_with_extension_and_page():
    assert (
        utils.get_main_url(utils.BASE_URL, "anime", 2, extension="episodes", page=2)
        == "https://api.jikan.moe/v3/anime/2/episodes/2"
    )
Esempio n. 7
0
def test_get_main_url():
    assert (
        utils.get_main_url(utils.BASE_URL, "anime", 2, extension=None, page=None)
        == "https://api.jikan.moe/v3/anime/2"
    )