-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
64 lines (44 loc) · 1.17 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
64
import json
from os import environ
import pytest
from workwork.server import create_app
@pytest.fixture
def config():
_config = {
"AWS_ACCESS_KEY_ID": "abc-123",
"AWS_SECRET_ACCESS_KEY": "def-456",
"API_KEY": "2eb05a35-1bb4-4900-a247-1aa5166ddf99",
}
for key, value in _config.items():
environ[key] = value
return _config
@pytest.fixture
def app(config):
_app = create_app(config=config)
_app.config["DEBUG"] = True
return _app
@pytest.fixture
def client(app):
return app.test_client()
@pytest.fixture
def instance_payload(config):
payload = {
"api_key": config["API_KEY"],
}
return Payload(payload)
class Payload:
def __init__(self, payload):
self.payload = payload
def __getitem__(self, key):
return self.payload[key]
def __setitem__(self, key, value):
self.payload[key] = value
def __delitem__(self, key):
del self.payload[key]
def to_json(self):
return {
"data": json.dumps(self.payload),
"content_type": "application/json",
}
def to_dict(self):
return self.payload