Skip to content

Update people_test.py #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update people_test.py
  • Loading branch information
kel-expel committed Aug 12, 2021
commit 960d1b5e0f44f106e6484a9fb693750b426adec0
14 changes: 8 additions & 6 deletions tests/people_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
from config import BASE_URI


def test_read_all_has_kent():
def test_read_all_has_Dak():
# We use requests.get() with url to make a get request
response = requests.get(BASE_URI)
# response from requests has many useful properties
# we can assert on the response status code
assert_that(response.status_code).is_equal_to(requests.codes.ok)

# We can get python dict as response by using .json() method
response_text = response.json()
first_names = [people['fname'] for people in response_text]
assert_that(first_names).contains('Kent')
first_names = [people['first_name'] for people in response_text]
assert_that(first_names).contains('Dak')


def test_new_person_can_be_added():
Expand Down Expand Up @@ -45,8 +46,8 @@ def create_new_person():
# Note: json.dumps() is used to convert python dict to json string
unique_last_name = f'User {str(uuid4())}'
payload = dumps({
'fname': 'New',
'lname': unique_last_name
'first_name': 'New',
'last_name': unique_last_name
})

# Setting default headers to show that the client accepts json
Expand All @@ -63,4 +64,5 @@ def create_new_person():


def search_created_user_in(peoples, last_name):
return [person for person in peoples if person['lname'] == last_name]
return [person for person in peoples if person['last_name'] == last_name]