Skip to content

Commit 9234086

Browse files
committed
Add restful booker tests
1 parent 7eea88e commit 9234086

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

tests/__init__.py

Whitespace-only changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from assertpy import assert_that, soft_assertions
2+
3+
from clients.restful_booker.restful_booker_client import RestfulBookerClient
4+
5+
client = RestfulBookerClient()
6+
7+
8+
def test_if_new_booking_can_be_created(context, create_data):
9+
response = client.create_booking(create_data)
10+
with soft_assertions():
11+
assert_that(response.status_code).is_equal_to(200)
12+
assert_that(response.as_dict).is_not_empty()
13+
assert_that(response.as_dict).contains("bookingid")
14+
assert_that(response.as_dict["bookingid"]).is_not_none()
15+
context["booking_id"] = client.create_booking(create_data).as_dict["bookingid"]
16+
17+
18+
def test_if_new_booking_can_be_fetched(context):
19+
response = client.get_booking(context.get("booking_id"))
20+
with soft_assertions():
21+
assert_that(response.status_code).is_equal_to(200)
22+
assert_that(response.as_dict).is_not_empty()
23+
assert_that(response.as_dict["firstname"]).is_equal_to("John")
24+
assert_that(response.as_dict["lastname"]).is_equal_to("Wick")
25+
26+
27+
def test_if_new_booking_can_be_updated(context, update_data):
28+
response = client.update_booking(context.get("booking_id"), update_data)
29+
with soft_assertions():
30+
assert_that(response.status_code).is_equal_to(200)
31+
assert_that(response.as_dict).is_not_empty()
32+
assert_that(response.as_dict["additionalneeds"]).is_equal_to("Dinner")
33+
34+
35+
def test_if_new_booking_can_be_deleted(context):
36+
response = client.delete_booking(context.get("booking_id"))
37+
with soft_assertions():
38+
assert_that(response.status_code).is_equal_to(201)
39+
assert_that(response.as_dict).is_empty()

0 commit comments

Comments
 (0)