diff --git a/tests/test_cli.py b/tests/test_cli.py index 9cb245279..b78ce9b3b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -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 diff --git a/weaver/cli.py b/weaver/cli.py index 6513e89e6..1621c3e4e 100644 --- a/weaver/cli.py +++ b/weaver/cli.py @@ -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}",