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.
This commit is contained in:
Benjamin Dauvergne 2021-05-06 10:17:30 +02:00
parent 99a912e255
commit 5b5d046414
2 changed files with 7 additions and 0 deletions

View File

@ -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:

View File

@ -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