Skip to content

Commit 785a6c8

Browse files
author
Gaurav Singh
committed
Added a test for read all API of people application and which makes use of assertpy's fluent assertions
1 parent c39067a commit 785a6c8

File tree

7 files changed

+133
-1
lines changed

7 files changed

+133
-1
lines changed

Pipfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ verify_ssl = true
77

88
[packages]
99
requests = "*"
10+
pytest = "*"
11+
assertpy = "*"
12+
jsonpath-ng = "*"
1013

1114
[requires]
1215
python_version = "3.8"

Pipfile.lock

Lines changed: 108 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.py

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

tests/__init__.py

Whitespace-only changes.

tests/people_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import requests
2+
from assertpy.assertpy import assert_that
3+
4+
from config import BASE_URI
5+
from utils.print_helpers import pretty_print
6+
7+
8+
def test_read_all_has_kent():
9+
response = requests.get(BASE_URI)
10+
response_text = response.json()
11+
pretty_print(response_text)
12+
13+
assert_that(response.status_code).is_equal_to(200)
14+
first_names = [people['fname'] for people in response_text]
15+
assert_that(first_names).contains('Kent')

utils/__init__.py

Whitespace-only changes.

utils/print_helpers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from pprint import pprint
2+
3+
4+
def pretty_print(msg, indent=2):
5+
print()
6+
pprint(msg, indent=indent)

0 commit comments

Comments
 (0)