Skip to content

Commit 2136bf9

Browse files
Merge pull request #574 from zhuoran-Cheng16/dev
add minimum issue date to the metadata with some tests(merge to dev)
2 parents dc1b86c + 7d2bf5e commit 2136bf9

File tree

9 files changed

+179
-28
lines changed

9 files changed

+179
-28
lines changed

integrations/acquisition/covidcast/test_covidcast_meta_caching.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,24 @@ def test_caching(self):
6767

6868
# insert dummy data
6969
self.cur.execute(f'''
70-
insert into covidcast values
70+
INSERT INTO
71+
`covidcast` (`id`, `source`, `signal`, `time_type`,
72+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
73+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
74+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
75+
VALUES
7176
(0, 'src', 'sig', 'day', 'state', 20200422, 'pa',
7277
123, 1, 2, 3, 456, 1, 20200422, 0, 1, False, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
7378
(0, 'src', 'sig', 'day', 'state', 20200422, 'wa',
7479
789, 1, 2, 3, 456, 1, 20200423, 1, 1, False, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
7580
''')
7681
self.cur.execute(f'''
77-
insert into covidcast values
82+
INSERT INTO
83+
`covidcast` (`id`, `source`, `signal`, `time_type`,
84+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
85+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
86+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
87+
VALUES
7888
(100, 'src', 'wip_sig', 'day', 'state', 20200422, 'pa',
7989
456, 4, 5, 6, 789, -1, 20200422, 0, 1, True, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
8090
''')
@@ -102,6 +112,7 @@ def test_caching(self):
102112
'mean_value': 1,
103113
'stdev_value': 0,
104114
'max_issue': 20200423,
115+
'min_issue': 20200422,
105116
'min_lag': 0,
106117
'max_lag': 1,
107118
}

integrations/acquisition/covidcast/test_fill_is_latest_issue.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ def _test_fill_is_latest_issue(self, clbp, use_filter):
5858
# direction, issue, lag, is_latest_issue, is_wip, missing_value, missing_stderr, missing_sample_size)
5959

