def assert_events_match(self, expected_events, actual_events, in_order=True): """Assert that each actual event matches one of the expected events. Args: expected_events (List): a list of dicts representing the expected events. actual_events (List): a list of dicts that were actually recorded. in_order (bool): if True then the events must be in the same order (defaults to True). """ if in_order: for expected_event, actual_event in zip(expected_events, actual_events): assert_event_matches(expected_event, actual_event, tolerate=EventMatchTolerates.lenient()) else: for expected_event in expected_events: actual_event = next( event for event in actual_events if is_matching_event(expected_event, event)) assert_event_matches(expected_event, actual_event or {}, tolerate=EventMatchTolerates.lenient())
def assert_events_match(self, expected_events, actual_events, in_order=True): """Assert that each actual event matches one of the expected events. Args: expected_events (List): a list of dicts representing the expected events. actual_events (List): a list of dicts that were actually recorded. in_order (bool): if True then the events must be in the same order (defaults to True). """ if in_order: for expected_event, actual_event in zip(expected_events, actual_events): expected_field = (None if expected_event.get('event') is None else expected_event.get('event').get('field')) has_field = expected_field is not None actual_event_to_compare = (next( item for item in actual_events if item.get('event').get('field') == expected_field) ) if has_field else actual_event assert_event_matches(expected_event, actual_event_to_compare, tolerate=EventMatchTolerates.lenient()) else: for expected_event in expected_events: actual_event = next( event for event in actual_events if is_matching_event(expected_event, event)) assert_event_matches(expected_event, actual_event or {}, tolerate=EventMatchTolerates.lenient())
def assert_events_match(self, expected_events, actual_events, in_order=True): """Assert that each actual event matches one of the expected events. Args: expected_events (List): a list of dicts representing the expected events. actual_events (List): a list of dicts that were actually recorded. in_order (bool): if True then the events must be in the same order (defaults to True). """ if in_order: for expected_event, actual_event in zip(expected_events, actual_events): assert_event_matches(expected_event, actual_event, tolerate=EventMatchTolerates.lenient()) else: for expected_event in expected_events: actual_event = next(event for event in actual_events if is_matching_event(expected_event, event)) assert_event_matches(expected_event, actual_event or {}, tolerate=EventMatchTolerates.lenient())
def assert_events_match(self, expected_events, actual_events): """ Assert that each item in the expected events sequence matches its counterpart at the same index in the actual events sequence. """ for expected_event, actual_event in zip(expected_events, actual_events): assert_event_matches(expected_event, actual_event, tolerate=EventMatchTolerates.lenient())
def assert_events_match(self, expected_events, actual_events): """ Assert that each item in the expected events sequence matches its counterpart at the same index in the actual events sequence. """ for expected_event, actual_event in zip(expected_events, actual_events): assert_event_matches( expected_event, actual_event, tolerate=EventMatchTolerates.lenient() )