|
2 | 2 | from uuid import uuid4
|
3 | 3 |
|
4 | 4 | import requests
|
5 |
| -from assertpy.assertpy import assert_that |
| 5 | +from assertpy.assertpy import assert_that, soft_assertions |
6 | 6 |
|
7 | 7 | from config import BASE_URI
|
8 | 8 |
|
9 | 9 |
|
10 | 10 | def test_read_all_has_kent():
|
11 | 11 | # We use requests.get() with url to make a get request
|
12 | 12 | response = requests.get(BASE_URI)
|
13 |
| - # 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) |
16 |
| - # We can get python dict as response by using .json() method |
17 |
| - response_content = response.json() |
18 |
| - |
19 |
| - # Use assertpy's fluent assertions to extract all fnames and then see the result is non empty and has |
20 |
| - # Kent in it. |
21 |
| - assert_that(response_content).extracting('fname').is_not_empty().contains('Kent') |
| 13 | + # Added the soft_assertions() - we use this when we want our Test to run successfully (means failing one test won't |
| 14 | + # stop the Test script's execution). Collect all the failures, consolidate all the errors and return all the test |
| 15 | + # failures in last. |
| 16 | + with soft_assertions(): |
| 17 | + # response from requests has many useful properties |
| 18 | + # we can assert on the response status code |
| 19 | + assert_that(response.status_code).is_equal_to(requests.codes.ok) |
| 20 | + # We can get python dict as response by using .json() method |
| 21 | + response_content = response.json() |
| 22 | + |
| 23 | + # Use assertpy's fluent assertions to extract all fnames and then see the result is non empty and has |
| 24 | + # Kent in it. |
| 25 | + assert_that(response_content).extracting('fname').is_not_empty().contains('Kent') |
22 | 26 |
|
23 | 27 |
|
24 | 28 | def test_new_person_can_be_added():
|
|
0 commit comments