cqrs-testing
БесплатноБез исполняемых скриптовНе проверенAsserts a python-cqrs handler through cqrs.testing.test_harness. Use when a test must check a command, a query, a domain event, a notification, an outbox, an…
от vadikko2258 установок в других каталогахОб этом скилле
Testing python-cqrs
Read the feature skill before writing the handler. This file only says which journal to assert.
Import from cqrs.testing import test_harness. It is not in cqrs.__all__. The package is already installed. Do not add an install step. Do not copy examples/testing/ into the application.
async with test_harness(...) as harness builds the mediators. Arguments match bootstrap. The builder passes compensation_retry_delay=0 unless the test passes a delay. async with test_harness.around(...) as harness wraps mediators the application already built and does not change that delay. around puts resolve, the broker, saga storage, and the listener back in finally.
If the application mediator has a real broker and no broker= argument is passed, around forwards each message to that real broker and records it. To keep a unit test isolated, pass a CapturingMessageBroker with no inner broker: async with test_harness.around(mediator, broker=CapturingMessageBroker()) as harness. The real broker's send_message is then redirected to the capture, so no message leaves the process.
test_harness(...) creates a memory outbox and a memory inbox on harness.outbox_repository and harness.inbox_repository. It does not bind them. The test binds the port.
For ScopeStrategy.SEND, pass di.Container. Do not pass TestContainer. TestContainer is register(type, instance) and async resolve.
Do not read DevnullMessageBroker.MESSAGE_BUS. If the mediator holds that broker, the harness replaces it with CapturingMessageBroker for the block and restores it afterwards.
An invocation record has handler, method (handle, act, or compensate), argument, argument_type, and handler_instance.
contains is a boolean and does not raise. assert_contains, assert_one, and assert_empty raise AssertionError with the recorded rows. Those methods are not on every journal:
requests,handled,unhandled, andpublishedhavecontains.handledandunhandledhaveassert_empty. They do not haveassert_containsorassert_one.publishedhascontains,assert_contains,assert_one, andassert_empty.outboxhasassert_empty. It does not havecontains,assert_contains, orassert_one.invocationshasassert_enteredandassert_not_entered. It does not havecontains,assert_contains,assert_one, orassert_empty.requestsdoes not haveassert_contains,assert_one, orassert_empty.
There is no pytest plugin.
Short shape for a command, a domain event, and a notification: assets/test_order.py.
Command
Assert requests and invocations. send returns the same result requests stored. published stays empty unless the command also emits a notification.
Query
Assert requests. handled, published, and outbox stay empty.
view = await harness.mediator.send(ReadOrder(order_id="1"))
harness.handled.assert_empty()
harness.published.assert_empty()
harness.outbox.assert_empty()
Domain event
Assert handled and invocations. A follow-up event is also on handled and enters the next handler. published stays empty.
Notification
Assert published (topic, message_name, payload, message_id). The notice is not on handled.
published.contains(OrderCreated) is false for a domain event. published.assert_contains names handled or invocations in the error when the event was recorded there and was not sent to the broker.
Parallel domain handlers
concurrent_event_handle_enable=True with ScopeStrategy.HANDLER or NONE. Both classes are on invocations. Do not assert order.
Swallowed domain-handler error
send returns the command result. The error is on handler_errors. requests still holds that result.
result = await harness.mediator.send(CreateOrder(sku="book"))
assert harness.handler_errors.of(OrderCreated, AuditHandler)
Event with no handler
The type is on unhandled. send does not raise. The missing handler is not on invocations.
EventMediator
await harness.event_mediator.send(event) enters handle on invocations. EventMediator goes through EventDispatcher, not EventEmitter, so this path is not handled. A follow-up also goes to the dispatcher.
Request fallback
Primary raises. Both classes are on invocations. The response on requests is the fallback's.
Event fallback
Same for an event from a command and for EventMediator. Both classes are on invocations.
Circuit breaker
Use a fake ICircuitBreaker. Do not install aiobreaker. An open breaker leaves the primary off invocations and enters the fallback.
Middleware
middlewares records the type, the request, and whether handle was called. If middleware does not call handle, invocations does not contain the handler, called_next is false, and requests holds the middleware's response.
harne
Установить cqrs-testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл cqrs-testing?
Asserts a python-cqrs handler through cqrs.testing.test_harness. Use when a test must check a command, a query, a domain event, a notification, an outbox, an inbox, a saga, a chain, a stream, a fallback, or middleware.
Как установить скилл cqrs-testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл cqrs-testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic