chore: fixed imports and tests configuration
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from agent.tools import api as api_tools
|
||||
from infrastructure.persistence import get_memory
|
||||
from alfred.agent.tools import api as api_tools
|
||||
from alfred.infrastructure.persistence import get_memory
|
||||
|
||||
|
||||
def create_mock_response(status_code, json_data=None, text=None):
|
||||
@@ -21,7 +21,7 @@ def create_mock_response(status_code, json_data=None, text=None):
|
||||
class TestFindMediaImdbId:
|
||||
"""Tests for find_media_imdb_id tool."""
|
||||
|
||||
@patch("infrastructure.api.tmdb.client.requests.get")
|
||||
@patch("alfred.infrastructure.api.tmdb.client.requests.get")
|
||||
def test_success(self, mock_get, memory):
|
||||
"""Should return movie info on success."""
|
||||
|
||||
@@ -56,7 +56,7 @@ class TestFindMediaImdbId:
|
||||
# Verify HTTP calls
|
||||
assert mock_get.call_count == 2
|
||||
|
||||
@patch("infrastructure.api.tmdb.client.requests.get")
|
||||
@patch("alfred.infrastructure.api.tmdb.client.requests.get")
|
||||
def test_stores_in_stm(self, mock_get, memory):
|
||||
"""Should store result in STM on success."""
|
||||
|
||||
@@ -88,7 +88,7 @@ class TestFindMediaImdbId:
|
||||
assert entity["title"] == "Inception"
|
||||
assert mem.stm.current_topic == "searching_media"
|
||||
|
||||
@patch("infrastructure.api.tmdb.client.requests.get")
|
||||
@patch("alfred.infrastructure.api.tmdb.client.requests.get")
|
||||
def test_not_found(self, mock_get, memory):
|
||||
"""Should return error when not found."""
|
||||
mock_get.return_value = create_mock_response(200, json_data={"results": []})
|
||||
@@ -98,7 +98,7 @@ class TestFindMediaImdbId:
|
||||
assert result["status"] == "error"
|
||||
assert result["error"] == "not_found"
|
||||
|
||||
@patch("infrastructure.api.tmdb.client.requests.get")
|
||||
@patch("alfred.infrastructure.api.tmdb.client.requests.get")
|
||||
def test_does_not_store_on_error(self, mock_get, memory):
|
||||
"""Should not store in STM on error."""
|
||||
mock_get.return_value = create_mock_response(200, json_data={"results": []})
|
||||
@@ -112,7 +112,7 @@ class TestFindMediaImdbId:
|
||||
class TestFindTorrent:
|
||||
"""Tests for find_torrent tool."""
|
||||
|
||||
@patch("infrastructure.api.knaben.client.requests.post")
|
||||
@patch("alfred.infrastructure.api.knaben.client.requests.post")
|
||||
def test_success(self, mock_post, memory):
|
||||
"""Should return torrents on success."""
|
||||
mock_post.return_value = create_mock_response(
|
||||
@@ -146,7 +146,7 @@ class TestFindTorrent:
|
||||
payload = mock_post.call_args[1]["json"]
|
||||
assert payload["query"] == "Inception 1080p"
|
||||
|
||||
@patch("infrastructure.api.knaben.client.requests.post")
|
||||
@patch("alfred.infrastructure.api.knaben.client.requests.post")
|
||||
def test_stores_in_episodic(self, mock_post, memory):
|
||||
"""Should store results in episodic memory."""
|
||||
mock_post.return_value = create_mock_response(
|
||||
@@ -171,7 +171,7 @@ class TestFindTorrent:
|
||||
assert mem.episodic.last_search_results["query"] == "Inception"
|
||||
assert mem.stm.current_topic == "selecting_torrent"
|
||||
|
||||
@patch("infrastructure.api.knaben.client.requests.post")
|
||||
@patch("alfred.infrastructure.api.knaben.client.requests.post")
|
||||
def test_results_have_indexes(self, mock_post, memory):
|
||||
"""Should add indexes to results."""
|
||||
mock_post.return_value = create_mock_response(
|
||||
@@ -211,7 +211,7 @@ class TestFindTorrent:
|
||||
assert results[1]["index"] == 2
|
||||
assert results[2]["index"] == 3
|
||||
|
||||
@patch("infrastructure.api.knaben.client.requests.post")
|
||||
@patch("alfred.infrastructure.api.knaben.client.requests.post")
|
||||
def test_not_found(self, mock_post, memory):
|
||||
"""Should return error when no torrents found."""
|
||||
mock_post.return_value = create_mock_response(200, json_data={"hits": []})
|
||||
@@ -286,7 +286,7 @@ class TestAddTorrentToQbittorrent:
|
||||
This is acceptable mocking because we're testing the TOOL logic, not the client.
|
||||
"""
|
||||
|
||||
@patch("agent.tools.api.qbittorrent_client")
|
||||
@patch("alfred.agent.tools.api.qbittorrent_client")
|
||||
def test_success(self, mock_client, memory):
|
||||
"""Should add torrent successfully and update memory."""
|
||||
mock_client.add_torrent.return_value = True
|
||||
@@ -298,7 +298,7 @@ class TestAddTorrentToQbittorrent:
|
||||
# Verify client was called correctly
|
||||
mock_client.add_torrent.assert_called_once_with("magnet:?xt=urn:btih:abc123")
|
||||
|
||||
@patch("agent.tools.api.qbittorrent_client")
|
||||
@patch("alfred.agent.tools.api.qbittorrent_client")
|
||||
def test_adds_to_active_downloads(self, mock_client, memory_with_search_results):
|
||||
"""Should add to active downloads on success."""
|
||||
mock_client.add_torrent.return_value = True
|
||||
@@ -313,7 +313,7 @@ class TestAddTorrentToQbittorrent:
|
||||
== "Inception.2010.1080p.BluRay.x264"
|
||||
)
|
||||
|
||||
@patch("agent.tools.api.qbittorrent_client")
|
||||
@patch("alfred.agent.tools.api.qbittorrent_client")
|
||||
def test_sets_topic_and_ends_workflow(self, mock_client, memory):
|
||||
"""Should set topic and end workflow."""
|
||||
mock_client.add_torrent.return_value = True
|
||||
@@ -326,10 +326,10 @@ class TestAddTorrentToQbittorrent:
|
||||
assert mem.stm.current_topic == "downloading"
|
||||
assert mem.stm.current_workflow is None
|
||||
|
||||
@patch("agent.tools.api.qbittorrent_client")
|
||||
@patch("alfred.agent.tools.api.qbittorrent_client")
|
||||
def test_error_handling(self, mock_client, memory):
|
||||
"""Should handle client errors correctly."""
|
||||
from infrastructure.api.qbittorrent.exceptions import QBittorrentAPIError
|
||||
from alfred.infrastructure.api.qbittorrent.exceptions import QBittorrentAPIError
|
||||
|
||||
mock_client.add_torrent.side_effect = QBittorrentAPIError("Connection failed")
|
||||
|
||||
@@ -349,7 +349,7 @@ class TestAddTorrentByIndex:
|
||||
- Error handling for edge cases
|
||||
"""
|
||||
|
||||
@patch("agent.tools.api.qbittorrent_client")
|
||||
@patch("alfred.agent.tools.api.qbittorrent_client")
|
||||
def test_success(self, mock_client, memory_with_search_results):
|
||||
"""Should get torrent by index and add it."""
|
||||
mock_client.add_torrent.return_value = True
|
||||
@@ -362,7 +362,7 @@ class TestAddTorrentByIndex:
|
||||
# Verify correct magnet was extracted and used
|
||||
mock_client.add_torrent.assert_called_once_with("magnet:?xt=urn:btih:abc123")
|
||||
|
||||
@patch("agent.tools.api.qbittorrent_client")
|
||||
@patch("alfred.agent.tools.api.qbittorrent_client")
|
||||
def test_uses_correct_magnet(self, mock_client, memory_with_search_results):
|
||||
"""Should extract correct magnet from index."""
|
||||
mock_client.add_torrent.return_value = True
|
||||
|
||||
Reference in New Issue
Block a user