From 4261bacf757cb40f8cf21730bd0477619caf480a Mon Sep 17 00:00:00 2001 From: manusjs Date: Mon, 6 Jul 2026 16:06:35 +0000 Subject: [PATCH] test(submit-cves): align missing-URL tests with error-status contract Two competing PRs (#92, #93) merged with conflicting expectations for submit_cves() when no webhook URL is configured. PR #93 deliberately moved URL validation inside the try block so a missing URL returns {"status": "error"} instead of raising ValueError (see source comment), and its tests in test_bug_fixes.py assert that contract. PR #92 added TestSubmitCvesMissingUrl in test_submit_cves_and_logger.py that still expects the removed `raise ValueError`, breaking main CI (2 failed). Update the two stale tests to assert the error-status dict contract, matching the source's documented behavior and the passing sibling tests. Drop the now-unused pytest import (F401). Full suite: 1154 passed, ruff clean. --- tests/test_submit_cves_and_logger.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_submit_cves_and_logger.py b/tests/test_submit_cves_and_logger.py index c6e2e94..09b9acf 100644 --- a/tests/test_submit_cves_and_logger.py +++ b/tests/test_submit_cves_and_logger.py @@ -8,8 +8,6 @@ from unittest.mock import MagicMock, patch -import pytest - # --------------------------------------------------------------------------- # Helpers # --------------------------------------------------------------------------- @@ -207,8 +205,9 @@ def test_result_has_tool_use_id(self, monkeypatch): class TestSubmitCvesMissingUrl: - def test_no_url_raises_value_error(self, monkeypatch): - """When neither config nor env has a webhook URL, submit_cves raises ValueError.""" + def test_no_url_returns_error_status(self, monkeypatch): + """When neither config nor env has a webhook URL, submit_cves returns an + error-status dict instead of raising ValueError to the caller.""" monkeypatch.delenv("CVE_SUBMIT_URL", raising=False) with patch("manus_agent.tools.submit_cves.Config") as mock_config: cfg = MagicMock() @@ -217,11 +216,11 @@ def test_no_url_raises_value_error(self, monkeypatch): from manus_agent.tools.submit_cves import submit_cves - with pytest.raises(ValueError, match="webhook URL"): - submit_cves(_make_tool_use()) + result = submit_cves(_make_tool_use()) + assert result["status"] == "error" def test_no_url_error_message_mentions_config_toml(self, monkeypatch): - """ValueError message should guide users to config.toml.""" + """Error message should guide users to config.toml.""" monkeypatch.delenv("CVE_SUBMIT_URL", raising=False) with patch("manus_agent.tools.submit_cves.Config") as mock_config: cfg = MagicMock() @@ -230,8 +229,9 @@ def test_no_url_error_message_mentions_config_toml(self, monkeypatch): from manus_agent.tools.submit_cves import submit_cves - with pytest.raises(ValueError, match="config.toml"): - submit_cves(_make_tool_use()) + result = submit_cves(_make_tool_use()) + assert result["status"] == "error" + assert "config.toml" in result["content"][0]["text"] # ===========================================================================