Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 657cf98

Browse files
author
Gaurav Singh
committed
Added lxml dependency and covid_test.py to demo how to work with xml responses
1 parent 2ca9964 commit 657cf98

File tree

4 files changed

+70
-16
lines changed

4 files changed

+70
-16
lines changed

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ verify_ssl = true
99
requests = "*"
1010
pytest = "*"
1111
assertpy = "*"
12+
lxml = "*"
1213

1314
[requires]
1415
python_version = "3.8"

Pipfile.lock

Lines changed: 50 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
BASE_URI = 'http://0.0.0.0:5000/api/people'
1+
BASE_URI = 'http://0.0.0.0:5000/api/people'
2+
COVID_TRACKER_HOST = 'http://127.0.0.1:5000'

tests/covid_test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import requests
2+
from assertpy import assert_that
3+
from lxml import etree
4+
5+
from config import COVID_TRACKER_HOST
6+
from utils.print_helpers import pretty_print
7+
8+
9+
def test_covid_cases_have_crossed_a_million():
10+
response = requests.get(f'{COVID_TRACKER_HOST}/api/v1/summary/latest')
11+
pretty_print(response.headers)
12+
13+
response_xml = response.text
14+
tree = etree.fromstring(bytes(response_xml, encoding='utf8'))
15+
total_cases = tree.xpath("//data/summary/total_cases")[0].text
16+
17+
assert_that(int(total_cases)).is_greater_than(1000000)

0 commit comments

Comments
 (0)