micro-fix: remove obsolete _PushoverClient tests
- the test suite still referenced _PushoverClient, which no longer exists - this caused import errors and failing pytest runs - removed all tests related to _PushoverClient - fixed pytest execution errors - removed dead test code - ensured test coverage reflects the current implementation
This commit is contained in:
@@ -1,98 +1,7 @@
|
||||
"""Tests for Pushover tool."""
|
||||
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from aden_tools.tools.pushover_tool.pushover_tool import (
|
||||
_PushoverClient,
|
||||
register_tools,
|
||||
)
|
||||
|
||||
|
||||
class TestPushoverClient:
|
||||
"""Tests for _PushoverClient."""
|
||||
|
||||
def setup_method(self):
|
||||
self.client = _PushoverClient(
|
||||
token="test_token",
|
||||
user_key="test_user_key",
|
||||
)
|
||||
|
||||
def _mock_response(self, status_code=200, json_data=None):
|
||||
mock = MagicMock()
|
||||
mock.status_code = status_code
|
||||
mock.json.return_value = json_data or {"status": 1, "request": "abc123"}
|
||||
mock.text = "OK"
|
||||
return mock
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_send_notification_success(self, mock_post):
|
||||
mock_post.return_value = self._mock_response()
|
||||
result = self.client.send_notification("Test message", title="Test")
|
||||
assert result["status"] == 1
|
||||
assert result["request"] == "abc123"
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_send_notification_emergency_priority(self, mock_post):
|
||||
mock_post.return_value = self._mock_response()
|
||||
_result = self.client.send_notification("Emergency!", priority=2)
|
||||
call_kwargs = mock_post.call_args[1]["data"]
|
||||
assert call_kwargs["retry"] == 30
|
||||
assert call_kwargs["expire"] == 3600
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_send_notification_rate_limited(self, mock_post):
|
||||
mock_post.return_value = self._mock_response(status_code=429)
|
||||
result = self.client.send_notification("Test")
|
||||
assert "error" in result
|
||||
assert "Rate limit" in result["error"]
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_send_notification_api_error(self, mock_post):
|
||||
mock_post.return_value = self._mock_response(
|
||||
json_data={"status": 0, "errors": ["invalid token"]}
|
||||
)
|
||||
result = self.client.send_notification("Test")
|
||||
assert "error" in result
|
||||
assert "invalid token" in result["error"]
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_send_notification_with_url(self, mock_post):
|
||||
mock_post.return_value = self._mock_response()
|
||||
result = self.client.send_notification_with_url(
|
||||
"Check this out",
|
||||
url="https://example.com",
|
||||
url_title="Example",
|
||||
)
|
||||
assert result["status"] == 1
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.get")
|
||||
def test_get_sounds(self, mock_get):
|
||||
mock_get.return_value = self._mock_response(
|
||||
json_data={"status": 1, "sounds": {"pushover": "Pushover (default)"}}
|
||||
)
|
||||
result = self.client.get_sounds()
|
||||
assert "sounds" in result
|
||||
assert "pushover" in result["sounds"]
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_validate_user_success(self, mock_post):
|
||||
mock_post.return_value = self._mock_response(
|
||||
json_data={"status": 1, "devices": ["iphone", "android"]}
|
||||
)
|
||||
result = self.client.validate_user()
|
||||
assert result["status"] == 1
|
||||
assert "iphone" in result["devices"]
|
||||
|
||||
@patch("aden_tools.tools.pushover_tool.pushover_tool.httpx.post")
|
||||
def test_validate_user_with_device(self, mock_post):
|
||||
mock_post.return_value = self._mock_response(json_data={"status": 1, "devices": ["iphone"]})
|
||||
_result = self.client.validate_user(device="iphone")
|
||||
call_kwargs = mock_post.call_args[1]["data"]
|
||||
assert call_kwargs["device"] == "iphone"
|
||||
|
||||
from aden_tools.tools.pushover_tool.pushover_tool import register_tools
|
||||
|
||||
class TestRegisterTools:
|
||||
"""Tests for register_tools MCP tool functions."""
|
||||
|
||||
def setup_method(self):
|
||||
self.mcp = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user