forked from Unleash/unleash-client-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
58 lines (50 loc) · 1.63 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
import pytest
import uuid
from datetime import datetime, timezone
from UnleashClient.constants import FEATURES_URL, METRIC_LAST_SENT_TIME, ETAG
from tests.utilities.mocks import MOCK_ALL_FEATURES, MOCK_CUSTOM_STRATEGY
from UnleashClient.cache import FileCache
from tests.utilities.mocks.mock_features import MOCK_FEATURES_WITH_SEGMENTS_RESPONSE
@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()