Skip to content

Commit 7cbbd68

Browse files
updated the files with formatting.
1 parent c6883a5 commit 7cbbd68

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BASE_URI = 'http://0.0.0.0:5000/api/people'
1+
BASE_URI = 'http://127.0.0.1:5000/api/people'

tests/people_test.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
from json import dumps
22
from uuid import uuid4
3-
43
import requests
54
from assertpy.assertpy import assert_that, soft_assertions
6-
75
from config import BASE_URI
86

97

@@ -14,20 +12,18 @@ def test_read_all_has_kent():
1412
# stop the Test script's execution). It will Collect all the failed tests, consolidate all of them with the errors
1513
# and return all the failed test failures in last with the failure messages.
1614
with soft_assertions():
17-
# response from requests has many useful properties
15+
# response from requests has many useful properties.
1816
# we can assert on the response status code
1917
assert_that(response.status_code).is_equal_to(requests.codes.ok)
20-
# We can get python dict as response by using .json() method
18+
# We can convert the JSON to --> Python Dictionary as response by using .json() method
2119
response_content = response.json()
22-
2320
# Use assertpy's fluent assertions to extract all fnames and then see the result is non-empty and has
24-
# Kent in it.
21+
# 'Kent' user in it.
2522
assert_that(response_content).extracting('fname').is_not_empty().contains('Kent')
2623

2724

2825
def test_new_person_can_be_added():
2926
unique_last_name = create_new_person()
30-
3127
# After user is created, we read all the users and then use filter expression to find if the
3228
# created user is present in the response list
3329
peoples = requests.get(BASE_URI).json()
@@ -37,10 +33,8 @@ def test_new_person_can_be_added():
3733

3834
def test_created_person_can_be_deleted():
3935
persons_last_name = create_new_person()
40-
4136
peoples = requests.get(BASE_URI).json()
4237
newly_created_user = search_created_user_in(peoples, persons_last_name)[0]
43-
4438
delete_url = f'{BASE_URI}/{newly_created_user["person_id"]}'
4539
response = requests.delete(delete_url)
4640
assert_that(response.status_code).is_equal_to(requests.codes.ok)
@@ -54,15 +48,12 @@ def create_new_person():
5448
'fname': 'New',
5549
'lname': unique_last_name
5650
})
57-
58-
# Setting default headers to show that the client accepts json
59-
# And will send json in the headers
51+
# Setting default headers to show that the client accepts json and will send the json in the headers
6052
headers = {
6153
'Content-Type': 'application/json',
6254
'Accept': 'application/json'
6355
}
64-
65-
# We use requests.post method with keyword params to make the request more readable
56+
# We use requests.post() method with keyword params to make the request more readable
6657
response = requests.post(url=BASE_URI, data=payload, headers=headers)
6758
assert_that(response.status_code, description='Person not created').is_equal_to(requests.codes.no_content)
6859
return unique_last_name

0 commit comments

Comments
 (0)