-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathclient.py
More file actions
50 lines (38 loc) · 1.4 KB
/
Copy pathclient.py
File metadata and controls
50 lines (38 loc) · 1.4 KB
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
import requests
import json
from datetime import date, timedelta
from pprint import pprint
app_url = 'http://localhost:5000'
json_header = {'Content-Type': 'application/json'}
def test_view_all_bookings():
response = requests.get(f'{app_url}/bookings')
pprint(response.json())
def test_make_booking():
booking_data = {
'guest_name': 'Sam',
'arrival_date': date.today().strftime("%Y-%m-%d"),
'departure_date': (date.today() + timedelta(days=3)).strftime("%Y-%m-%d"),
}
response = requests.post(f'{app_url}/bookings',
headers=json_header,
data=json.dumps(booking_data))
print(response)
def test_modify_booking():
id_of_booking_to_modify = 5
new_booking_data = {
'guest_name': 'Arthur',
'arrival_date': date.today().strftime("%Y-%m-%d"),
'departure_date': (date.today() + timedelta(days=4)).strftime("%Y-%m-%d"),
}
response = requests.put(f'{app_url}/bookings/{id_of_booking_to_modify}',
headers=json_header,
data=json.dumps(new_booking_data))
print(response)
def test_remove_booking():
id_of_booking_to_delete = 5
response = requests.delete(f'{app_url}/bookings/{id_of_booking_to_delete}')
print(response)
# test_view_all_bookings()
# test_make_booking()
# test_modify_booking()
# test_remove_booking()