From 5b5d0464146824116ed98ee8946330e128c8b981 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 6 May 2021 10:17:30 +0200 Subject: [PATCH 2/3] misc: add setting to force synchronous rendering of cells (#49149) The setting is used through a new fixture, `synchronous_cells`. It's necessary to test views with cells which always use ajax rendering without an headless browser or using the request factory. --- combo/public/views.py | 2 ++ tests/conftest.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/combo/public/views.py b/combo/public/views.py index a4f016f1..612b015b 100644 --- a/combo/public/views.py +++ b/combo/public/views.py @@ -591,6 +591,8 @@ def publish_page(request, page, status=200, template_name=None): } ctx.update(getattr(request, 'extra_context_data', {})) modify_global_context(request, ctx) + if getattr(settings, 'COMBO_TEST_ALWAYS_RENDER_CELLS_SYNCHRONOUSLY', False): + ctx['synchronous'] = True for cell in cells: if cell.modify_global_context: diff --git a/tests/conftest.py b/tests/conftest.py index e7aa5856..f9fe2606 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -57,3 +57,8 @@ def nocache(settings): 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', } } + + +@pytest.fixture +def synchronous_cells(settings): + settings.COMBO_TEST_ALWAYS_RENDER_CELLS_SYNCHRONOUSLY = True -- 2.31.1