mock-external-services

Creates configurable mock layers for Twilio, Stripe, SendGrid, Azure Search, and Sterling integrations in Python tests.

Updated May 11, 2026
One-click install
npx skills add https://github.com/thachrocky12345/local-agent-train-workstation --skill mock-external-services-thachrocky12345
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mock-external-services
Source: https://github.com/thachrocky12345/local-agent-train-workstation/tree/main/.claude/skills/mock-external-services
Command: npx skills add https://github.com/thachrocky12345/local-agent-train-workstation --skill mock-external-services-thachrocky12345

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Testing code that calls external APIs like Stripe, Twilio, or SendGrid is slow, costly, and unreliable when it hits real services. This Skill builds drop-in mock clients with configurable failure modes so test suites run offline, in CI/CD pipelines, and against error scenarios that are hard to reproduce with live APIs. ## Core Features & Use Cases - Backend mock classes: Generates MockTwilioClient, MockStripeClient, MockSendGridClient, MockAzureSearchClient, MockSterlingClient, MockCertnClient, and MockPayPalClient under apps/utils/mocks/, each with a failure_mode parameter covering success, timeout, rate limit, card declines, bounces, and FCRA adverse-action flows. - Failure injection patterns: Provides pytest monkeypatch snippets that patch the exact import paths used by existing conftest fixtures, so new mocks extend rather than duplicate current test setup. - Frontend MSW handlers: Scaffolds Mock Service Worker handler files for auth, calendar, and payments endpoints once the frontend test scaffold exists. - Use Case: You need to verify your checkout flow handles a declined card. Invoke the Skill with the stripe service and card_declined mode, then assert your API returns the correct 400 response without touching Stripe. ## Quick Start Ask the AI to create mock layers for all external services in success mode so the test suite runs fully offline.

Frequently Asked Questions about mock-external-services

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I mock Stripe payment failures in pytest?

Instantiate MockStripeClient with a failure_mode such as card_declined or insufficient_funds, then monkeypatch apps.stripe_integration.views.stripe with the mock and set _STRIPE_CONFIGURED to True. The mock raises Stripe-style card errors with proper code and decline_code attributes.

How do I test Twilio video room creation without API credentials?

Use MockTwilioClient with failure_mode success and patch apps.video_conferencing.utils.Client plus apps.video_conferencing.twilio_config.get_twilio_client. The mock returns rooms with realistic SIDs and statuses, and supports failure modes like room_full and rate_limit.

Can I test SendGrid bounce and delivery webhook events?

Yes. MockSendGridClient captures sent emails in memory and queues webhook events for hard bounces, soft bounces, spam reports, and deliveries. Call simulate_webhook_delivery to retrieve queued events and use assertion helpers like assert_email_sent_to.

Does this work with existing conftest mock fixtures?

Yes. The mocks are designed to extend existing fixtures like mock_stripe, mock_paypal, and mock_external_apis rather than replace them. They patch the same import paths and respect the _STRIPE_CONFIGURED and _PAYPAL_CONFIGURED guards in the views module.

How do I simulate a Sterling background check adverse action flow?

Use MockSterlingClient with failure_mode adverse_action. It is stateful: successive calls to get_screening_status progress through the FCRA flow from adverse_action_pending with pre-adverse notice through the dispute window to the final adverse action decision.

When should I not use these service mocks?

Avoid them for contract testing against real API behavior changes, since mocks encode assumed response shapes. Also note the autouse mock_cache fixture mocks Redis, so tests needing real cache behavior must explicitly override that fixture.