pkgprateek commited on
Commit
b1b661d
·
1 Parent(s): cfa7ab8

fix: fixed unit testts config

Browse files
conftest.py CHANGED
@@ -1,8 +1,19 @@
1
  """Pytest configuration and fixtures."""
2
 
3
  import sys
 
4
  from pathlib import Path
5
 
6
  # Add project root to Python path for src imports
7
  project_root = Path(__file__).parent
8
  sys.path.insert(0, str(project_root))
 
 
 
 
 
 
 
 
 
 
 
1
  """Pytest configuration and fixtures."""
2
 
3
  import sys
4
+ import pytest
5
  from pathlib import Path
6
 
7
  # Add project root to Python path for src imports
8
  project_root = Path(__file__).parent
9
  sys.path.insert(0, str(project_root))
10
+
11
+
12
+ @pytest.fixture(autouse=True)
13
+ def mock_env(monkeypatch):
14
+ """Mock environment variables for all tests."""
15
+ monkeypatch.setenv("OPENROUTER_API_KEY", "sk-mock-key")
16
+ monkeypatch.setenv("TAVILY_API_KEY", "tvly-mock-key")
17
+ monkeypatch.setenv("LANGSMITH_API_KEY", "lsv2-mock-key")
18
+ monkeypatch.setenv("LANGCHAIN_TRACING_V2", "false")
19
+ monkeypatch.setenv("LANGCHAIN_PROJECT", "test-project")
docs/WORKFLOW.md CHANGED
@@ -177,6 +177,6 @@ def _custom_routing(self, state):
177
  - [x] State persistence with checkpoints
178
  - [x] Error recovery and graceful degradation
179
  - [x] Observability integration
180
- - [ ] Human-in-the-loop UI integration (Phase 5)
181
  - [ ] Rate limiting for API calls
182
  - [ ] Result caching for repeated queries
 
177
  - [x] State persistence with checkpoints
178
  - [x] Error recovery and graceful degradation
179
  - [x] Observability integration
180
+ - [ ] Human-in-the-loop UI integration
181
  - [ ] Rate limiting for API calls
182
  - [ ] Result caching for repeated queries
tests/unit/test_config.py CHANGED
@@ -24,6 +24,7 @@ def test_settings_with_defaults(monkeypatch):
24
  """Test settings use defaults for optional fields."""
25
  monkeypatch.setenv("OPENROUTER_API_KEY", "test-key")
26
  monkeypatch.setenv("TAVILY_API_KEY", "test-key")
 
27
 
28
  settings = Settings()
29
 
 
24
  """Test settings use defaults for optional fields."""
25
  monkeypatch.setenv("OPENROUTER_API_KEY", "test-key")
26
  monkeypatch.setenv("TAVILY_API_KEY", "test-key")
27
+ monkeypatch.delenv("LANGCHAIN_PROJECT", raising=False)
28
 
29
  settings = Settings()
30
 
tests/unit/test_workflow.py CHANGED
@@ -1,6 +1,7 @@
1
  """Unit tests for LangGraph workflow state and nodes."""
2
 
3
  import pytest
 
4
 
5
  from src.workflows.types import IntelligenceState
6
  from src.workflows.market_analysis import MarketIntelligenceWorkflow
@@ -145,14 +146,23 @@ class TestWorkflowNodes:
145
  """Test research node returns correct state structure."""
146
  workflow = MarketIntelligenceWorkflow()
147
 
 
 
 
 
 
 
 
 
 
 
 
148
  state = {
149
  "company_name": "Test Company",
150
  "industry": "Technology",
151
  "iteration": 0,
152
  }
153
 
154
- # This will make real API calls, so we just test structure
155
- # In a real test, we'd mock the agents
156
  result = await workflow._research_node(state)
157
 
158
  assert "current_agent" in result
 
1
  """Unit tests for LangGraph workflow state and nodes."""
2
 
3
  import pytest
4
+ from unittest.mock import AsyncMock
5
 
6
  from src.workflows.types import IntelligenceState
7
  from src.workflows.market_analysis import MarketIntelligenceWorkflow
 
146
  """Test research node returns correct state structure."""
147
  workflow = MarketIntelligenceWorkflow()
148
 
149
+ # Mock the research agent's run method
150
+ workflow.research_agent.run = AsyncMock(
151
+ return_value={
152
+ "company_name": "Test Company",
153
+ "company_overview": "Overview",
154
+ "competitors": "Competitors",
155
+ "market_trends": "Trends",
156
+ "raw_sources": [],
157
+ }
158
+ )
159
+
160
  state = {
161
  "company_name": "Test Company",
162
  "industry": "Technology",
163
  "iteration": 0,
164
  }
165
 
 
 
166
  result = await workflow._research_node(state)
167
 
168
  assert "current_agent" in result