Skip to content

Commit 9c174eb

Browse files
simplify testing suite
1 parent 231212f commit 9c174eb

6 files changed

Lines changed: 31 additions & 1084 deletions

File tree

macro_agents/tests/test_analysis_agents.py

Lines changed: 1 addition & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,15 @@
33
"""
44

55
import polars as pl
6-
import pytest
7-
from unittest.mock import Mock, patch
6+
from unittest.mock import Mock
87
from macro_agents.defs.agents.analysis_agent import (
98
EconomicAnalyzer,
10-
EconomicAnalysisModule,
119
)
1210
from macro_agents.defs.agents.economic_cycle_analyzer import (
1311
EconomicCycleAnalyzer,
14-
EconomicCycleModule,
1512
)
1613
from macro_agents.defs.agents.asset_allocation_analyzer import (
1714
AssetAllocationAnalyzer,
18-
AssetAllocationModule,
1915
)
2016
from macro_agents.defs.resources.motherduck import MotherDuckResource
2117

@@ -32,42 +28,6 @@ def test_initialization(self):
3228
assert analyzer.model_name == "gpt-4-turbo-preview"
3329
assert analyzer.openai_api_key == "test_key"
3430

35-
@pytest.mark.skip_ci
36-
@patch("dspy.LM")
37-
@patch("dspy.settings.configure")
38-
def test_setup_for_execution(self, mock_configure, mock_lm):
39-
"""Test setup for execution."""
40-
analyzer = EconomicAnalyzer(
41-
model_name="gpt-4-turbo-preview", openai_api_key="test_key"
42-
)
43-
44-
mock_context = Mock()
45-
analyzer.setup_for_execution(mock_context)
46-
47-
mock_lm.assert_called_once()
48-
mock_configure.assert_called_once()
49-
50-
@pytest.mark.skip_ci
51-
def test_format_results_as_json(self):
52-
"""Test formatting results as JSON."""
53-
analyzer = EconomicAnalyzer(
54-
model_name="gpt-4-turbo-preview", openai_api_key="test_key"
55-
)
56-
57-
category_results = {
58-
"Technology": "Tech analysis",
59-
"Healthcare": "Health analysis",
60-
}
61-
62-
json_results = analyzer.format_results_as_json(
63-
category_results, sample_size=50, metadata={"test": "value"}
64-
)
65-
66-
assert len(json_results) == 2
67-
assert json_results[0]["category"] == "Technology"
68-
assert json_results[0]["num_samples"] == 50
69-
assert json_results[0]["test"] == "value"
70-
7131

7232
class TestEconomicCycleAnalyzer:
7333
"""Test cases for EconomicCycleAnalyzer."""
@@ -81,21 +41,6 @@ def test_initialization(self):
8141
assert analyzer.model_name == "gpt-4-turbo-preview"
8242
assert analyzer.openai_api_key == "test_key"
8343

84-
@pytest.mark.skip_ci
85-
@patch("dspy.LM")
86-
@patch("dspy.settings.configure")
87-
def test_setup_for_execution(self, mock_configure, mock_lm):
88-
"""Test setup for execution."""
89-
analyzer = EconomicCycleAnalyzer(
90-
model_name="gpt-4-turbo-preview", openai_api_key="test_key"
91-
)
92-
93-
mock_context = Mock()
94-
analyzer.setup_for_execution(mock_context)
95-
96-
mock_lm.assert_called_once()
97-
mock_configure.assert_called_once()
98-
9944
def test_get_economic_data(self):
10045
"""Test getting economic data."""
10146
analyzer = EconomicCycleAnalyzer(
@@ -143,28 +88,6 @@ def test_get_market_data(self):
14388
assert "AAPL" in result
14489
mock_md.execute_query.assert_called_once()
14590

146-
@pytest.mark.skip_ci
147-
def test_format_cycle_analysis_as_json(self):
148-
"""Test formatting cycle analysis as JSON."""
149-
analyzer = EconomicCycleAnalyzer(
150-
model_name="gpt-4-turbo-preview", openai_api_key="test_key"
151-
)
152-
153-
analysis_result = {
154-
"economic_cycle_analysis": "Cycle analysis",
155-
"market_trend_analysis": "Trend analysis",
156-
"analysis_timestamp": "2024-01-01T00:00:00",
157-
"model_name": "gpt-4-turbo-preview",
158-
}
159-
160-
json_results = analyzer.format_cycle_analysis_as_json(
161-
analysis_result, metadata={"test": "value"}
162-
)
163-
164-
assert len(json_results) == 2
165-
assert json_results[0]["analysis_type"] == "economic_cycle"
166-
assert json_results[1]["analysis_type"] == "market_trends"
167-
16891

16992
class TestAssetAllocationAnalyzer:
17093
"""Test cases for AssetAllocationAnalyzer."""
@@ -178,21 +101,6 @@ def test_initialization(self):
178101
assert analyzer.model_name == "gpt-4-turbo-preview"
179102
assert analyzer.openai_api_key == "test_key"
180103

181-
@pytest.mark.skip_ci
182-
@patch("dspy.LM")
183-
@patch("dspy.settings.configure")
184-
def test_setup_for_execution(self, mock_configure, mock_lm):
185-
"""Test setup for execution."""
186-
analyzer = AssetAllocationAnalyzer(
187-
model_name="gpt-4-turbo-preview", openai_api_key="test_key"
188-
)
189-
190-
mock_context = Mock()
191-
analyzer.setup_for_execution(mock_context)
192-
193-
mock_lm.assert_called_once()
194-
mock_configure.assert_called_once()
195-
196104
def test_get_latest_analysis(self):
197105
"""Test getting latest analysis."""
198106
analyzer = AssetAllocationAnalyzer(
@@ -214,43 +122,3 @@ def test_get_latest_analysis(self):
214122
assert cycle_analysis == "cycle analysis"
215123
assert trend_analysis == "trend analysis"
216124
mock_md.execute_query.assert_called_once()
217-
218-
@pytest.mark.skip_ci
219-
def test_format_allocation_as_json(self):
220-
"""Test formatting allocation as JSON."""
221-
analyzer = AssetAllocationAnalyzer(
222-
model_name="gpt-4-turbo-preview", openai_api_key="test_key"
223-
)
224-
225-
allocation_result = {
226-
"allocation_recommendations": "Allocation recommendations",
227-
"analysis_timestamp": "2024-01-01T00:00:00",
228-
"model_name": "gpt-4-turbo-preview",
229-
}
230-
231-
json_result = analyzer.format_allocation_as_json(
232-
allocation_result, metadata={"test": "value"}
233-
)
234-
235-
assert json_result["analysis_type"] == "asset_allocation_recommendations"
236-
assert json_result["analysis_content"] == "Allocation recommendations"
237-
assert json_result["test"] == "value"
238-
239-
240-
class TestDSPyModules:
241-
"""Test cases for DSPy modules."""
242-
243-
def test_economic_analysis_module(self):
244-
"""Test EconomicAnalysisModule."""
245-
module = EconomicAnalysisModule()
246-
assert module.analyze is not None
247-
248-
def test_economic_cycle_module(self):
249-
"""Test EconomicCycleModule."""
250-
module = EconomicCycleModule()
251-
assert module.analyze_cycle is not None
252-
253-
def test_asset_allocation_module(self):
254-
"""Test AssetAllocationModule."""
255-
module = AssetAllocationModule()
256-
assert module.analyze_allocation is not None

macro_agents/tests/test_dagster_assets_descriptions.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

macro_agents/tests/test_dbt_models_descriptions.py

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)