testing-strategy

A set of rules for testing Python code with pytest and nox. It tells the coding agent which tests and checks to run after test files change.

In plain words
What is it for?
Running changed and related tests, checking coverage, starting mock servers for integration tests, and verifying that tests use the expected markers and mocks.
Why use it?
It reduces the chance of leaving untested code, broken test naming, missing failure cases, or unverified integration and end-to-end tests.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/ekakit/lightfast-mcp/testing-strategy
Clone the repo
git clone --depth 1 https://github.com/ekakit/lightfast-mcp

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 722 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00722
Opus 5 $0.00000 $0.00361
Sonnet 5 $0.00000 $0.00144
Haiku 4.5 $0.00000 $0.00072

Measured 2d ago against content hash 860dc48eb4f5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-strategy scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/testing-strategy.mdc · 114 lines

How it starts

The opening of the file, as written. The whole thing — 114 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing Workflow

When editing test files, execute this workflow immediately:

Immediate Actions After Test File Changes

  1. Run the Specific Test: uv run pytest {current_test_file} -v
  2. Run Related Fast Tests: nox -s test_fast
  3. Check Test Coverage: Ensure new code paths are covered

Test File Validation Checklist

  • Test function names start with test_
  • Async tests use @pytest.mark.asyncio
  • Integration tests use @pytest.mark.integration
  • Tests have descriptive docstrings
  • Both success and failure scenarios are tested
  • External dependencies are properly mocked

Automatic Commands by Test Type

Unit Tests (tests/unit/)

# Run just the current test file
uv run pytest {current_file} -v

# Run all unit tests for the module being tested
uv run pytest tests/unit/test_{module_name}* -v

Integration Tests (tests/integration/)

# Run the current integration test
uv run pytest {current_file} -v

# Ensure test servers are available
uv run lightfast-mock-server &
sleep 2
uv run pytest {current_file} -v
pkill -f lightfast-mock-server

E2E Tests (tests/e2e/)

# Run the current E2E test in isolation
uv run pytest {current_file} -v -s

# Run full E2E suite if major changes
nox -s test_e2e

Test Development Workflow

When writing new tests:

  1. Write Failing Test: Start with a test that fails
  2. Run Test: uv run pytest {test_file}::{test_function} -v
  3. Implement Feature: Make the test pass
  4. Run Full Test Suite: nox -s test_fast
  5. Check Coverage: Ensure adequate test coverage

Required Test Patterns

Unit Test Template

import pytest
from lightfast_mcp.servers.{module} import {Class}

@pytest.mark.asyncio
async def test_{function_name}_success():
    """Test {function} succeeds with valid input."""
    # Arrange
    instance = {Class}()
    
    # Act
    result = await instance.{function}("valid_input")
    
    # Assert
    assert result == "expected_output"

@pytest.mark.asyncio
async def test_{function_name}_failure():
    """Test {function} handles invalid input gracefully."""
    # Arrange
    instance = {Class}()
    
    # Act & Assert
    with pytest.raises(ValueError, match="expected error message"):
        await instance.{function}("invalid_input")

Read the full file on GitHub · 114 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 114 lines · 0 tokens per session scan A 860dc48eb4f5

Subscribe to this mod's changes

testing-strategy is a cursor rule published in the GitHub repository ekakit/lightfast-mcp (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 722 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.