From 3c1b0894d0436cee31afce3b8e6685bfde0b42e2 Mon Sep 17 00:00:00 2001 From: Ivan Tustanivskyi Date: Thu, 14 Mar 2024 14:47:24 +0200 Subject: [PATCH] fix tests --- tests/assertions.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/assertions.py b/tests/assertions.py index dc92e4f4c..fbd9fa2a0 100644 --- a/tests/assertions.py +++ b/tests/assertions.py @@ -37,18 +37,14 @@ def assert_session(envelope, extra_assertion=None): if extra_assertion: assert_matches(session, extra_assertion) -def assert_user_feedback(envelope, extra_assertion=None): - user_feedback = None - for item in envelope: - if item.headers.get("type") == "user_report" and item.payload.json is not None: - user_feedback = item.payload.json - - assert user_feedback is not None - assert user_feedback["name"] == "some-name" - assert user_feedback["email"] == "some-email" - assert user_feedback["comments"] == "some-comment" - if extra_assertion: - assert_matches(user_feedback, extra_assertion) +def assert_user_feedback(envelope): + expected = { + "type": "user_report", + "name": "some-name", + "email": "some-email", + "comments": "some-comment" + } + assert any(matches(item.headers, expected) for item in envelope) def assert_meta(