コード例 #1
0
def reset_cache(request):
    """
    Resetts the cache for every test
    """
    if 'django_db' in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original cachables
        element_cache.ensure_cache(reset=True)
コード例 #2
0
def reset_cache(request):
    """
    Resetts the cache for every test
    """
    if 'django_db' in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original cachables
        async_to_sync(element_cache.cache_provider.clear_cache)()
        element_cache.ensure_cache(reset=True)

    # Set constant start_time
    element_cache.start_time = 1
コード例 #3
0
ファイル: conftest.py プロジェクト: CatoTH/OpenSlides
def reset_cache(request):
    """
    Resetts the cache for every test
    """
    if "django_db" in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original cachables
        async_to_sync(element_cache.cache_provider.clear_cache)()
        element_cache.ensure_cache(reset=True)

    # Set constant start_time
    element_cache.start_time = 1
コード例 #4
0
ファイル: conftest.py プロジェクト: topelrapha/OpenSlides
def reset_cache(request):
    """
    Resetts the cache for every test
    """
    if "django_db" in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original cachables
        async_to_sync(element_cache.cache_provider.clear_cache)()
        element_cache.ensure_cache(reset=True)

    # Set constant default change_id
    cast(MemoryCacheProvider,
         element_cache.cache_provider).default_change_id = 1
コード例 #5
0
def constants(request):
    """
    Resets the constants on every test.

    Uses fake constants, if the db is not in use.
    """
    from openslides.utils.constants import set_constants, get_constants_from_apps

    if 'django_db' in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original constants
        set_constants(get_constants_from_apps())
    else:
        # Else: Use fake constants
        set_constants({'constant1': 'value1', 'constant2': 'value2'})
コード例 #6
0
ファイル: conftest.py プロジェクト: CatoTH/OpenSlides
def constants(request):
    """
    Resets the constants on every test.

    Uses fake constants, if the db is not in use.
    """
    from openslides.utils.constants import set_constants, get_constants_from_apps

    if "django_db" in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original constants
        set_constants(get_constants_from_apps())
    else:
        # Else: Use fake constants
        set_constants({"constant1": "value1", "constant2": "value2"})
コード例 #7
0
ファイル: conftest.py プロジェクト: topelrapha/OpenSlides
def constants(request, reset_cache):
    """
    Resets the constants on every test. The filled cache is needed to
    build the constants, because some of them depends on the config.

    Uses fake constants, if the db is not in use.
    """
    from openslides.utils.constants import get_constants_from_apps, set_constants

    if "django_db" in request.node.keywords or is_django_unittest(request):
        # When the db is created, use the original constants
        set_constants(get_constants_from_apps())
    else:
        # Else: Use fake constants
        set_constants({"constant1": "value1", "constant2": "value2"})
コード例 #8
0
def db(request, django_db_setup, django_db_blocker):
    """
    Override this fixture from pytest-django to support multi db
    """
    from django.test import TestCase  # NOQA

    class MultiDBTestCase(TestCase):
        multi_db = True

        def _fixture_setup(self):
            assert not self.reset_sequences, 'reset_sequences cannot be used on TestCase instances'
            self.atomics = self._enter_atomics()

        def _fixture_teardown(self):
            self._rollback_atomics(self.atomics)

    if is_django_unittest(request):
        return

    django_db_blocker.unblock()
    test_case = MultiDBTestCase(methodName='__init__')
    test_case._pre_setup()
    request.addfinalizer(test_case._post_teardown)