Skip to content

Commit

Permalink
properly fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Nov 29, 2024
1 parent fe77cfc commit bc0d360
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ def test_cli_version_non_weaver():
"""
Tests that the ``version`` operation is handled gracefully for a server not supporting it (Weaver-specific).
"""
with mock.patch("requests.Session.request", return_value=MockedResponse(body="", status="404 Not Found")):
with mock.patch("weaver.cli.WeaverClient._request", return_value=OperationResult(success=False, code=404)):
result = WeaverClient(url="https://fake.domain.com").version()
with mock.patch("weaver.cli.WeaverClient._request", return_value=OperationResult(success=False, code=404)):
result = WeaverClient(url="https://fake.domain.com").version()
assert result.code == 404
assert "Failed to obtain server version." in result.message
7 changes: 4 additions & 3 deletions weaver/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,14 @@ def version(
headers=self._headers, x_headers=headers, settings=self._settings, auth=auth,
request_timeout=request_timeout, request_retries=request_retries
)
if resp.code != 200:
result = self._parse_result(resp, with_links=with_links, with_headers=with_headers, output_format=output_format)
if result.code != 200:
no_ver = "This server might not implement the '/versions' endpoint."
return OperationResult(
False, f"Failed to obtain server version. {no_ver}",
body=resp.body, text=resp.text, code=resp.code, headers=resp.headers
body=result.body, text=result.text, code=result.code, headers=result.headers
)
return self._parse_result(resp, with_links=with_links, with_headers=with_headers, output_format=output_format)
return result

def conformance(
self,
Expand Down

0 comments on commit bc0d360

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy