@@ -62,16 +62,34 @@ def gdelt_paging_server():
6262 pages = [
6363 {
6464 "articles" : [
65- {"url" : "https://a.test/1" , "title" : "Newest A" , "seendate" : "20240615T120000Z" ,
66- "domain" : "a.test" , "language" : "English" , "sourcecountry" : "United States" },
67- {"url" : "https://a.test/2" , "title" : "Newest B" , "seendate" : "20240615T100000Z" ,
68- "domain" : "a.test" , "language" : "English" , "sourcecountry" : "United States" },
65+ {
66+ "url" : "https://a.test/1" ,
67+ "title" : "Newest A" ,
68+ "seendate" : "20240615T120000Z" ,
69+ "domain" : "a.test" ,
70+ "language" : "English" ,
71+ "sourcecountry" : "United States" ,
72+ },
73+ {
74+ "url" : "https://a.test/2" ,
75+ "title" : "Newest B" ,
76+ "seendate" : "20240615T100000Z" ,
77+ "domain" : "a.test" ,
78+ "language" : "English" ,
79+ "sourcecountry" : "United States" ,
80+ },
6981 ]
7082 },
7183 {
7284 "articles" : [
73- {"url" : "https://a.test/3" , "title" : "Older C" , "seendate" : "20240614T080000Z" ,
74- "domain" : "a.test" , "language" : "English" , "sourcecountry" : "France" },
85+ {
86+ "url" : "https://a.test/3" ,
87+ "title" : "Older C" ,
88+ "seendate" : "20240614T080000Z" ,
89+ "domain" : "a.test" ,
90+ "language" : "English" ,
91+ "sourcecountry" : "France" ,
92+ },
7593 ]
7694 },
7795 ]
@@ -91,9 +109,7 @@ def test_news_providers_lists_providers():
91109 with _client () as client :
92110 table = _collect (client .table_function (function_name = "news_providers" ))
93111 assert table .column_names == ["provider" , "requires_key" ]
94- providers = dict (
95- zip (table .column ("provider" ).to_pylist (), table .column ("requires_key" ).to_pylist (), strict = True )
96- )
112+ providers = dict (zip (table .column ("provider" ).to_pylist (), table .column ("requires_key" ).to_pylist (), strict = True ))
97113 assert providers == {"gdelt" : False , "newsapi" : True }
98114
99115
@@ -107,7 +123,15 @@ def test_news_search_unified_schema_and_types(mock_gdelt, worker_env):
107123 )
108124 )
109125 assert table .column_names == [
110- "title" , "url" , "domain" , "language" , "seendate" , "country" , "tone" , "source" , "extra" ,
126+ "title" ,
127+ "url" ,
128+ "domain" ,
129+ "language" ,
130+ "seendate" ,
131+ "country" ,
132+ "tone" ,
133+ "source" ,
134+ "extra" ,
111135 ]
112136 # seendate is a real TIMESTAMPTZ.
113137 seendate_type = table .schema .field ("seendate" ).type
@@ -149,30 +173,28 @@ def test_scan_state_round_trips_across_batch_boundary(gdelt_paging_server, worke
149173def test_newsapi_path_via_mock_requires_secret (mock_newsapi , worker_env ):
150174 """Without a secret configured, the newsapi provider errors cleanly (no crash)."""
151175 worker_env ({"VGI_NEWS_NEWSAPI_BASE_URL" : mock_newsapi })
152- with _client () as client :
153- with pytest .raises (Exception ) as excinfo :
154- _collect (
155- client .table_function (
156- function_name = "news_search" ,
157- arguments = Arguments (
158- positional = [pa .scalar ("elections" )],
159- named = {"provider" : pa .scalar ("newsapi" )},
160- ),
161- )
176+ with _client () as client , pytest .raises (Exception ) as excinfo :
177+ _collect (
178+ client .table_function (
179+ function_name = "news_search" ,
180+ arguments = Arguments (
181+ positional = [pa .scalar ("elections" )],
182+ named = {"provider" : pa .scalar ("newsapi" )},
183+ ),
162184 )
185+ )
163186 assert "API key" in str (excinfo .value ) or "secret" in str (excinfo .value ).lower ()
164187
165188
166189def test_unknown_provider_errors_clean ():
167- with _client () as client :
168- with pytest .raises (Exception ) as excinfo :
169- _collect (
170- client .table_function (
171- function_name = "news_search" ,
172- arguments = Arguments (
173- positional = [pa .scalar ("x" )],
174- named = {"provider" : pa .scalar ("nope" )},
175- ),
176- )
190+ with _client () as client , pytest .raises (Exception ) as excinfo :
191+ _collect (
192+ client .table_function (
193+ function_name = "news_search" ,
194+ arguments = Arguments (
195+ positional = [pa .scalar ("x" )],
196+ named = {"provider" : pa .scalar ("nope" )},
197+ ),
177198 )
199+ )
178200 assert "unknown provider" in str (excinfo .value ).lower ()
0 commit comments