How to use jikanpy - 10 common examples

To help you get started, we’ve selected a few jikanpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AWConant / jikanpy / tests / test_utils.py View on Github external
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"
    )
github AWConant / jikanpy / tests / test_aiojikan.py View on Github external
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()
github AWConant / jikanpy / tests / test_jikan.py View on Github external
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())
github AWConant / jikanpy / tests / test_aiojikan.py View on Github external
async def test_empty_response_json(aio_jikan, aio_response_mock):
    with pytest.raises(APIException) as err_info:
        await aio_jikan._wrap_response(aio_response_mock, url=utils.BASE_URL, param=1)

    err = err_info.value
    err_text = await aio_response_mock.text()
    assert err.status_code == aio_response_mock.status
    assert isinstance(err.error_json, dict)
    assert "error" in err.error_json
    assert err.error_json["error"] == err_text
    assert isinstance(err.relevant_params, dict)
    assert "param" in err.relevant_params
    assert err.relevant_params["param"] == 1
    assert str(err) == f"HTTP {aio_response_mock.status} - error={err_text} for param=1"
    assert repr(err).startswith(
        f"APIException(status_code={aio_response_mock.status}, error_json={{'error': '"
    )
    assert repr(err).endswith("'}, relevant_params={'param': 1})")
github AWConant / jikanpy / tests / test_utils.py View on Github external
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"
    )
github AWConant / jikanpy / tests / test_utils.py View on Github external
def test_get_url_with_page():
    assert utils.get_url_with_page(utils.BASE_URL, 2) == "https://api.jikan.moe/v3/2"
github AWConant / jikanpy / tests / test_utils.py View on Github external
def test_get_user_url_with_friends_and_page():
    assert (
        utils.get_user_url(
            utils.BASE_URL,
            "Xinil",
            request="friends",
            argument=None,
            page=2,
            parameters=None,
        )
        == "https://api.jikan.moe/v3/user/xinil/friends/2"
    )
github AWConant / jikanpy / tests / test_utils.py View on Github external
def test_get_user_url_with_anime_history():
    assert (
        utils.get_user_url(
            utils.BASE_URL,
            "Xinil",
            request="history",
            argument="anime",
            page=None,
            parameters=None,
        )
        == "https://api.jikan.moe/v3/user/xinil/history/anime"
    )
github AWConant / jikanpy / tests / test_utils.py View on Github external
def test_get_user_url():
    assert (
        utils.get_user_url(
            utils.BASE_URL,
            "Xinil",
            request=None,
            argument=None,
            page=None,
            parameters=None,
        )
        == "https://api.jikan.moe/v3/user/xinil"
    )
github AWConant / jikanpy / tests / test_utils.py View on Github external
def test_get_user_url_with_animelist_and_page_parameter():
    assert (
        utils.get_user_url(
            utils.BASE_URL,
            "Xinil",
            request="animelist",
            argument="completed",
            page=None,
            parameters={"page": 2},
        )
        == "https://api.jikan.moe/v3/user/xinil/animelist/completed?page=2"
    )