From 3e4b6fd129088084329ced2c7de8b85deeb25b44 Mon Sep 17 00:00:00 2001 From: Berack96 Date: Sun, 12 Oct 2025 17:38:09 +0200 Subject: [PATCH] update tests --- tests/agents/test_predictor.py | 57 -------------------------------- tests/tools/test_market_tool.py | 2 +- tests/tools/test_news_tool.py | 2 +- tests/tools/test_socials_tool.py | 2 +- 4 files changed, 3 insertions(+), 60 deletions(-) delete mode 100644 tests/agents/test_predictor.py diff --git a/tests/agents/test_predictor.py b/tests/agents/test_predictor.py deleted file mode 100644 index 1e9145f..0000000 --- a/tests/agents/test_predictor.py +++ /dev/null @@ -1,57 +0,0 @@ -import pytest -from app.agents import AppModels -from app.agents.predictor import PredictorInput, PredictorOutput, PredictorStyle -from app.agents.prompts import PREDICTOR_INSTRUCTIONS -from app.api.core.markets import ProductInfo - -def unified_checks(model: AppModels, input: PredictorInput) -> None: - llm = model.get_agent(PREDICTOR_INSTRUCTIONS, output_schema=PredictorOutput) # type: ignore[arg-type] - result = llm.run(input) # type: ignore - content = result.content - - assert isinstance(content, PredictorOutput) - assert content.strategy not in (None, "", "null") - assert isinstance(content.strategy, str) - assert isinstance(content.portfolio, list) - assert len(content.portfolio) > 0 - for item in content.portfolio: - assert item.asset not in (None, "", "null") - assert isinstance(item.asset, str) - assert item.percentage >= 0.0 - assert item.percentage <= 100.0 - assert isinstance(item.percentage, (int, float)) - assert item.motivation not in (None, "", "null") - assert isinstance(item.motivation, str) - # La somma delle percentuali deve essere esattamente 100 - total_percentage = sum(item.percentage for item in content.portfolio) - assert abs(total_percentage - 100) < 0.01 # Permette una piccola tolleranza per errori di arrotondamento - -class TestPredictor: - - def inputs(self) -> PredictorInput: - data: list[ProductInfo] = [] - for symbol, price in [("BTC", 60000.00), ("ETH", 3500.00), ("SOL", 150.00)]: - product_info = ProductInfo() - product_info.symbol = symbol - product_info.price = price - data.append(product_info) - - return PredictorInput(data=data, style=PredictorStyle.AGGRESSIVE, sentiment="positivo") - - def test_gemini_model_output(self): - inputs = self.inputs() - unified_checks(AppModels.GEMINI, inputs) - - def test_ollama_qwen_4b_model_output(self): - inputs = self.inputs() - unified_checks(AppModels.OLLAMA_QWEN_4B, inputs) - - @pytest.mark.slow - def test_ollama_qwen_latest_model_output(self): - inputs = self.inputs() - unified_checks(AppModels.OLLAMA_QWEN, inputs) - - @pytest.mark.slow - def test_ollama_gpt_oss_model_output(self): - inputs = self.inputs() - unified_checks(AppModels.OLLAMA_GPT, inputs) diff --git a/tests/tools/test_market_tool.py b/tests/tools/test_market_tool.py index 5e28edd..ea90bf2 100644 --- a/tests/tools/test_market_tool.py +++ b/tests/tools/test_market_tool.py @@ -1,5 +1,5 @@ import pytest -from app.api.markets import MarketAPIsTool +from app.api.tools import MarketAPIsTool @pytest.mark.tools diff --git a/tests/tools/test_news_tool.py b/tests/tools/test_news_tool.py index 5f685a8..370ea71 100644 --- a/tests/tools/test_news_tool.py +++ b/tests/tools/test_news_tool.py @@ -1,5 +1,5 @@ import pytest -from app.api.news import NewsAPIsTool +from app.api.tools import NewsAPIsTool @pytest.mark.tools diff --git a/tests/tools/test_socials_tool.py b/tests/tools/test_socials_tool.py index 29a81ae..c021a90 100644 --- a/tests/tools/test_socials_tool.py +++ b/tests/tools/test_socials_tool.py @@ -1,5 +1,5 @@ import pytest -from app.api.social import SocialAPIsTool +from app.api.tools import SocialAPIsTool @pytest.mark.tools