Skip to content

Commit 1a494c4

Browse files
author
Gaurav Singh
committed
Showing off user of requests.codes to have readable http codes
1 parent ae5ac93 commit 1a494c4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tests/people_test.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ def test_read_all_has_kent():
1111
# We use requests.get() with url to make a get request
1212
response = requests.get(BASE_URI)
1313
# response from requests has many useful properties
14+
# we can assert on the response status code
15+
assert_that(response.status_code).is_equal_to(requests.codes.ok)
1416
# We can get python dict as response by using .json() method
1517
response_text = response.json()
16-
pretty_print(response_text)
17-
18-
# Also we can assert on the response status code
19-
assert_that(response.status_code).is_equal_to(200)
2018
first_names = [people['fname'] for people in response_text]
2119
assert_that(first_names).contains('Kent')
2220

@@ -39,7 +37,7 @@ def test_new_person_can_be_added():
3937

4038
# We use requests.post method with keyword params to make the request more readable
4139
response = requests.post(url=BASE_URI, data=payload, headers=headers)
42-
assert_that(response.status_code).is_equal_to(204)
40+
assert_that(response.status_code).is_equal_to(requests.codes.no_content)
4341

4442
# After user is created, we read all the users and then use filter expression to find if the
4543
# created user is present in the response list

0 commit comments

Comments
 (0)