Skip to content

Commit 05ce4f0

Browse files
committed
test(django): Use a local case table for the ASGI user identity test
test_user_identity_error_event_data_collection borrowed the shared 6-row DATA_COLLECTION_USER_INFO_CASES table, 2 rows of which cover send_default_pii vs. data_collection precedence — already asserted by the WSGI tests in test_data_scrubbing.py. Replace it with a local 4-row table covering the branches asgi.py actually takes: pii on/off crossed with data_collection user_info on/off.
1 parent d4e7586 commit 05ce4f0

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

tests/integrations/django/asgi/test_asgi.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from sentry_sdk.integrations.django.asgi import _asgi_middleware_mixin_factory
1818
from tests.integrations.django.myapp.asgi import channels_application
1919
from tests.integrations.django.utils import pytest_mark_django_db_decorator
20-
from tests.integrations.utils import DATA_COLLECTION_USER_INFO_CASES
2120

2221
try:
2322
from django.urls import reverse
@@ -1046,7 +1045,27 @@ async def test_async_middleware_process_exception_is_awaited(
10461045
@pytest.mark.skipif(
10471046
django.VERSION < (3, 0), reason="Django ASGI support shipped in 3.0"
10481047
)
1049-
@pytest.mark.parametrize("init_kwargs, expect_user", DATA_COLLECTION_USER_INFO_CASES)
1048+
# The full precedence table (data_collection winning over send_default_pii)
1049+
# is covered by the WSGI tests in test_data_scrubbing.py; here we only need
1050+
# each user-info branch of the ASGI middleware: legacy pii on/off and
1051+
# data_collection user_info on/off (asgi.py:75-83, _asgi_common.py:129-143).
1052+
@pytest.mark.parametrize(
1053+
"init_kwargs, expect_user",
1054+
[
1055+
pytest.param({"send_default_pii": True}, True, id="pii_on"),
1056+
pytest.param({"send_default_pii": False}, False, id="pii_off"),
1057+
pytest.param(
1058+
{"_experiments": {"data_collection": {"user_info": True}}},
1059+
True,
1060+
id="data_collection_user_info_on",
1061+
),
1062+
pytest.param(
1063+
{"_experiments": {"data_collection": {"user_info": False}}},
1064+
False,
1065+
id="data_collection_user_info_off",
1066+
),
1067+
],
1068+
)
10501069
@pytest_mark_django_db_decorator()
10511070
async def test_user_identity_error_event_data_collection(
10521071
sentry_init, capture_events, application, init_kwargs, expect_user

0 commit comments

Comments
 (0)