chore: fixed imports and tests configuration
This commit is contained in:
@@ -10,7 +10,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_very_long_message(self, memory):
|
||||
"""Should handle very long user message."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
# Patch the agent's LLM directly
|
||||
mock_llm = Mock()
|
||||
@@ -32,7 +33,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_unicode_message(self, memory):
|
||||
"""Should handle unicode in message."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = {
|
||||
@@ -57,7 +59,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_special_characters_in_message(self, memory):
|
||||
"""Should handle special characters."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = {"role": "assistant", "content": "Response"}
|
||||
@@ -78,12 +81,12 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_empty_content_in_message(self, memory):
|
||||
"""Should handle empty content in message."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = "Response"
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -100,11 +103,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_null_content_in_message(self, memory):
|
||||
"""Should handle null content in message."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -120,11 +123,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_missing_content_field(self, memory):
|
||||
"""Should handle missing content field."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -141,11 +144,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_missing_role_field(self, memory):
|
||||
"""Should handle missing role field."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -162,12 +165,12 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_invalid_role(self, memory):
|
||||
"""Should handle invalid role."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = "Response"
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -184,7 +187,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_many_messages(self, memory):
|
||||
"""Should handle many messages in conversation."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = {"role": "assistant", "content": "Response"}
|
||||
@@ -210,11 +214,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_only_system_messages(self, memory):
|
||||
"""Should reject if only system messages."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -233,11 +237,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_only_assistant_messages(self, memory):
|
||||
"""Should reject if only assistant messages."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -255,11 +259,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_messages_not_array(self, memory):
|
||||
"""Should reject if messages is not array."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -276,11 +280,11 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_message_not_object(self, memory):
|
||||
"""Should handle message that is not object."""
|
||||
with patch("app.DeepSeekClient") as mock_llm_class:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm_class:
|
||||
mock_llm = Mock()
|
||||
mock_llm_class.return_value = mock_llm
|
||||
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -297,7 +301,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_extra_fields_in_request(self, memory):
|
||||
"""Should ignore extra fields in request."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = {"role": "assistant", "content": "Response"}
|
||||
@@ -320,8 +325,9 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_streaming_with_tool_call(self, memory, real_folder):
|
||||
"""Should handle streaming with tool execution."""
|
||||
from app import agent, app
|
||||
from infrastructure.persistence import get_memory
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
from alfred.infrastructure.persistence import get_memory
|
||||
|
||||
mem = get_memory()
|
||||
mem.ltm.set_config("download_folder", str(real_folder["downloads"]))
|
||||
@@ -365,7 +371,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_concurrent_requests_simulation(self, memory):
|
||||
"""Should handle rapid sequential requests."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = {"role": "assistant", "content": "Response"}
|
||||
@@ -385,7 +392,8 @@ class TestChatCompletionsEdgeCases:
|
||||
|
||||
def test_llm_returns_json_in_response(self, memory):
|
||||
"""Should handle LLM returning JSON in text response."""
|
||||
from app import agent, app
|
||||
from alfred.app import app
|
||||
from alfred.agent import agent
|
||||
|
||||
mock_llm = Mock()
|
||||
mock_llm.complete.return_value = {
|
||||
@@ -414,9 +422,9 @@ class TestMemoryEndpointsEdgeCases:
|
||||
|
||||
def test_memory_state_with_large_data(self, memory):
|
||||
"""Should handle large memory state."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
# Add lots of data to memory
|
||||
for i in range(100):
|
||||
@@ -432,9 +440,9 @@ class TestMemoryEndpointsEdgeCases:
|
||||
|
||||
def test_memory_state_with_unicode(self, memory):
|
||||
"""Should handle unicode in memory state."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
memory.ltm.set_config("japanese", "日本語テスト")
|
||||
memory.stm.add_message("user", "🎬 Movie request")
|
||||
@@ -448,9 +456,9 @@ class TestMemoryEndpointsEdgeCases:
|
||||
|
||||
def test_search_results_with_special_chars(self, memory):
|
||||
"""Should handle special characters in search results."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
memory.episodic.store_search_results(
|
||||
"Test <script>alert('xss')</script>",
|
||||
@@ -467,9 +475,9 @@ class TestMemoryEndpointsEdgeCases:
|
||||
|
||||
def test_clear_session_idempotent(self, memory):
|
||||
"""Should be idempotent - multiple clears should work."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -480,9 +488,9 @@ class TestMemoryEndpointsEdgeCases:
|
||||
|
||||
def test_clear_session_preserves_ltm(self, memory):
|
||||
"""Should preserve LTM after clear."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
memory.ltm.set_config("important", "data")
|
||||
memory.stm.add_message("user", "Hello")
|
||||
@@ -502,9 +510,9 @@ class TestHealthEndpointEdgeCases:
|
||||
|
||||
def test_health_returns_version(self, memory):
|
||||
"""Should return version in health check."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -515,9 +523,9 @@ class TestHealthEndpointEdgeCases:
|
||||
|
||||
def test_health_with_query_params(self, memory):
|
||||
"""Should ignore query parameters."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
@@ -531,9 +539,9 @@ class TestModelsEndpointEdgeCases:
|
||||
|
||||
def test_models_response_format(self, memory):
|
||||
"""Should return OpenAI-compatible format."""
|
||||
with patch("app.DeepSeekClient") as mock_llm:
|
||||
with patch("alfred.app.DeepSeekClient") as mock_llm:
|
||||
mock_llm.return_value = Mock()
|
||||
from app import app
|
||||
from alfred.app import app
|
||||
|
||||
client = TestClient(app)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user