Skip to content

test: LangGraph integration tests (Groq, Gemini, mock)#16

Merged
arieradle merged 2 commits intomainfrom
feat/langgraph-integration
Mar 12, 2026
Merged

test: LangGraph integration tests (Groq, Gemini, mock)#16
arieradle merged 2 commits intomainfrom
feat/langgraph-integration

Conversation

@arieradle
Copy link
Owner

Summary

  • Adds tests/integrations/test_langgraph_integration.py with 14 tests covering LangGraph + shekel budget tracking
  • Adds langgraph to dev dependencies so tests run in CI

Test classes

TestLangGraphGroqIntegration (5 tests, skip without GROQ_API_KEY)
Uses openai.OpenAI(base_url="https://api.groq.com/openai/v1") inside real LangGraph nodes — shekel's OpenAI patch captures spend automatically.

TestLangGraphGeminiIntegration (4 tests, skip without GEMINI_API_KEY)
Uses litellm.completion(model="gemini/gemini-2.0-flash") inside LangGraph nodes — shekel's LiteLLM patch captures spend automatically.

TestLangGraphMockIntegration (5 tests, always run)
Mocked OpenAI client, exercises the full patch→graph path end-to-end without API keys.

Scenarios covered per class

  • Single-node cost tracking
  • Multi-node spend accumulation
  • BudgetExceededError propagation out of graph
  • Nested budget spend propagation to parent
  • Conditional retry-loop graph (mock only)

Test plan

  • 5 mock tests pass locally
  • Real-API tests exercise in CI with GROQ_API_KEY / GEMINI_API_KEY secrets

🤖 Generated with Claude Code

Tests three scenarios:
- TestLangGraphGroqIntegration: real Groq API via openai client
  (OpenAI-compatible endpoint), skipped without GROQ_API_KEY
- TestLangGraphGeminiIntegration: real Gemini API via LiteLLM,
  skipped without GEMINI_API_KEY
- TestLangGraphMockIntegration: 5 end-to-end tests with mocked
  OpenAI client — always run, no API keys needed

Each class covers: single-node tracking, multi-node accumulation,
budget enforcement, nested budget propagation. Mock class also tests
conditional retry-loop graphs.

Also adds langgraph to dev dependencies so tests run in CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…bundled pricing

Groq's llama-3.1-8b-instant has no bundled price table in shekel, so
max_usd=0.000001 alone never triggers BudgetExceededError (cost = $0).
Adding price_per_1k_tokens forces non-zero cost calculation and makes
the enforcement assertion reliable across all providers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@arieradle arieradle merged commit d7ed04a into main Mar 12, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant