Skip to content

Commit 7cf0116

Browse files
committed
add basic integration tests
1 parent f96d926 commit 7cf0116

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

integrations/server/test_rvdss.py

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# first party
2+
from delphi.epidata.common.integration_test_base_class import DelphiTestBase
3+
4+
5+
class rvdssTest(DelphiTestBase):
6+
"""Basic integration tests for rvdss endpoint."""
7+
8+
def localSetUp(self):
9+
self.truncate_tables_list = ["rvdss_repiratory_detections",
10+
"rvdss_pct_positive",
11+
"rvdss_detections_counts"]
12+
13+
def test_rvdss_repiratory_detections(self):
14+
"""Basic integration test for rvdss_repiratory_detections endpoint"""
15+
self.cur.execute(
16+
"INSERT INTO `rvdss_repiratory_detections`(`epiweek`, `time_value`, `issue`, `geo_type`, `geo_value`, `sarscov2_tests`, `sarscov2_positive_tests`, `flu_tests`, `flu_positive_tests`, `fluah1n1pdm09_positive_tests`, `fluah3_positive_tests`, `fluauns_positive_tests`, `flua_positive_tests`, `flub_positive_tests`, `rsv_tests`, `rsv_positive_tests`, `hpiv_tests`, `hpiv1_positive_tests`, `hpiv2_positive_tests`, `hpiv3_positive_tests`, `hpiv4_positive_tests`, `hpivother_positive_tests`, `adv_tests`, `adv_positive_tests`, `hmpv_tests`, `hmpv_positive_tests`, `evrv_tests`, `evrv_positive_tests`, `hcov_tests`, `hcov_positive_tests`, `week`, `weekorder`, `year`) VALUES(%(epiweek)s, %(time_value)s, %(issue)s, %(geo_type)s, %(geo_value)s, %(sarscov2_tests)s, %(sarscov2_positive_tests)s, %(flu_tests)s, %(flu_positive_tests)s, %(fluah1n1pdm09_positive_tests)s, %(fluah3_positive_tests)s, %(fluauns_positive_tests)s, %(flua_positive_tests)s, %(flub_positive_tests)s, %(rsv_tests)s, %(rsv_positive_tests)s, %(hpiv_tests)s, %(hpiv1_positive_tests)s, %(hpiv2_positive_tests)s, %(hpiv3_positive_tests)s, %(hpiv4_positive_tests)s, %(hpivother_positive_tests)s, %(adv_tests)s, %(adv_positive_tests)s, %(hmpv_tests)s, %(hmpv_positive_tests)s, %(evrv_tests)s, %(evrv_positive_tests)s, %(hcov_tests)s, %(hcov_positive_tests)s, %(week)s, %(weekorder)s, %(year)s)",
17+
("201212", "2012-04-12", "2012-04-17", "region","on", "10", "1", "9", "1", "0", "0", "2", "3", "1", "8", "2", "7", "1", "1", "1", "1","1", "6", "5", "100", "13", "92", "9", "167", "52", "12", "34", "2012"),
18+
)
19+
self.cnx.commit()
20+
response = self.epidata_client.rvdss_repiratory_detections(epiweeks=201212, geo_value="on")
21+
self.assertEqual(
22+
response,
23+
{
24+
"epidata": [
25+
{'epiweek':201212,
26+
'time_value':"2012-04-12",
27+
'issue':"2012-04-17",
28+
'geo_type':"region",
29+
'geo_value':"on",
30+
'sarscov2_tests':10,
31+
'sarscov2_positive_tests':1,
32+
'flu_tests':9,
33+
'flu_positive_tests':1,
34+
'fluah1n1pdm09_positive_tests':0,
35+
'fluah3_positive_tests':0,
36+
'fluauns_positive_tests':2,
37+
'flua_positive_tests':3,
38+
'flub_positive_tests':1,
39+
'rsv_tests':8,
40+
'rsv_positive_tests':2,
41+
'hpiv_tests':8,
42+
'hpiv1_positive_tests':1,
43+
'hpiv2_positive_tests':1,
44+
'hpiv3_positive_tests':1,
45+
'hpiv4_positive_tests':1,
46+
'hpivother_positive_tests':1,
47+
'adv_tests':6,
48+
'adv_positive_tests':5,
49+
'hmpv_tests':100,
50+
'hmpv_positive_tests':13,
51+
'evrv_tests':92,
52+
'evrv_positive_tests':9,
53+
'hcov_tests':167,
54+
'hcov_positive_tests':52,
55+
'week':12,
56+
'weekorder':34,
57+
'year':2012
58+
}
59+
],
60+
"result": 1,
61+
"message": "success",
62+
},
63+
)
64+
65+
def test_rvdss_pct_positive(self):
66+
"""Basic integration test for rvdss_pct_positive endpoint"""
67+
self.cur.execute(
68+
"INSERT INTO rvdss_pct_positive (`epiweek`, `time_value`, `issue`, `geo_type`, `geo_value`, `evrv_pct_positive`, `evrv_tests`, `evrv_positive_tests`, `hpiv_pct_positive`, `hpiv_tests`, `hpiv_positive_tests`, `adv_pct_positive`, `adv_tests`, `adv_positive_tests`,`hcov_pct_positive`, `hcov_tests`, `hcov_positive_tests`, `flua_pct_positive`, `flub_pct_positive`, `flu_tests`, `flua_positive_tests`, `flua_tests`, `flub_tests`, `flub_positive_tests`, `flu_positive_tests`, `flu_pct_positive`, `hmpv_pct_positive`, `hmpv_tests`, `hmpv_positive_tests`, `rsv_pct_positive`, `rsv_tests`, `rsv_positive_tests`, `sarscov2_pct_positive`, `sarscov2_tests`, `sarscov2_positive_tests`, `region`, `week`, `weekorder`, `year`) VALUES (%(epiweek)s, %(time_value)s, %(issue)s, %(geo_type)s, %(geo_value)s, %(evrv_pct_positive)s, %(evrv_tests)s, %(evrv_positive_tests)s, %(hpiv_pct_positive)s, %(hpiv_tests)s, %(hpiv_positive_tests)s, %(adv_pct_positive)s, %(adv_tests)s, %(hcov_pct_positive)s, %(hcov_tests)s, %(hcov_positive_tests)s, %(flua_pct_positive)s, %(flub_pct_positive)s, %(flu_tests)s, %(flua_positive_tests)s, %(flua_tests)s, %(flub_tests)s, %(flub_positive_tests)s, %(flu_positive_tests)s, %(flu_pct_positive)s, %(hmpv_pct_positive)s, %(hmpv_tests)s, %(hmpv_positive_tests)s, %(rsv_pct_positive)s, %(rsv_tests)s, %(rsv_positive_tests)s, %(sarscov2_pct_positive)s, %(sarscov2_tests)s, %(sarscov2_positive_tests)s, %(region)s, %(week)s, %(weekorder)s, %(year)s)",
69+
("201212", "2012-04-12", "2012-04-17", "region","on","0.1","10","1","0.1","10","1","0.1","10","1","0.1","10","1","0.05","0.05","100", "10", "100","100", "10", "20", "0.1","0.1","10","1","0.1","10","1","0.1","10","1","on","12","34","2012")
70+
)
71+
self.cnx.commit()
72+
response = self.epidata_client.rvdss_pct_positive(epiweeks=201212, geo_value="on")
73+
self.assertEqual(
74+
response,
75+
{
76+
"epidata": [
77+
{'epiweek':201212,
78+
'time_value':"2012-04-12",
79+
'issue':"2012-04-17",
80+
'geo_type':"region",
81+
'geo_value':"on",
82+
'evrv_pct_positive':0.1,
83+
'evrv_tests':10,
84+
'evrv_positive_tests':1,
85+
'hpiv_pct_positive':0.1,
86+
'hpiv_tests':10,
87+
'hpiv_positive_tests':1,
88+
'adv_pct_positive':0.1,
89+
'adv_tests':10,
90+
'adv_positive_tests':1,
91+
'hcov_pct_positive':0.1,
92+
'hcov_tests':10,
93+
'hcov_positive_tests':1,
94+
'flua_pct_positive':0.05,
95+
'flub_pct_positive':0.05,
96+
'flu_tests':100,
97+
'flua_positive_tests':10,
98+
'flua_tests':100,
99+
'flub_tests':100,
100+
'flub_positive_tests':10,
101+
'flu_positive_tests':20,
102+
'flu_pct_positive':0.1,
103+
'hmpv_pct_positive':0.1,
104+
'hmpv_tests':10,
105+
'hmpv_positive_tests':1,
106+
'rsv_pct_positive':0.1,
107+
'rsv_tests':10,
108+
'rsv_positive_tests':1,
109+
'sarscov2_pct_positive':0.1,
110+
'sarscov2_tests':10,
111+
'sarscov2_positive_tests':1,
112+
'region':"on",
113+
'week':12,
114+
'weekorder':34,
115+
'year':2012
116+
}
117+
],
118+
"result": 1,
119+
"message": "success",
120+
},
121+
)
122+
123+
def test_rvdss_detections_counts(self):
124+
"""Basic integration test for rvdss_detections_counts endpoint"""
125+
self.cur.execute(
126+
"INSERT INTO rvdss_detections_counts (`epiweek`, `time_value`, `issue`, `geo_type`, `geo_value`, `hpiv_positive_tests`, `adv_positive_tests`, `hmpv_positive_tests`, `evrv_positive_tests`, `hcov_positive_tests`, `rsv_positive_tests`, `flu_positive_tests`) VALUES (%(epiweek)s, %(time_value)s, %(issue)s, %(geo_type)s, %(geo_value)s, %(hpiv_positive_tests)s, %(adv_positive_tests)s, %(hmpv_positive_tests)s, %(evrv_positive_tests)s, %(hcov_positive_tests)s, %(rsv_positive_tests)s, %(flu_positive_tests)s)",
127+
("201212", "2012-04-12", "2012-04-17", "nation","ca", "10", "9", "8", "7", "6", "5", "4"),
128+
)
129+
self.cnx.commit()
130+
response = self.epidata_client.rvdss_detections_counts(epiweeks=201212, geo_value="ca")
131+
self.assertEqual(
132+
response,
133+
{
134+
"epidata": [
135+
{'epiweek':201212,
136+
'time_value':"2012-04-12",
137+
'issue':"2012-04-17",
138+
'geo_type':"nation",
139+
'geo_value':"ca",
140+
'hpiv_positive_tests':10,
141+
'adv_positive_tests':9,
142+
'hmpv_positive_tests':8,
143+
'evrv_positive_tests':7,
144+
'hcov_positive_tests':6,
145+
'rsv_positive_tests':5,
146+
'flu_positive_tests':4
147+
}
148+
],
149+
"result": 1,
150+
"message": "success",
151+
},
152+
)

src/acquisition/rvdss/database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"hpiv_positive_tests",
8383
"adv_pct_positive",
8484
"adv_tests",
85+
"adv_positive_tests",
8586
"hcov_pct_positive",
8687
"hcov_tests",
8788
"hcov_positive_tests",

src/ddl/rvdss.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ CREATE TABLE `rvdss_pct_positive` (
5959
`hpiv_positive_tests` int(10) NOT NULL,
6060
`adv_pct_positive` int(10) NOT NULL,
6161
`adv_tests` int(10) NOT NULL,
62+
`adv_positive_tests` int(10) NOT NULL,
6263
`hcov_pct_positive` int(10) NOT NULL,
6364
`hcov_tests` int(10) NOT NULL,
6465
`hcov_positive_tests` int(10) NOT NULL,

0 commit comments

Comments
 (0)