-
Notifications
You must be signed in to change notification settings - Fork 2
/
conftest.py
31 lines (25 loc) · 947 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Project conftest"""
# pylint: disable=wildcard-import, unused-wildcard-import
import pytest
from fixtures.aws import * # noqa: F403
from fixtures.common import * # noqa: F403
from fixtures.opensearch import * # noqa: F403
from fixtures.users import * # noqa: F403
from main.exceptions import DoNotUseRequestException
@pytest.fixture(autouse=True)
def prevent_requests(mocker, request): # noqa: PT004
"""Patch requests to error on request by default"""
if "mocked_responses" in request.fixturenames:
return
mocker.patch(
"requests.sessions.Session.request",
autospec=True,
side_effect=DoNotUseRequestException,
)
@pytest.fixture(autouse=True)
def _use_dummy_redis_cache_backend(settings):
new_cache_settings = settings.CACHES.copy()
new_cache_settings["redis"] = {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
}
settings.CACHES = new_cache_settings