PublishedList¶
- class safir.metrics.PublishedList(iterable=(), /)¶
Bases:
list
[P
]A list of event payload models with assertion helpers.
All assertion helpers take lists of dicts as expected items and use the
model_dump(mode="json")
serialization of the models for comparison.Methods Summary
assert_published
(expected, *[, any_order])Assert that all of the expected payloads were published.
assert_published_all
(expected, *[, any_order])Assert that all of the expected payloads, and only the expected payloads, were published.
Methods Documentation
- assert_published(expected, *, any_order=False)¶
Assert that all of the expected payloads were published.
- Parameters:
expected (
list
[dict
[str
,Any
]]) – A list of expected event payload dicts, to be compared with themodel_dump(format="json")
serialization of the actual published payloads.any_order (
bool
, default:False
) – If true, then the expected payload list must be an ordered subset of the actual published payloads. This is like theany_order
parameter inunittest.mock.Mock
methods.
- Raises:
PublishedTooFewError – Expected more events than have actually been published
NotPublishedError – Some expected items were not published
NotPublishedConsecutivelyError – Expected events were not published consecutively
- Return type:
- assert_published_all(expected, *, any_order=False)¶
Assert that all of the expected payloads, and only the expected payloads, were published.
- Parameters:
expected (
list
[dict
[str
,Any
]]) – A list of expected event payload dicts, to be compared with themodel_dump(format="json")
serialization of the actual published payloads.any_order (
bool
, default:False
) – If true, then the expected payloads must be in the same order as the actual published payloads. This is like theany_order
parameter inunittest.mock.Mock
methods.
- Raises:
NotPublishedError – Some expected items were not published
NotPublishedConsecutivelyError – Expected events were not published consecutively
PublishedCountError – A different number of events were published than were expected
- Return type: