From 4295b0240613a68fdcf5cd5a173849914eed8c84 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 17 Jul 2026 18:32:57 +0200 Subject: [PATCH] Fix tests after hierarkey update --- src/tests/api/test_checkin.py | 10 +++++----- src/tests/api/test_checkinrpc.py | 4 ++-- src/tests/api/test_events.py | 2 +- src/tests/api/test_orders.py | 4 ++-- src/tests/base/test_cross_selling.py | 6 +++--- src/tests/base/test_memberships.py | 2 +- src/tests/conftest.py | 6 ++++++ 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/tests/api/test_checkin.py b/src/tests/api/test_checkin.py index 25e270d4a..2e15b6174 100644 --- a/src/tests/api/test_checkin.py +++ b/src/tests/api/test_checkin.py @@ -252,7 +252,7 @@ TEST_HISTORY_RES = { } -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_list_list(token_client, organizer, event, clist, item, subevent, django_assert_num_queries): res = dict(TEST_LIST_RES) res["id"] = clist.pk @@ -422,7 +422,7 @@ def test_list_update(token_client, organizer, event, clist): assert cl.name == "VIP" -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_list_all_items_positions(token_client, organizer, event, clist, clist_all, item, other_item, order, django_assert_num_queries): with scopes_disabled(): p1 = dict(TEST_ORDERPOSITION1_RES) @@ -680,7 +680,7 @@ def _redeem(token_client, org, clist, p, body=None): ), body or {}, format='json') -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_query_load(token_client, organizer, clist, event, order, django_assert_max_num_queries): with scopes_disabled(): p = order.positions.first().pk @@ -1368,7 +1368,7 @@ def test_redeem_addon_if_match_and_revoked_force(token_client, organizer, clist, assert ci.position == p -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_search(token_client, organizer, event, clist, clist_all, item, other_item, order, django_assert_max_num_queries): with scopes_disabled(): p1 = dict(TEST_ORDERPOSITION1_RES) @@ -1400,7 +1400,7 @@ def test_checkin_pdf_data_requires_permission(token_client, event, team, organiz assert not resp.data['results'][0].get('pdf_data') -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_expand(token_client, organizer, event, clist, clist_all, item, other_item, order, django_assert_max_num_queries): with scopes_disabled(): op = order.positions.first() diff --git a/src/tests/api/test_checkinrpc.py b/src/tests/api/test_checkinrpc.py index 0c5c387a9..6ea5066cb 100644 --- a/src/tests/api/test_checkinrpc.py +++ b/src/tests/api/test_checkinrpc.py @@ -214,7 +214,7 @@ def _redeem(token_client, org, clist, p, body=None, query='', headers={}): ), body, format='json', headers={}) -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_query_load(token_client, organizer, clist, event, order, django_assert_max_num_queries): with scopes_disabled(): p = order.positions.first() @@ -996,7 +996,7 @@ def test_redeem_conflicting_lists(token_client, organizer, clist, clist_all, eve assert resp.data == ['Selecting two check-in lists from the same event is unsupported.'] -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_search(token_client, organizer, event, clist, clist_all, item, other_item, order, django_assert_max_num_queries): with scopes_disabled(): diff --git a/src/tests/api/test_events.py b/src/tests/api/test_events.py index eb7d3bb86..56b714d70 100644 --- a/src/tests/api/test_events.py +++ b/src/tests/api/test_events.py @@ -1848,7 +1848,7 @@ def test_event_block_unblock_seat_bulk(token_client, organizer, event, seatingpl assert not s2.blocked -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_event_expand_seat_filter_and_querycount(token_client, organizer, event, seatingplan, item): event.settings.seating_minimal_distance = 2 diff --git a/src/tests/api/test_orders.py b/src/tests/api/test_orders.py index a41b72de5..f2cab9196 100644 --- a/src/tests/api/test_orders.py +++ b/src/tests/api/test_orders.py @@ -1058,7 +1058,7 @@ def test_orderposition_list_limited_read( ('/api/v1/organizers/{}/orderpositions/', "organizer") ], ) -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_orderposition_list( endpoint_template, endpoint_type, @@ -2036,7 +2036,7 @@ def test_blocked_secret_list(token_client, organizer, event): assert [res] == resp.data['results'] -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_pdf_data(token_client, organizer, event, order, django_assert_max_num_queries): # order detail resp = token_client.get('/api/v1/organizers/{}/events/{}/orders/{}/?pdf_data=true'.format( diff --git a/src/tests/base/test_cross_selling.py b/src/tests/base/test_cross_selling.py index 635a0d2e8..ffbd0f49a 100644 --- a/src/tests/base/test_cross_selling.py +++ b/src/tests/base/test_cross_selling.py @@ -732,7 +732,7 @@ def test_five_tickets_one_free(event): @scopes_disabled() -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) @pytest.mark.parametrize("itemcount", [3, 10, 50]) def test_query_count_many_items(event, itemcount): setup_items(event, 'Tickets', 'both', 'discounts', @@ -784,7 +784,7 @@ def test_query_count_many_items(event, itemcount): @scopes_disabled() -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) @pytest.mark.parametrize("catcount", [1, 10, 50]) def test_query_count_many_categories_and_discounts(event, catcount): for n in range(1, catcount + 1): @@ -838,7 +838,7 @@ def test_query_count_many_categories_and_discounts(event, catcount): @scopes_disabled() -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) @pytest.mark.parametrize("catcount", [2, 10, 50]) def test_query_count_many_cartpos(event, catcount): for n in range(1, catcount + 1): diff --git a/src/tests/base/test_memberships.py b/src/tests/base/test_memberships.py index 33ce29e68..4b6d0fe9c 100644 --- a/src/tests/base/test_memberships.py +++ b/src/tests/base/test_memberships.py @@ -210,7 +210,7 @@ def test_validate_membership_required(event, customer, membership, requiring_tic assert "requires an active" in str(excinfo.value) -@pytest.mark.django_db +@pytest.mark.django_db(transaction=True) def test_validate_membership_ensure_locking(event, customer, membership, requiring_ticket, membership_type, django_assert_num_queries): with django_assert_num_queries(4) as captured: validate_memberships_in_order( diff --git a/src/tests/conftest.py b/src/tests/conftest.py index aadca8109..415a599c6 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -28,6 +28,7 @@ from django.test import override_settings from django.utils import translation from django_scopes import scopes_disabled from fakeredis import FakeRedisConnection +from hierarkey.proxy import dirty_cache_keys from xdist.dsession import DSession from pretix.testutils.mock import get_redis_connection @@ -82,6 +83,11 @@ def reset_locale(): translation.activate("en") +@pytest.fixture(autouse=True) +def reset_hierarkey_cache_state(): + dirty_cache_keys.set(set()) + + @pytest.fixture def fakeredis_client(monkeypatch): worker_id = os.environ.get("PYTEST_XDIST_WORKER")