From cb6fcc59dbba2b8bd7d8d8f87f0a077c13c3da79 Mon Sep 17 00:00:00 2001 From: Devops Bot Date: Thu, 20 Aug 2026 13:18:59 +0000 Subject: [PATCH 1/2] fix: Add podcasts filter to news search --- asknews_sdk/api/news.py | 17 +++++++++++++++-- tests/api/test_news.py | 8 +++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/asknews_sdk/api/news.py b/asknews_sdk/api/news.py index 30298ff..3c4ea37 100644 --- a/asknews_sdk/api/news.py +++ b/asknews_sdk/api/news.py @@ -114,6 +114,7 @@ def search_news( reporting_voice: Optional[Union[List[str], str]] = None, domain_url: Optional[Union[List[str], str]] = None, bad_domain_url: Optional[Union[List[str], str]] = None, + podcasts: Literal["include", "only", "none"] = "include", page_rank: Optional[int] = None, diversify_sources: Optional[bool] = False, strategy: Literal["latest news", "news knowledge", "default"] = "default", @@ -195,6 +196,10 @@ def search_news( :type reporting_voice: Optional[str] :param domain_url: Domain URL, defaults to None :type domain_url: Optional[str] + :param podcasts: Control whether podcasts are included in search results. 'include' + searches news and podcasts, 'only' searches podcasts only, and 'none' + excludes podcasts. Defaults to 'include'. + :type podcasts: Literal["include", "only", "none"] :param page_rank: Page rank, defaults to None :type page_rank: Optional[int] :param http_headers: Additional HTTP headers. @@ -223,6 +228,7 @@ def search_news( "reporting_voice": reporting_voice, "domain_url": domain_url, "bad_domain_url": bad_domain_url, + "podcasts": podcasts, "page_rank": page_rank, "diversify_sources": diversify_sources, "strategy": strategy, @@ -602,6 +608,7 @@ async def search_news( reporting_voice: Optional[Union[List[str], str]] = None, domain_url: Optional[Union[List[str], str]] = None, bad_domain_url: Optional[Union[List[str], str]] = None, + podcasts: Literal["include", "only", "none"] = "include", page_rank: Optional[int] = None, diversify_sources: Optional[bool] = False, strategy: Literal["latest news", "news knowledge", "default"] = "default", @@ -631,9 +638,14 @@ async def search_news( http_headers: Optional[Dict] = None, ) -> SearchResponse: """ - Get time-series counts for a filter + Search for news articles given a query. - https://docs.asknews.app/en/reference#get-/v1/index_counts + https://docs.asknews.app/en/reference#get-/v1/news/search + + :param podcasts: Control whether podcasts are included in search results. 'include' + searches news and podcasts, 'only' searches podcasts only, and 'none' + excludes podcasts. Defaults to 'include'. + :type podcasts: Literal["include", "only", "none"] """ response = await self.client.request( method="GET", @@ -656,6 +668,7 @@ async def search_news( "reporting_voice": reporting_voice, "domain_url": domain_url, "bad_domain_url": bad_domain_url, + "podcasts": podcasts, "page_rank": page_rank, "diversify_sources": diversify_sources, "strategy": strategy, diff --git a/tests/api/test_news.py b/tests/api/test_news.py index be152ba..7651f0e 100644 --- a/tests/api/test_news.py +++ b/tests/api/test_news.py @@ -120,7 +120,10 @@ async def test_async_news_api_get_article(async_news_api: AsyncNewsAPI, response assert mock_route.calls.last.response.status_code == 404 -def test_sync_news_api_search_news(sync_news_api: NewsAPI, response_mock: MockRouter): +@pytest.mark.parametrize("podcasts", ["include", "only", "none"]) +def test_sync_news_api_search_news( + sync_news_api: NewsAPI, response_mock: MockRouter, podcasts: str +): mock_search_response = MockSearchResponse.build() mock_route = response_mock.get("/v1/news/search").respond( @@ -129,6 +132,7 @@ def test_sync_news_api_search_news(sync_news_api: NewsAPI, response_mock: MockRo response = sync_news_api.search_news( "query", + podcasts=podcasts, http_headers={ "custom-header": "custom-value", } @@ -140,6 +144,7 @@ def test_sync_news_api_search_news(sync_news_api: NewsAPI, response_mock: MockRo assert mock_route.called assert mock_route.calls.last.request.url.path == "/v1/news/search" + assert mock_route.calls.last.request.url.params["podcasts"] == podcasts assert mock_route.calls.last.request.method == "GET" assert mock_route.calls.last.request.headers["accept"] == SearchResponse.__content_type__ assert mock_route.calls.last.request.headers["custom-header"] == "custom-value" @@ -166,6 +171,7 @@ async def test_async_news_api_search_news(async_news_api: AsyncNewsAPI, response assert mock_route.called assert mock_route.calls.last.request.url.path == "/v1/news/search" + assert mock_route.calls.last.request.url.params["podcasts"] == "include" assert mock_route.calls.last.request.method == "GET" assert mock_route.calls.last.request.headers["accept"] == SearchResponse.__content_type__ assert mock_route.calls.last.request.headers["custom-header"] == "custom-value" From ccb92c6b5c55047a994c64fce0f3a3e75f79ee73 Mon Sep 17 00:00:00 2001 From: Devops Bot Date: Thu, 20 Aug 2026 13:38:57 +0000 Subject: [PATCH 2/2] fix: Preserve news search positional arguments --- asknews_sdk/api/news.py | 8 ++++---- tests/api/test_news.py | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/asknews_sdk/api/news.py b/asknews_sdk/api/news.py index 3c4ea37..dccb1b8 100644 --- a/asknews_sdk/api/news.py +++ b/asknews_sdk/api/news.py @@ -114,7 +114,6 @@ def search_news( reporting_voice: Optional[Union[List[str], str]] = None, domain_url: Optional[Union[List[str], str]] = None, bad_domain_url: Optional[Union[List[str], str]] = None, - podcasts: Literal["include", "only", "none"] = "include", page_rank: Optional[int] = None, diversify_sources: Optional[bool] = False, strategy: Literal["latest news", "news knowledge", "default"] = "default", @@ -140,6 +139,7 @@ def search_news( geo_radius: Optional[float] = None, geo_polygon: Optional[str] = None, sort_by: Optional[Literal["relevance", "pub_date"]] = None, + podcasts: Literal["include", "only", "none"] = "include", *, http_headers: Optional[Dict] = None, ) -> SearchResponse: @@ -196,12 +196,12 @@ def search_news( :type reporting_voice: Optional[str] :param domain_url: Domain URL, defaults to None :type domain_url: Optional[str] + :param page_rank: Page rank, defaults to None + :type page_rank: Optional[int] :param podcasts: Control whether podcasts are included in search results. 'include' searches news and podcasts, 'only' searches podcasts only, and 'none' excludes podcasts. Defaults to 'include'. :type podcasts: Literal["include", "only", "none"] - :param page_rank: Page rank, defaults to None - :type page_rank: Optional[int] :param http_headers: Additional HTTP headers. :type http_headers: Optional[Dict] :return: The search response. @@ -608,7 +608,6 @@ async def search_news( reporting_voice: Optional[Union[List[str], str]] = None, domain_url: Optional[Union[List[str], str]] = None, bad_domain_url: Optional[Union[List[str], str]] = None, - podcasts: Literal["include", "only", "none"] = "include", page_rank: Optional[int] = None, diversify_sources: Optional[bool] = False, strategy: Literal["latest news", "news knowledge", "default"] = "default", @@ -634,6 +633,7 @@ async def search_news( geo_radius: Optional[float] = None, geo_polygon: Optional[str] = None, sort_by: Optional[Literal["relevance", "pub_date"]] = None, + podcasts: Literal["include", "only", "none"] = "include", *, http_headers: Optional[Dict] = None, ) -> SearchResponse: diff --git a/tests/api/test_news.py b/tests/api/test_news.py index 7651f0e..11a71e1 100644 --- a/tests/api/test_news.py +++ b/tests/api/test_news.py @@ -151,7 +151,10 @@ def test_sync_news_api_search_news( assert mock_route.calls.last.response.status_code == 200 -async def test_async_news_api_search_news(async_news_api: AsyncNewsAPI, response_mock: MockRouter): +@pytest.mark.parametrize("podcasts", ["include", "only", "none"]) +async def test_async_news_api_search_news( + async_news_api: AsyncNewsAPI, response_mock: MockRouter, podcasts: str +): mock_search_response = MockSearchResponse.build() mock_route = response_mock.get("/v1/news/search").respond( @@ -160,6 +163,7 @@ async def test_async_news_api_search_news(async_news_api: AsyncNewsAPI, response response = await async_news_api.search_news( "query", + podcasts=podcasts, http_headers={ "custom-header": "custom-value", } @@ -171,7 +175,7 @@ async def test_async_news_api_search_news(async_news_api: AsyncNewsAPI, response assert mock_route.called assert mock_route.calls.last.request.url.path == "/v1/news/search" - assert mock_route.calls.last.request.url.params["podcasts"] == "include" + assert mock_route.calls.last.request.url.params["podcasts"] == podcasts assert mock_route.calls.last.request.method == "GET" assert mock_route.calls.last.request.headers["accept"] == SearchResponse.__content_type__ assert mock_route.calls.last.request.headers["custom-header"] == "custom-value"