Skip to content

Commit 6eb498e

Browse files
add document text section about the lecture detail.
1 parent 7e772e6 commit 6eb498e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/people_test.py

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

7+
'''
8+
We'll learn in this section is -: How to work with XML?
9+
Any automation framework that you create is probably incomplete without having the ability to deal with XML requests &
10+
responses. You might need this if you're automating the SOAP Based service, you might want to use the XML as a datatype
11+
to store your test data or work with certain pre-created test data.
12+
So let's understand how we can work with the XML in Python.
13+
We'll use 'lxml' library which is very popular having nice python api.
14+
'''
15+
916

1017
def test_read_all_has_kent():
1118
# We use requests.get() with url to make a get request
@@ -15,15 +22,13 @@ def test_read_all_has_kent():
1522
assert_that(response.status_code).is_equal_to(requests.codes.ok)
1623
# We can get python dict as response by using .json() method
1724
response_content = response.json()
18-
1925
# Use assertpy's fluent assertions to extract all fnames and then see the result is non empty and has
2026
# Kent in it.
2127
assert_that(response_content).extracting('fname').is_not_empty().contains('Kent')
2228

2329

2430
def test_new_person_can_be_added():
2531
unique_last_name = create_new_person()
26-
2732
# After user is created, we read all the users and then use filter expression to find if the
2833
# created user is present in the response list
2934
peoples = requests.get(BASE_URI).json()
@@ -33,10 +38,8 @@ def test_new_person_can_be_added():
3338

3439
def test_created_person_can_be_deleted():
3540
persons_last_name = create_new_person()
36-
3741
peoples = requests.get(BASE_URI).json()
3842
newly_created_user = search_created_user_in(peoples, persons_last_name)[0]
39-
4043
delete_url = f'{BASE_URI}/{newly_created_user["person_id"]}'
4144
response = requests.delete(delete_url)
4245
assert_that(response.status_code).is_equal_to(requests.codes.ok)
@@ -50,14 +53,12 @@ def create_new_person():
5053
'fname': 'New',
5154
'lname': unique_last_name
5255
})
53-
5456
# Setting default headers to show that the client accepts json
5557
# And will send json in the headers
5658
headers = {
5759
'Content-Type': 'application/json',
5860
'Accept': 'application/json'
5961
}
60-
6162
# We use requests.post method with keyword params to make the request more readable
6263
response = requests.post(url=BASE_URI, data=payload, headers=headers)
6364
assert_that(response.status_code, description='Person not created').is_equal_to(requests.codes.no_content)

0 commit comments

Comments
 (0)