How to use the jikanpy.utils.BASE_URL function in jikanpy

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_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_jikan.py View on Github external
def test_empty_response_json(jikan, response_mock):
    with pytest.raises(APIException) as err_info:
        jikan._wrap_response(response_mock, url=utils.BASE_URL, param=1)

    err = err_info.value
    err_text = response_mock.text
    assert err.status_code == response_mock.status_code
    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 {response_mock.status_code} - error={err_text} for param=1"
    )
    assert repr(err).startswith(
        f"APIException(status_code={response_mock.status_code}, error_json={{'error': '"
    )
github AWConant / jikanpy / tests / test_utils.py View on Github external
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"
    )
github AWConant / jikanpy / jikanpy / aiojikan.py View on Github external
the official Jikan API URL.
            session (aiohttp.ClientSession, optional) -- Requests session.
                Defaults to a new aiohttp session object.

        Returns:
            AioJikan: Instance of AioJikan.

        Examples:
            >>> aio_jikan_1 = AioJikan()
            >>> aio_jikan_2 = AioJikan(selected_base='http://localhost:8000/v3')
            >>> aio_jikan_3 = AioJikan(
                    session=aiohttp.ClientSession(headers={'x-test': 'true'})
                )
        """
        self.base = (
            utils.BASE_URL if selected_base is None else selected_base.rstrip("/ ")
        )
        self.session = session
github AWConant / jikanpy / jikanpy / jikan.py View on Github external
Args:
            selected_base (str, optional): Base url of Jikan API. Defaults to
                the official Jikan API URL.
            session (requests.Session, optional) -- Requests session. Defaults
                to a new Requests session object.

        Returns:
            Jikan: Instance of Jikan.

        Examples:
            >>> jikan_1 = Jikan()
            >>> jikan_2 = Jikan(selected_base='http://localhost:8000/v3')
            >>> jikan_3 = jikan = Jikan(session=requests.Session())
        """
        self.base = (
            utils.BASE_URL if selected_base is None else selected_base.rstrip("/ ")
        )
        self.session = requests.Session() if session is None else session