Skip to content

Commit

Permalink
fix test coverage CLI version failed case
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault committed Nov 28, 2024
1 parent 7c4e188 commit 3bb6c42
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,3 +600,14 @@ def test_subscriber_parsing(expect_error, subscriber_option, subscriber_dest, su
else:
assert expect_error is None, f"Test was expected to fail with {expect_error}, but did not raise"
assert dict(**vars(ns)) == subscriber_result # pylint: disable=R1735


@pytest.mark.cli
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("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
2 changes: 1 addition & 1 deletion weaver/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ def version(
headers=self._headers, x_headers=headers, settings=self._settings, auth=auth,
request_timeout=request_timeout, request_retries=request_retries
)
if resp.status_code != 200:
if resp.code != 200:
no_ver = "This server might not implement the '/versions' endpoint."
return OperationResult(
False, f"Failed to obtain server version. {no_ver}",
Expand Down

0 comments on commit 3bb6c42

Please sign in to comment.