Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_get_search_url():
assert (
utils.get_search_url(
utils.BASE_URL, "anime", "jojo", page=None, parameters=None
)
== "https://api.jikan.moe/v3/search/anime?q=jojo"
)
def test_get_search_url_with_parameters():
assert (
utils.get_search_url(
utils.BASE_URL, "anime", "jojo", page=None, parameters={"a": "x", "b": "y"},
)
== "https://api.jikan.moe/v3/search/anime?q=jojo&a=x&b=y"
)
def test_get_search_url_with_page_and_parameters():
assert (
utils.get_search_url(
utils.BASE_URL, "anime", "jojo", page=2, parameters={"a": "x", "b": "y"},
)
== "https://api.jikan.moe/v3/search/anime?q=jojo&page=2&a=x&b=y"
)
def test_get_search_url_with_page():
assert (
utils.get_search_url(utils.BASE_URL, "anime", "jojo", page=2, parameters=None)
== "https://api.jikan.moe/v3/search/anime?q=jojo&page=2"
)
None.
parameters (:obj:`dict`, optional): Dictionary containing key,value
pairs for ?key=value in url query. Defaults to None.
Returns:
Dict: Dictionary containing search results.
Examples:
>>> await jikan.search('anime', 'Jojo')
>>> await jikan.search('anime', 'Jojo', page=2)
>>> await jikan.search('anime', 'Jojo', parameters={'type': 'tv'})
>>> await jikan.search(
'anime', 'Jojo', page=2, parameters={'genre': 37, 'type': 'tv'}
)
"""
url = utils.get_search_url(self.base, search_type, query, page, parameters)
kwargs = {"search type": search_type, "query": query}
return await self._request(url, **kwargs)
None.
parameters (:obj:`dict`, optional): Dictionary containing key,value
pairs for ?key=value in url query. Defaults to None.
Returns:
Dict: Dictionary containing search results.
Examples:
>>> jikan.search('anime', 'Jojo')
>>> jikan.search('anime', 'Jojo', page=2)
>>> jikan.search('anime', 'Jojo', parameters={'type': 'tv'})
>>> jikan.search(
'anime', 'Jojo', page=2, parameters={'genre': 37, 'type': 'tv'}
)
"""
url = utils.get_search_url(self.base, search_type, query, page, parameters)
kwargs = {"search type": search_type, "query": query}
return self._request(url, **kwargs)