File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1
1
import requests
2
2
from assertpy.assertpy import assert_that
3
3
4
+ from json import dumps
4
5
from config import BASE_URI
5
6
from utils.print_helpers import pretty_print
7
+ from uuid import uuid4
6
8
7
9
8
10
def test_read_all_has_kent():
@@ -13,3 +15,23 @@ def test_read_all_has_kent():
13
15
assert_that(response.status_code).is_equal_to(200)
14
16
first_names = [people['fname'] for people in response_text]
15
17
assert_that(first_names).contains('Kent')
18
+
19
+
20
+ def test_new_person_can_be_added():
21
+ unique_last_name = f'User {str(uuid4())}'
22
+ payload = dumps({
23
+ 'fname': 'New',
24
+ 'lname': unique_last_name
25
+ })
26
+
27
+ headers = {
28
+ 'Content-Type': 'application/json',
29
+ 'Accept': 'application/json'
30
+ }
31
+
32
+ response = requests.post(url=BASE_URI, data=payload, headers=headers)
33
+ assert_that(response.status_code).is_equal_to(204)
34
+
35
+ people = requests.get(BASE_URI).json()
36
+ is_new_user_created = filter(lambda person: person['lname'] == unique_last_name, people)
37
+ assert_that(is_new_user_created).is_true()
You can’t perform that action at this time.
0 commit comments