-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
71 lines (59 loc) · 1.81 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
65
66
67
68
69
70
71
import pytest
import requests
@pytest.fixture
def api_client():
class Client:
def __init__(self, endpoint):
self.BASE_URI = f"http://127.0.0.1:5000/{endpoint}"
self.headers = {"Content-Type": "application/json"}
def get_all(self, params=None):
r = requests.get(f"{self.BASE_URI}", headers=self.headers, params=params)
return r
def get(self, id):
r = requests.get(
f"{self.BASE_URI}/{id}",
headers=self.headers,
)
return r
def create(self, payload):
p = requests.post(
f"{self.BASE_URI}",
json=payload,
headers=self.headers,
)
return p
def delete(self, id):
d = requests.delete(
f"{self.BASE_URI}/{id}",
headers=self.headers,
)
return d
def update(self, id, payload):
p = requests.put(
f"{self.BASE_URI}/{id}",
json=payload,
headers=self.headers,
)
return p
def partially_update(self, id, payload):
p = requests.patch(
f"{self.BASE_URI}/{id}",
json=payload,
headers=self.headers,
)
return p
return Client
@pytest.fixture
def payload():
class Payload:
artist = {
"name": "Future",
"first_name": "Nayvadius",
"last_name": "Wilburn",
"phone": "412-546-6931",
"website": "futurefreebandz.com",
"is_group": False,
}
album = {"artist_id": 5, "name": "X&Y"}
song = {"album_id": 4, "name": "Foreign", "duration": 2.22}
return Payload