forked from codecov/codecov-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
44 lines (36 loc) · 1.37 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
from pathlib import Path
import fakeredis
import pytest
import vcr
from django.conf import settings
# we need to enable this in the test environment since we're often creating
# timeseries data and then asserting something about the aggregates all in
# a single transaction. calling `refresh_continuous_aggregate` doesn't work
# either since it cannot be called in a transaction.
settings.TIMESERIES_REAL_TIME_AGGREGATES = True
def pytest_configure(config):
"""
pytest_configure is the canonical way to configure test server for entire testing suite
"""
pass
@pytest.fixture
def codecov_vcr(request):
current_path = Path(request.node.fspath)
current_path_name = current_path.name.replace(".py", "")
cls_name = request.node.cls.__name__
cassete_path = current_path.parent / "cassetes" / current_path_name / cls_name
current_name = request.node.name
casset_file_path = str(cassete_path / f"{current_name}.yaml")
with vcr.use_cassette(
casset_file_path,
filter_headers=["authorization"],
match_on=["method", "scheme", "host", "port", "path"],
) as cassete_maker:
yield cassete_maker
@pytest.fixture
def mock_redis(mocker):
m = mocker.patch("services.redis_configuration._get_redis_instance_from_url")
redis_server = fakeredis.FakeStrictRedis()
m.return_value = redis_server
yield redis_server