Skip to content

Commit

Permalink
test(transport): Non-order-dependent discarded events assertion
Browse files Browse the repository at this point in the history
Make the `report["discarded_events"]` assertion logic (in `test_data_category_limits_reporting`) not rely on the ordering of events or any sorting logic. Done in preparation of #3244, where the sorting logic cannot be relied on anymore, since the same number of spans will be discarded as transactions.
  • Loading branch information
szokeasaurusrex committed Jul 8, 2024
1 parent 69ecd87 commit 54b32f2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/test_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,21 @@ def intercepting_fetch(*args, **kwargs):
assert envelope.items[0].type == "event"
assert envelope.items[1].type == "client_report"
report = parse_json(envelope.items[1].get_bytes())
assert sorted(report["discarded_events"], key=lambda x: x["quantity"]) == [
{"category": "transaction", "reason": "ratelimit_backoff", "quantity": 2},
{"category": "attachment", "reason": "ratelimit_backoff", "quantity": 11},
]

discarded_events = report["discarded_events"]

assert len(discarded_events) == 2
assert {
"category": "transaction",
"reason": "ratelimit_backoff",
"quantity": 2,
} in discarded_events
assert {
"category": "attachment",
"reason": "ratelimit_backoff",
"quantity": 11,
} in discarded_events

capturing_server.clear_captured()

# here we sent a normal event
Expand Down

0 comments on commit 54b32f2

Please sign in to comment.