forked from Unleash/unleash-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
63 lines (53 loc) · 1.7 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import uuid
from datetime import datetime, timezone
import pytest
from tests.utilities.mocks import MOCK_ALL_FEATURES, MOCK_CUSTOM_STRATEGY
from tests.utilities.mocks.mock_features import MOCK_FEATURES_WITH_SEGMENTS_RESPONSE
from UnleashClient.cache import FileCache
from UnleashClient.constants import ETAG, FEATURES_URL, METRIC_LAST_SENT_TIME
@pytest.fixture()
def cache_empty():
cache_name = "pytest_%s" % uuid.uuid4()
temporary_cache = FileCache(cache_name)
temporary_cache.mset({METRIC_LAST_SENT_TIME: datetime.now(timezone.utc), ETAG: ""})
yield temporary_cache
temporary_cache.destroy()
@pytest.fixture()
def cache_full():
cache_name = "pytest_%s" % uuid.uuid4()
temporary_cache = FileCache(cache_name)
temporary_cache.mset(
{
FEATURES_URL: MOCK_ALL_FEATURES,
METRIC_LAST_SENT_TIME: datetime.now(timezone.utc),
ETAG: "",
}
)
yield temporary_cache
temporary_cache.destroy()
@pytest.fixture()
def cache_custom():
cache_name = "pytest_%s" % uuid.uuid4()
temporary_cache = FileCache(cache_name)
temporary_cache.mset(
{
FEATURES_URL: MOCK_CUSTOM_STRATEGY,
METRIC_LAST_SENT_TIME: datetime.now(timezone.utc),
ETAG: "",
}
)
yield temporary_cache
temporary_cache.destroy()
@pytest.fixture()
def cache_segments():
cache_name = "pytest_%s" % uuid.uuid4()
temporary_cache = FileCache(cache_name)
temporary_cache.mset(
{
FEATURES_URL: MOCK_FEATURES_WITH_SEGMENTS_RESPONSE,
METRIC_LAST_SENT_TIME: datetime.now(timezone.utc),
ETAG: "",
}
)
yield temporary_cache
temporary_cache.destroy()