Projet

Général

Profil

0002-misc-add-setting-to-force-synchronous-rendering-of-c.patch

Benjamin Dauvergne, 06 mai 2021 15:23

Télécharger (1,43 ko)

Voir les différences:

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(+)
combo/public/views.py
591 591
    }
592 592
    ctx.update(getattr(request, 'extra_context_data', {}))
593 593
    modify_global_context(request, ctx)
594
    if getattr(settings, 'COMBO_TEST_ALWAYS_RENDER_CELLS_SYNCHRONOUSLY', False):
595
        ctx['synchronous'] = True
594 596

  
595 597
    for cell in cells:
596 598
        if cell.modify_global_context:
tests/conftest.py
57 57
            'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
58 58
        }
59 59
    }
60

  
61

  
62
@pytest.fixture
63
def synchronous_cells(settings):
64
    settings.COMBO_TEST_ALWAYS_RENDER_CELLS_SYNCHRONOUSLY = True
60
-