-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sample.py
More file actions
69 lines (62 loc) · 1.17 KB
/
test_sample.py
File metadata and controls
69 lines (62 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import requests
url_ddg = "https://api.duckduckgo.com"
president_match = official_list = [
"lincoln",
"jackson",
"johnson",
"obama",
"harrison",
"buren",
"clinton",
"coolidge",
"arthur",
"trump",
"eisenhower",
"adams",
"roosevelt",
"pierce",
"bush",
"washington",
"bush",
"ford",
"cleveland",
"truman",
"hoover",
"garfield",
"buchanan",
"polk",
"madison",
"monroe",
"carter",
"biden",
"adams",
"kennedy",
"adams",
"tyler",
"johnson",
"buren",
"fillmore",
"nixon",
"reagan",
"hayes",
"roosevelt",
"jefferson",
"grant",
"harding",
"harrison",
"taft",
"mckinley",
"wilson",
"taylor",
]
def test_ddg0():
resp = requests.get(url_ddg + "/?q=presidents of the united states&format=json")
rsp_data = resp.json()
presidents_returned = []
for pres in rsp_data["RelatedTopics"]:
presidents_returned.append(
pres["Text"].split("-")[0].replace(".", "").lower().strip().split()[-1]
)
for pres in president_match:
assert pres in presidents_returned
test_ddg0()