xiaohongshu
xiaohongshu
generate-test
Generates test files following TDD patterns with Given-When-Then structure. Use when creating tests for domain logic, API endpoints, or repositories.
Full skill instructions
Creates test files following the project's TDD conventions.
Mandatory format:
def test_when_<condition>_then_<expected_outcome>():
Examples:
def test_when_item_already_exists_then_raise_ItemAlreadyExistsException():
def test_when_item_does_not_exist_then_create_item():
def test_when_user_not_authenticated_then_return_401():
def test_when_valid_request_then_return_created_item():
Use Given-When-Then structure without comments:
def test_when_item_already_exists_then_raise_ItemAlreadyExistsException(
item_repository: IItemRepository,
):
# Given - setup
item_db = ItemDb(id=uuid.uuid4(), user_id=user_id, name="Test", description="Desc")
item_repository.create(item_db)
# When/Then - action and assertion
with pytest.raises(ItemAlreadyExistsException):
create_item(user_id, "Test", "Another desc", item_repository)
Mirror the source structure:
back/src/api/{module}/domain/create_item.py
back/tests/api/{module}/domain/test_create_item.py
back/src/api/{module}/infrastructure/repository.py
back/tests/api/{module}/infrastructure/test_{entity}_repository.py
import uuid
import pytest
from freezegun import freeze_time
from src.api.{module}.domain.{action} import {action_function}
from src.api.{module}.domain.exception import {Entity}NotFoundException, {Entity}AlreadyExistsException
from src.api.{module}.infrastructure.models import {Entity}Db
from src.api.{module}.infrastructure.repository import I{Entity}Repository
user_id = "test_user_123"
def test_when_{condition}_then_{outcome}(
{entity}_repository: I{Entity}Repository,
):
{entity}_db = {Entity}Db(id=uuid.uuid4(), user_id=user_id, name="Test", description="Desc")
{entity}_repository.create({entity}_db)
with pytest.raises({Entity}AlreadyExistsException):
{action_function}(user_id, "Test", "Another desc", {entity}_repository)
@freeze_time("2023-01-01 00:00:00", tz_offset=0)
def test_when_{condition}_then_{outcome}(
{entity}_repository: I{Entity}Repository,
frozen_datetime,
):
{entity}_db = {action_function}(user_id, "Test", "Description", {entity}_repository)
assert {entity}_db.user_id == user_id
assert {entity}_db.name == "Test"
assert {entity}_db.created_at == frozen_datetime
Available in back/tests/conftest.py:
@pytest.fixture
def session():
"""Database session for tests."""
@pytest.fixture
def client(session):
"""FastAPI test client."""
@pytest.fixture
def frozen_datetime():
"""Current frozen time for freezegun tests."""
@pytest.fixture
def {entity}_repository(session) -> I{Entity}Repository:
"""Repository instance for testing."""
return {Entity}Repository(session=session)
def test_when_not_found_then_raise_NotFoundException(repository):
with pytest.raises(EntityNotFoundException):
get_entity(uuid.uuid4(), repository)
@freeze_time("2023-01-01 00:00:00", tz_offset=0)
def test_when_created_then_timestamps_set(repository, frozen_datetime):
entity = create_entity("name", repository)
assert entity.created_at == frozen_datetime
assert entity.updated_at == frozen_datetime
@pytest.mark.parametrize("name,expected", [
("valid", True),
("", False),
(None, False),
])
def test_when_name_varies_then_validation_correct(name, expected):
result = validate_name(name)
assert result == expected
# All tests
cd back && task tests
# Specific module
uv run pytest tests/api/{module}/ -v
# Single file
uv run pytest tests/api/{module}/domain/test_create_{entity}.py -v
# Single test
uv run pytest tests/api/{module}/domain/test_create_{entity}.py::test_when_... -v
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience