Skip to content

Commit 3dae260

Browse files
committed
Port public R queries
1 parent a929bf9 commit 3dae260

File tree

1 file changed

+174
-0
lines changed

1 file changed

+174
-0
lines changed

tests/test_epidata_calls.py

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
from epidatpy.request import Epidata, EpiRange
2+
3+
# Requirements to run these:
4+
# DELPHI_EPIDATA_KEY environment variable is set https://api.delphi.cmu.edu/epidata/admin/registration_form
5+
6+
def test_pub_covid_hosp_facility_lookup() -> None:
7+
apicall = Epidata.pub_covid_hosp_facility_lookup(state="fl")
8+
data = apicall.json()
9+
assert(len(data) > 0)
10+
11+
apicall = Epidata.pub_covid_hosp_facility_lookup(city="southlake")
12+
data = apicall.json()
13+
assert(len(data) > 0)
14+
15+
def test_pub_covid_hosp_facility() -> None:
16+
apicall = Epidata.pub_covid_hosp_facility(
17+
hospital_pks = "100075",
18+
collection_weeks = EpiRange(20200101, 20200501))
19+
data = apicall.json()
20+
assert(len(data) > 0)
21+
22+
apicall = Epidata.pub_covid_hosp_facility(
23+
hospital_pks = "100075",
24+
collection_weeks = EpiRange(202001, 202005))
25+
data = apicall.json()
26+
assert(len(data) > 0) # fails
27+
28+
def test_pub_covid_hosp_state_timeseries() -> None:
29+
apicall = Epidata.pub_covid_hosp_state_timeseries(
30+
states = "fl",
31+
dates = EpiRange(20200101, 20200501))
32+
data = apicall.json()
33+
assert(len(data) > 0)
34+
35+
def test_pub_covidcast_meta() -> None:
36+
apicall = Epidata.pub_covidcast_meta()
37+
data = apicall.json()
38+
assert(len(data) > 0)
39+
40+
def test_pub_covidcast() -> None:
41+
apicall = Epidata.pub_covidcast(
42+
data_source = "jhu-csse",
43+
signals = "confirmed_7dav_incidence_prop",
44+
geo_type = "state",
45+
time_type = "day",
46+
geo_values = ["ca", "fl"],
47+
time_values = EpiRange(20200601, 20200801))
48+
data = apicall.json()
49+
assert(len(data) > 0)
50+
51+
apicall = Epidata.pub_covidcast(
52+
data_source = "jhu-csse",
53+
signals = "confirmed_7dav_incidence_prop",
54+
geo_type = "state",
55+
time_type = "day",
56+
geo_values = "*",
57+
time_values = EpiRange(20200601, 20200801))
58+
data = apicall.json()
59+
assert(len(data) > 0)
60+
61+
def test_pub_delphi() -> None:
62+
apicall = Epidata.pub_delphi(
63+
system = "ec",
64+
epiweek = 201501
65+
)
66+
data = apicall.classic() # only supports classic
67+
assert(len(data) > 0)
68+
69+
def test_pub_dengue_nowcast() -> None:
70+
apicall = Epidata.pub_dengue_nowcast(
71+
locations = "pr",
72+
epiweeks = EpiRange(201401, 202301)
73+
)
74+
data = apicall.json()
75+
assert(len(data) > 0)
76+
77+
def test_pub_ecdc_ili() -> None:
78+
apicall = Epidata.pub_ecdc_ili(
79+
regions = "austria",
80+
epiweeks = EpiRange(201901, 202001)
81+
)
82+
data = apicall.json(disable_date_parsing=True)
83+
assert(len(data) > 0)
84+
85+
def test_pub_flusurv() -> None:
86+
apicall = Epidata.pub_flusurv(
87+
locations = "CA",
88+
epiweeks = EpiRange(201701, 201801)
89+
)
90+
data = apicall.json(disable_date_parsing=True)
91+
assert(len(data) > 0)
92+
93+
def test_pub_fluview_clinical() -> None:
94+
apicall = Epidata.pub_fluview_clinical(
95+
regions = "nat",
96+
epiweeks = EpiRange(201601, 201701)
97+
)
98+
data = apicall.json(disable_date_parsing=True)
99+
assert(len(data) > 0)
100+
101+
def test_pub_fluview_meta() -> None:
102+
apicall = Epidata.pub_fluview_meta()
103+
data = apicall.json(disable_date_parsing=True)
104+
assert(len(data) > 0)
105+
106+
def test_pub_fluview() -> None:
107+
apicall = Epidata.pub_fluview(
108+
regions = "nat",
109+
epiweeks = EpiRange(201201, 202005)
110+
)
111+
data = apicall.json(disable_date_parsing=True)
112+
assert(len(data) > 0)
113+
114+
def test_pub_gft() -> None:
115+
apicall = Epidata.pub_gft(
116+
locations = "hhs1",
117+
epiweeks = EpiRange(201201, 202001)
118+
)
119+
data = apicall.json()
120+
assert(len(data) > 0)
121+
122+
def test_pub_kcdc_ili() -> None:
123+
apicall = Epidata.pub_kcdc_ili(
124+
regions = "ROK",
125+
epiweeks = 200436
126+
)
127+
data = apicall.json(disable_date_parsing=True)
128+
assert(len(data) > 0)
129+
130+
def test_pub_meta() -> None:
131+
apicall = Epidata.pub_meta()
132+
data = apicall.classic() # only supports classic
133+
assert(len(data) > 0)
134+
135+
def test_pub_nidss_dengue() -> None:
136+
apicall = Epidata.pub_nidss_dengue(
137+
locations = "taipei",
138+
epiweeks = EpiRange(201201, 201301)
139+
)
140+
data = apicall.json()
141+
assert(len(data) > 0)
142+
143+
def test_pub_nidss_flu() -> None:
144+
apicall = Epidata.pub_nidss_flu(
145+
regions = "taipei",
146+
epiweeks = EpiRange(201501, 201601)
147+
)
148+
data = apicall.json(disable_date_parsing=True)
149+
assert(len(data) > 0)
150+
151+
def test_pub_nowcast() -> None:
152+
apicall = Epidata.pub_nowcast(
153+
locations = "ca",
154+
epiweeks = EpiRange(201201, 201301)
155+
)
156+
data = apicall.json()
157+
assert(len(data) > 0)
158+
159+
def test_pub_paho_dengue() -> None:
160+
apicall = Epidata.pub_paho_dengue(
161+
regions = "ca",
162+
epiweeks = EpiRange(201401, 201501)
163+
)
164+
data = apicall.json(disable_date_parsing=True)
165+
assert(len(data) > 0)
166+
167+
def test_pub_wiki() -> None:
168+
apicall = Epidata.pub_wiki(
169+
articles = "avian_influenza",
170+
time_type = "week",
171+
time_values = EpiRange(201501, 201601)
172+
)
173+
data = apicall.json()
174+
assert(len(data) > 0)

0 commit comments

Comments
 (0)