angzarr_client.testing.builders¶
Proto message builders for testing.
Provides simplified builders for constructing EventBook, CommandBook, Cover, and related proto types in tests.
Functions¶
|
Create a timestamp for now. |
|
Pack a protobuf message into an Any with the canonical type URL. |
|
Create a Cover from domain and root bytes. |
|
Create an EventPage. |
|
Create an EventBook. |
|
Create a CommandPage. |
|
Create a CommandBook with a single command. |
Module Contents¶
- angzarr_client.testing.builders.make_timestamp() google.protobuf.timestamp_pb2.Timestamp¶
Create a timestamp for now.
Alias for angzarr_client.helpers.now() for backwards compatibility.
- Returns:
Current time as protobuf Timestamp
- angzarr_client.testing.builders.pack_event(msg: google.protobuf.message.Message) google.protobuf.any_pb2.Any¶
Pack a protobuf message into an Any with the canonical type URL.
The type URL is derived from the message’s descriptor (
msg.DESCRIPTOR.full_name) prefixed with the standardtype.googleapis.com/— per the google.protobuf.Any spec.Audit finding #47 (Option C — drop the second arg, derive name from the message): mirrors Rust’s
testing::builders::pack_event<M>(msg). Removes the previoustype_url_prefixparameter (which was a typo-prone footgun and diverged in semantics from the Rust 2nd-arg convention).- Returns:
ProtoAny containing the packed message.
- angzarr_client.testing.builders.make_cover(domain: str, root: bytes, correlation_id: str = '') angzarr_client.proto.angzarr.Cover¶
Create a Cover from domain and root bytes.
- Parameters:
domain – The aggregate domain name
root – The aggregate root as 16 bytes
correlation_id – Optional correlation ID for cross-domain tracking
- Returns:
Cover proto with domain and root set
- angzarr_client.testing.builders.make_event_page(sequence: int, event: google.protobuf.any_pb2.Any) angzarr_client.proto.angzarr.EventPage¶
Create an EventPage.
- Parameters:
sequence – The event sequence number
event – The packed event (ProtoAny)
- Returns:
EventPage proto
- angzarr_client.testing.builders.make_event_book(cover: angzarr_client.proto.angzarr.Cover, pages: list[angzarr_client.proto.angzarr.EventPage] = None, next_sequence: int = None) angzarr_client.proto.angzarr.EventBook¶
Create an EventBook.
- Parameters:
cover – The Cover identifying the aggregate
pages – List of EventPages (defaults to empty)
next_sequence – Next sequence number (defaults to len(pages))
- Returns:
EventBook proto
- angzarr_client.testing.builders.make_command_page(sequence: int, command: google.protobuf.any_pb2.Any) angzarr_client.proto.angzarr.CommandPage¶
Create a CommandPage.
- Parameters:
sequence – The command sequence number
command – The packed command (ProtoAny)
- Returns:
CommandPage proto
- angzarr_client.testing.builders.make_command_book(cover: angzarr_client.proto.angzarr.Cover, command: google.protobuf.any_pb2.Any, sequence: int = 0) angzarr_client.proto.angzarr.CommandBook¶
Create a CommandBook with a single command.
- Parameters:
cover – The Cover identifying the target aggregate
command – The packed command (ProtoAny)
sequence – The command sequence number (defaults to 0)
- Returns:
CommandBook proto with one page