VibecoderMcSwaggins commited on
Commit
923641c
·
1 Parent(s): 9e9bc6b

fix: address CodeRabbit review feedback

Browse files

- Move network reachability check to runtime in test_clinicaltrials.py
(avoids 5s delay at test collection time)
- Add explicit api_provider validation in app.py
(raises ValueError for unsupported providers instead of silent fallback)

src/app.py CHANGED
@@ -68,9 +68,11 @@ def configure_orchestrator(
68
  if api_provider == "anthropic":
69
  anthropic_provider = AnthropicProvider(api_key=user_api_key)
70
  model = AnthropicModel(settings.anthropic_model, provider=anthropic_provider)
71
- else:
72
  openai_provider = OpenAIProvider(api_key=user_api_key)
73
  model = OpenAIModel(settings.openai_model, provider=openai_provider)
 
 
74
  judge_handler = JudgeHandler(model=model)
75
 
76
  return create_orchestrator(
 
68
  if api_provider == "anthropic":
69
  anthropic_provider = AnthropicProvider(api_key=user_api_key)
70
  model = AnthropicModel(settings.anthropic_model, provider=anthropic_provider)
71
+ elif api_provider == "openai":
72
  openai_provider = OpenAIProvider(api_key=user_api_key)
73
  model = OpenAIModel(settings.openai_model, provider=openai_provider)
74
+ else:
75
+ raise ValueError(f"Unsupported API provider: {api_provider}")
76
  judge_handler = JudgeHandler(model=model)
77
 
78
  return create_orchestrator(
tests/unit/tools/test_clinicaltrials.py CHANGED
@@ -123,26 +123,21 @@ class TestClinicalTrialsTool:
123
  await tool.search("metformin alzheimer")
124
 
125
 
126
- def _can_reach_clinicaltrials() -> bool:
127
- """Check if ClinicalTrials.gov API is reachable."""
128
- try:
129
- resp = requests.get("https://clinicaltrials.gov/api/v2/studies", timeout=5)
130
- return resp.status_code < 500
131
- except (requests.RequestException, OSError):
132
- return False
133
-
134
-
135
  class TestClinicalTrialsIntegration:
136
  """Integration tests (marked for separate run)."""
137
 
138
  @pytest.mark.integration
139
  @pytest.mark.asyncio
140
- @pytest.mark.skipif(
141
- not _can_reach_clinicaltrials(),
142
- reason="ClinicalTrials.gov API not reachable (network/SSL issue)",
143
- )
144
  async def test_real_api_call(self) -> None:
145
  """Test actual API call (requires network)."""
 
 
 
 
 
 
 
 
146
  tool = ClinicalTrialsTool()
147
  results = await tool.search("metformin diabetes", max_results=3)
148
 
 
123
  await tool.search("metformin alzheimer")
124
 
125
 
 
 
 
 
 
 
 
 
 
126
  class TestClinicalTrialsIntegration:
127
  """Integration tests (marked for separate run)."""
128
 
129
  @pytest.mark.integration
130
  @pytest.mark.asyncio
 
 
 
 
131
  async def test_real_api_call(self) -> None:
132
  """Test actual API call (requires network)."""
133
+ # Skip at runtime if API unreachable (avoids network call at collection time)
134
+ try:
135
+ resp = requests.get("https://clinicaltrials.gov/api/v2/studies", timeout=5)
136
+ if resp.status_code >= 500:
137
+ pytest.skip("ClinicalTrials.gov API not reachable (server error)")
138
+ except (requests.RequestException, OSError):
139
+ pytest.skip("ClinicalTrials.gov API not reachable (network/SSL issue)")
140
+
141
  tool = ClinicalTrialsTool()
142
  results = await tool.search("metformin diabetes", max_results=3)
143