Skip to content

Commit 525ee9f

Browse files
committed
Refactor some more tests
1 parent a3dad4a commit 525ee9f

File tree

2 files changed

+60
-20
lines changed

2 files changed

+60
-20
lines changed

tests/integration/test_ourlogs.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,17 +343,36 @@ def test_ourlog_extraction_with_string_pii_scrubbing(
343343
envelope = mini_sentry.captured_events.get()
344344
item_payload = json.loads(envelope.items[0].payload.bytes.decode())
345345
item = item_payload["items"][0]
346-
attributes = item["attributes"]
347-
348-
assert "test_pii" in attributes
349-
assert attributes["test_pii"]["value"] == expected_scrubbed
350-
assert "_meta" in item
351-
meta = item["_meta"]["attributes"]["test_pii"]["value"][""]
352-
assert "rem" in meta
353346

354-
# Check that the rule type is mentioned in the metadata
355-
rem_info = meta["rem"][0]
356-
assert rule_type in rem_info[0]
347+
assert item == {
348+
"trace_id": "5b8efff798038103d269b633813fc60c",
349+
"span_id": "eee19b7ec3c1b174",
350+
"attributes": {
351+
"test_pii": { "type": "string", "value": expected_scrubbed},
352+
"sentry.browser.name": {"type": "string", "value": "Python Requests"},
353+
"sentry.browser.version": {"type": "string", "value": "2.32"},
354+
"sentry.observed_timestamp_nanos": {
355+
"type": "string",
356+
"value": time_within(ts, expect_resolution="ns"),
357+
},
358+
},
359+
"__header": {"byte_size": mock.ANY},
360+
"_meta": {
361+
"attributes": {
362+
"test_pii": {
363+
"value": {
364+
"": {
365+
"len": mock.ANY,
366+
"rem": [[rule_type, mock.ANY, mock.ANY, mock.ANY]]
367+
}
368+
}
369+
}
370+
},
371+
},
372+
"body": "Test log",
373+
"level": "info",
374+
"timestamp": time_within(ts),
375+
}
357376

358377

359378
def test_ourlog_extraction_default_pii_scrubbing_attributes(

tests/integration/test_spansv2.py

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -577,17 +577,38 @@ def test_spanv2_with_string_pii_scrubbing(
577577
envelope = mini_sentry.captured_events.get()
578578
item_payload = json.loads(envelope.items[0].payload.bytes.decode())
579579
item = item_payload["items"][0]
580-
attributes = item["attributes"]
581-
582-
assert "test_pii" in attributes
583-
assert attributes["test_pii"]["value"] == expected_scrubbed
584-
assert "_meta" in item
585-
meta = item["_meta"]["attributes"]["test_pii"]["value"][""]
586-
assert "rem" in meta
587580

588-
# Check that the rule type is mentioned in the metadata
589-
rem_info = meta["rem"][0]
590-
assert rule_type in rem_info[0]
581+
assert item == {
582+
"trace_id": "5b8efff798038103d269b633813fc60c",
583+
"span_id": "eee19b7ec3c1b174",
584+
"attributes": {
585+
"test_pii": { "type": "string", "value": expected_scrubbed},
586+
"sentry.browser.name": {"type": "string", "value": "Python Requests"},
587+
"sentry.browser.version": {"type": "string", "value": "2.32"},
588+
"sentry.observed_timestamp_nanos": {
589+
"type": "string",
590+
"value": time_within(ts, expect_resolution="ns"),
591+
},
592+
},
593+
"_meta": {
594+
"attributes": {
595+
"test_pii": {
596+
"value": {
597+
"": {
598+
"len": mock.ANY,
599+
"rem": [[rule_type, mock.ANY, mock.ANY, mock.ANY]]
600+
}
601+
}
602+
}
603+
},
604+
"status": {"": {"err": ["missing_attribute"]}},
605+
},
606+
"name": "Test span",
607+
"start_timestamp": time_within(ts),
608+
"end_timestamp": time_within(ts.timestamp() + 0.5),
609+
"is_remote": False,
610+
"status": None,
611+
}
591612

592613

593614
def test_spanv2_default_pii_scrubbing_attributes(

0 commit comments

Comments
 (0)