6060
self.cur.execute(f'''
61-
insert into covidcast values
61+
INSERT INTO
62+
`covidcast` (`id`, `source`, `signal`, `time_type`,
63+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
64+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
65+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
66+
VALUES
6267
(0, 'src', 'sig', 'day', 'state', 20200228, 'ca',
6368
123, 2, 5, 5, 5, NULL, 20200228, 0, 1, False,
6469
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),

integrations/client/test_delphi_epidata.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ def test_covidcast(self):
6767

6868
# insert dummy data
6969
self.cur.execute(f'''
70-
insert into covidcast values
70+
INSERT INTO
71+
`covidcast` (`id`, `source`, `signal`, `time_type`,
72+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
73+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
74+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
75+
VALUES
7176
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
7277
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 0, False,
7378
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -331,7 +336,12 @@ def test_geo_value(self):
331336

332337
# insert dummy data
333338
self.cur.execute(f'''
334-
insert into covidcast values
339+
INSERT INTO
340+
`covidcast` (`id`, `source`, `signal`, `time_type`,
341+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
342+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
343+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
344+
VALUES
335345
(0, 'src', 'sig', 'day', 'county', 20200414, '11111',
336346
123, 10, 11, 12, 456, 13, 20200414, 0, 1, False,
337347
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -432,7 +442,12 @@ def test_covidcast_meta(self):
432442

433443
# insert dummy data
434444
self.cur.execute(f'''
435-
insert into covidcast values
445+
INSERT INTO
446+
`covidcast` (`id`, `source`, `signal`, `time_type`,
447+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
448+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
449+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
450+
VALUES
436451
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
437452
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 0, False,
438453
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -562,7 +577,12 @@ def test_covidcast_nowcast(self):
562577
def test_async_epidata(self):
563578
# insert dummy data
564579
self.cur.execute(f'''
565-
insert into covidcast values
580+
INSERT INTO
581+
`covidcast` (`id`, `source`, `signal`, `time_type`,
582+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
583+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
584+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
585+
VALUES
566586
(0, 'src', 'sig', 'day', 'county', 20200414, '11111',
567587
123, 10, 11, 12, 456, 13, 20200414, 0, 1, False,
568588
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),

integrations/server/test_covidcast.py

Lines changed: 84 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ def test_round_trip(self):
4545

4646
# insert dummy data
4747
self.cur.execute(f'''
48-
insert into covidcast values
48+
INSERT INTO
49+
`covidcast` (`id`, `source`, `signal`, `time_type`,
50+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
51+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
52+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
53+
VALUES
4954
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
5055
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 1, False,
5156
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -92,7 +97,12 @@ def test_round_trip(self):
9297

9398
# # insert dummy data
9499
# self.cur.execute(f'''
95-
# insert into covidcast values
100+
# INSERT INTO
101+
# `covidcast` (`id`, `source`, `signal`, `time_type`,
102+
# `geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
103+
# `value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
104+
# `direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
105+
# VALUES
96106
# (0, 'src', 'sig', 'day', 'county', 20200414, '01234',
97107
# 123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 1, False,
98108
# {Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -129,7 +139,12 @@ def test_csv_format(self):
129139

130140
# insert dummy data
131141
self.cur.execute(f'''
132-
insert into covidcast values
142+
INSERT INTO
143+
`covidcast` (`id`, `source`, `signal`, `time_type`,
144+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
145+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
146+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
147+
VALUES
133148
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
134149
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 1, False,
135150
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -163,7 +178,12 @@ def test_raw_json_format(self):
163178

164179
# insert dummy data
165180
self.cur.execute(f'''
166-
insert into covidcast values
181+
INSERT INTO
182+
`covidcast` (`id`, `source`, `signal`, `time_type`,
183+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
184+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
185+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
186+
VALUES
167187
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
168188
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 1, False,
169189
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -205,7 +225,12 @@ def test_fields(self):
205225

206226
# insert dummy data
207227
self.cur.execute(f'''
208-
insert into covidcast values
228+
INSERT INTO
229+
`covidcast` (`id`, `source`, `signal`, `time_type`,
230+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
231+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
232+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
233+
VALUES
209234
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
210235
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 1, False,
211236
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -326,7 +351,12 @@ def test_location_wildcard(self):
326351

327352
# insert dummy data
328353
self.cur.execute(f'''
329-
insert into covidcast values
354+
INSERT INTO
355+
`covidcast` (`id`, `source`, `signal`, `time_type`,
356+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
357+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
358+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
359+
VALUES
330360
(0, 'src', 'sig', 'day', 'county', 20200414, '11111',
331361
123, 10, 11, 12, 456, 13, 20200414, 0, 1, False,
332362
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -414,7 +444,12 @@ def test_geo_value(self):
414444

415445
# insert dummy data
416446
self.cur.execute(f'''
417-
insert into covidcast values
447+
INSERT INTO
448+
`covidcast` (`id`, `source`, `signal`, `time_type`,
449+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
450+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
451+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
452+
VALUES
418453
(0, 'src', 'sig', 'day', 'county', 20200414, '11111',
419454
123, 10, 11, 12, 456, 13, 20200414, 0, 1, False,
420455
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -530,7 +565,12 @@ def test_location_timeline(self):
530565

531566
# insert dummy data
532567
self.cur.execute(f'''
533-
insert into covidcast values
568+
INSERT INTO
569+
`covidcast` (`id`, `source`, `signal`, `time_type`,
570+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
571+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
572+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
573+
VALUES
534574
(0, 'src', 'sig', 'day', 'county', 20200411, '01234',
535575
123, 10, 11, 12, 456, 13, 20200413, 2, 1, False,
536576
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -618,7 +658,12 @@ def test_unique_key_constraint(self):
618658

619659
# insert dummy data
620660
self.cur.execute(f'''
621-
insert into covidcast values
661+
INSERT INTO
662+
`covidcast` (`id`, `source`, `signal`, `time_type`,
663+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
664+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
665+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
666+
VALUES
622667
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
623668
0, 0, 0, 0, 0, 0, 20200414, 0, 1, False,
624669
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -628,15 +673,25 @@ def test_unique_key_constraint(self):
628673
# fail to insert different dummy data under the same key
629674
with self.assertRaises(mysql.connector.errors.IntegrityError):
630675
self.cur.execute(f'''
631-
insert into covidcast values
676+
INSERT INTO
677+
`covidcast` (`id`, `source`, `signal`, `time_type`,
678+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
679+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
680+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
681+
VALUES
632682
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
633683
1, 1, 1, 1, 1, 1, 20200414, 0, 1, False,
634684
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
635685
''')
636686

637687
# succeed to insert different dummy data under a different issue
638688
self.cur.execute(f'''
639-
insert into covidcast values
689+
INSERT INTO
690+
`covidcast` (`id`, `source`, `signal`, `time_type`,
691+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
692+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
693+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
694+
VALUES
640695
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
641696
1, 1, 1, 1, 1, 1, 20200415, 1, 1, False,
642697
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING})
@@ -647,7 +702,12 @@ def test_nullable_columns(self):
647702

648703
# insert dummy data
649704
self.cur.execute(f'''
650-
insert into covidcast values
705+
INSERT INTO
706+
`covidcast` (`id`, `source`, `signal`, `time_type`,
707+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
708+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
709+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
710+
VALUES
651711
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
652712
123, 0.123, NULL, NULL, 456, NULL, 20200414, 0, 1, False,
653713
{Nans.NOT_MISSING}, {Nans.OTHER}, {Nans.OTHER})
@@ -693,7 +753,12 @@ def test_temporal_partitioning(self):
693753

694754
# insert dummy data
695755
self.cur.execute(f'''
696-
insert into covidcast values
756+
INSERT INTO
757+
`covidcast` (`id`, `source`, `signal`, `time_type`,
758+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
759+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
760+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
761+
VALUES
697762
(0, 'src', 'sig', 'hour', 'state', 2020041714, 'vi',
698763
123, 10, 11, 12, 456, 13, 2020041714, 0, 1, False,
699764
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),
@@ -750,7 +815,12 @@ def test_date_formats(self):
750815

751816
# insert dummy data
752817
self.cur.execute(f'''
753-
insert into covidcast values
818+
INSERT INTO
819+
`covidcast` (`id`, `source`, `signal`, `time_type`,
820+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
821+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
822+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
823+
VALUES
754824
(0, 'src', 'sig', 'day', 'county', 20200411, '01234',
755825
123, 10, 11, 12, 456, 13, 20200413, 0, 1, False,
756826
{Nans.NOT_MISSING}, {Nans.NOT_MISSING}, {Nans.NOT_MISSING}),

integrations/server/test_covidcast_endpoints.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,12 @@ def _insert_rows(self, rows: Iterable[CovidcastRow]):
127127
sql = ",\n".join((str(r) for r in rows))
128128
self.cur.execute(
129129
f"""
130-
insert into covidcast values
130+
INSERT INTO
131+
`covidcast` (`id`, `source`, `signal`, `time_type`,
132+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
133+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
134+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
135+
VALUES
131136
{sql}
132137
"""
133138
)

integrations/server/test_covidcast_meta.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ def test_round_trip(self):
4747

4848
# insert dummy data and accumulate expected results (in sort order)
4949
template = '''
50-
insert into covidcast values
50+
INSERT INTO
51+
`covidcast` (`id`, `source`, `signal`, `time_type`,
52+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
53+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
54+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
55+
VALUES
5156
(0, "%s", "%s", "%s", "%s", %d, "%s", 123,
5257
%d, 0, 0, 456, 0, %d, 0, 1, %d, %d, %d, %d)
5358
'''
@@ -100,7 +105,12 @@ def test_filter(self):
100105

101106
# insert dummy data and accumulate expected results (in sort order)
102107
template = '''
103-
insert into covidcast values
108+
INSERT INTO
109+
`covidcast` (`id`, `source`, `signal`, `time_type`,
110+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
111+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
112+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
113+
VALUES
104114
(0, "%s", "%s", "%s", "%s", %d, "%s", 123,
105115
%d, 0, 0, 456, 0, %d, 0, 1, %d, %d, %d, %d)
106116
'''
@@ -218,7 +228,12 @@ def test_suppress_work_in_progress(self):
218228

219229
# insert dummy data and accumulate expected results (in sort order)
220230
template = '''
221-
insert into covidcast values
231+
INSERT INTO
232+
`covidcast` (`id`, `source`, `signal`, `time_type`,
233+
`geo_type`, `time_value`, `geo_value`, `value_updated_timestamp`,
234+
`value`, `stderr`, `sample_size`, `direction_updated_timestamp`,
235+
`direction`, `issue`, `lag`, `is_latest_issue`, `is_wip`)
236+
VALUES
222237
(0, "%s", "%s", "%s", "%s", %d, "%s", 123,
223238
%d, 0, 0, 456, 0, %d, 0, 1, %d, %d, %d, %d)
224239
'''

integrations/server/test_fluview.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ def test_round_trip(self):
4848

4949
# insert dummy data
5050
self.cur.execute('''
51-
insert into fluview values
51+
INSERT INTO
52+
`fluview` (`id`, `release_date`, `issue`, `epiweek`, `region`,
53+
`lag`, `num_ili`, `num_patients`, `num_providers`, `wili`, `ili`,
54+
`num_age_0`, `num_age_1`, `num_age_2`, `num_age_3`, `num_age_4`, `num_age_5`)
55+
VALUES
5256
(0, "2020-04-07", 202021, 202020, "nat", 1, 2, 3, 4, 3.14159, 1.41421,
5357
10, 11, 12, 13, 14, 15)
5458
''')

integrations/server/test_fluview_meta.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ def test_round_trip(self):
4848

4949
# insert dummy data
5050
self.cur.execute('''
51-
insert into fluview values
51+
INSERT INTO
52+
`fluview` (`id`, `release_date`, `issue`, `epiweek`, `region`,
53+
`lag`, `num_ili`, `num_patients`, `num_providers`, `wili`, `ili`,
54+
`num_age_0`, `num_age_1`, `num_age_2`, `num_age_3`, `num_age_4`, `num_age_5`)
55+
VALUES
5256
(0, "2020-04-07", 202021, 202020, "nat", 1, 2, 3, 4, 3.14159, 1.41421,
5357
10, 11, 12, 13, 14, 15),
5458
(0, "2020-04-28", 202022, 202022, "hhs1", 5, 6, 7, 8, 1.11111, 2.22222,

0 commit comments

Comments
 (0)