Skip to content

Commit a8d0075

Browse files
authored
fix: correct test there is no free-api log (#276)
that `any` line was never executed before since the error is throw after `session.general.partition`
1 parent c380230 commit a8d0075

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

_test_unstructured_client/unit/test_custom_hooks.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def test_unit_clean_server_url_fixes_malformed_urls_with_positional_arguments(se
230230
)
231231

232232

233-
def test_unit_issues_warning_on_a_401(caplog, session_: Mock, response_: requests.Session):
233+
def test_after_error_hook_logs(caplog, session_: Mock, response_: requests.Session):
234234
def mock_post(request):
235235
return Response(401, request=request)
236236

@@ -245,15 +245,13 @@ def mock_post(request):
245245
req = operations.PartitionRequest(
246246
partition_parameters=shared.PartitionParameters(files=files)
247247
)
248-
249248
with pytest.raises(SDKError, match="API error occurred: Status 401"):
250-
with caplog.at_level(logging.WARNING):
251-
session.general.partition(request=req)
252-
253-
assert any(
254-
"This API key is invalid against the paid API. If intending to use the free API, please initialize UnstructuredClient with `server='free-api'`."
255-
in message for message in caplog.messages
256-
)
249+
session.general.partition(request=req)
250+
251+
assert any(
252+
"Server responded with 401"
253+
in message for message in caplog.messages
254+
)
257255

258256

259257
# -- fixtures --------------------------------------------------------------------------------

0 commit comments

Comments
 (0)