Skip to content

Commit

Permalink
Merge pull request #170 from krivard/feature/cvc-multi-signal-queries
Browse files Browse the repository at this point in the history
Add support for querying multiple signals
  • Loading branch information
krivard committed Sep 4, 2020
2 parents 6ff3b4a + a57b61a commit 530612d
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 74 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Integration tests for covidcast's metadata caching."""

# standard library
import json
import unittest

# third party
Expand Down Expand Up @@ -100,15 +101,15 @@ def test_caching(self):
'stdev_value': 0,
'max_issue': 20200423,
'min_lag': 0,
'max_lag': 1
'max_lag': 1,
}
])
epidata1={'result':1,'message':'success','epidata':epidata1}
epidata1={'result':1, 'message':'success', 'epidata':epidata1}

# make sure the API covidcast_meta is still blank, since it only serves
# the cached version and we haven't cached anything yet
epidata2 = Epidata.covidcast_meta()
self.assertEqual(epidata2['result'], -2)
self.assertEqual(epidata2['result'], -2, json.dumps(epidata2))

# update the cache
args = None
Expand Down
7 changes: 7 additions & 0 deletions integrations/acquisition/covidcast/test_csv_uploading.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def apply_lag(expected_epidata):
'stderr': 0.1,
'sample_size': 10,
'direction': None,
'signal': 'test',
},
{
'time_value': 20200419,
Expand All @@ -134,6 +135,7 @@ def apply_lag(expected_epidata):
'stderr': 0.3,
'sample_size': 30,
'direction': None,
'signal': 'test',
},
{
'time_value': 20200419,
Expand All @@ -142,6 +144,7 @@ def apply_lag(expected_epidata):
'stderr': 0.2,
'sample_size': 20,
'direction': None,
'signal': 'test',
},
]),
'message': 'success',
Expand All @@ -164,6 +167,7 @@ def apply_lag(expected_epidata):
'stderr': 0.01,
'sample_size': 100,
'direction': None,
'signal': 'wip_prototype',
},
{
'time_value': 20200419,
Expand All @@ -172,6 +176,7 @@ def apply_lag(expected_epidata):
'stderr': 0.02,
'sample_size': 200,
'direction': None,
'signal': 'wip_prototype',
},
{
'time_value': 20200419,
Expand All @@ -180,6 +185,7 @@ def apply_lag(expected_epidata):
'stderr': 0.03,
'sample_size': 300,
'direction': None,
'signal': 'wip_prototype',
},
]),
'message': 'success',
Expand All @@ -202,6 +208,7 @@ def apply_lag(expected_epidata):
'stderr': 5.4,
'sample_size': 624,
'direction': None,
'signal': 'wip_really_long_name_that_will_be_accepted',
},
])
})
Expand Down
36 changes: 24 additions & 12 deletions integrations/acquisition/covidcast/test_direction_updating.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20201028,
'lag': 0
'lag': 0,
'signal': 'sig1'
},
{
'time_value': 20201029,
Expand All @@ -117,7 +118,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20201029,
'lag': 0
'lag': 0,
'signal': 'sig1'
},
{
'time_value': 20201030,
Expand All @@ -127,7 +129,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20201030,
'lag': 0
'lag': 0,
'signal': 'sig1'
},
],
'message': 'success',
Expand All @@ -149,7 +152,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20200228,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200229,
Expand All @@ -159,7 +163,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20200229,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200301,
Expand All @@ -169,7 +174,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': 1,
'issue': 20200301,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200511,
Expand All @@ -179,7 +185,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20200511,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200512,
Expand All @@ -189,7 +196,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20200512,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200517,
Expand All @@ -199,7 +207,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': 0,
'issue': 20200517,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200615,
Expand All @@ -209,7 +218,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20200615,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200616,
Expand All @@ -219,7 +229,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': None,
'issue': 20200616,
'lag': 0
'lag': 0,
'signal': 'sig',
},
{
'time_value': 20200617,
Expand All @@ -229,7 +240,8 @@ def test_uploading(self):
'sample_size': 0,
'direction': 1,
'issue': 20200617,
'lag': 0
'lag': 0,
'signal': 'sig',
},
],
'message': 'success',
Expand Down
85 changes: 78 additions & 7 deletions integrations/client/test_delphi_epidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,85 @@ def tearDown(self):

def test_covidcast(self):
"""Test that the covidcast endpoint returns expected data."""

self.maxDiff=None

# insert dummy data
self.cur.execute('''
insert into covidcast values
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 0, False),
(0, 'src', 'sig2', 'day', 'county', 20200414, '01234',
123, 1.5, 2.5, 3.5, 456, 4, 20200414, 0, 0, False),
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
456, 5.5, 1.2, 10.5, 789, 0, 20200415, 1, 0, False),
(0, 'src', 'sig', 'day', 'county', 20200414, '01234',
345, 6.5, 2.2, 11.5, 678, 0, 20200416, 2, 1, False)
''')
self.cnx.commit()

# fetch data
response = Epidata.covidcast(
'src', ['sig','sig2'], 'day', 'county', 20200414, '01234')

# check result
self.assertEqual(response, {
'result': 1,
'epidata': [{
'time_value': 20200414,
'geo_value': '01234',
'value': 6.5,
'stderr': 2.2,
'sample_size': 11.5,
'direction': 0,
'issue': 20200416,
'lag': 2,
'signal': 'sig',
},{
'time_value': 20200414,
'geo_value': '01234',
'value': 1.5,
'stderr': 2.5,
'sample_size': 3.5,
'direction': 4,
'issue': 20200414,
'lag': 0,
'signal': 'sig2',
}],
'message': 'success',
})

# fetch data
response = Epidata.covidcast(
'src', ['sig','sig2'], 'day', 'county', 20200414, '01234', format='tree')

# check result
self.assertEqual(response, {
'result': 1,
'epidata': [{
'sig': [{
'time_value': 20200414,
'geo_value': '01234',
'value': 6.5,
'stderr': 2.2,
'sample_size': 11.5,
'direction': 0,
'issue': 20200416,
'lag': 2,
}],
'sig2': [{
'time_value': 20200414,
'geo_value': '01234',
'value': 1.5,
'stderr': 2.5,
'sample_size': 3.5,
'direction': 4,
'issue': 20200414,
'lag': 0,
}],
}],
'message': 'success',
})

# fetch data, without specifying issue or lag
response_1 = Epidata.covidcast(
'src', 'sig', 'day', 'county', 20200414, '01234')
Expand All @@ -73,7 +139,8 @@ def test_covidcast(self):
'sample_size': 11.5,
'direction': 0,
'issue': 20200416,
'lag': 2
'lag': 2,
'signal': 'sig',
}],
'message': 'success',
})
Expand All @@ -94,7 +161,8 @@ def test_covidcast(self):
'sample_size': 10.5,
'direction': 0,
'issue': 20200415,
'lag': 1
'lag': 1,
'signal': 'sig',
}],
'message': 'success',
})
Expand All @@ -115,7 +183,8 @@ def test_covidcast(self):
'sample_size': 3.5,
'direction': 4,
'issue': 20200414,
'lag': 0
'lag': 0,
'signal': 'sig',
}, {
'time_value': 20200414,
'geo_value': '01234',
Expand All @@ -124,7 +193,8 @@ def test_covidcast(self):
'sample_size': 10.5,
'direction': 0,
'issue': 20200415,
'lag': 1
'lag': 1,
'signal': 'sig',
}],
'message': 'success',
})
Expand All @@ -145,7 +215,8 @@ def test_covidcast(self):
'sample_size': 11.5,
'direction': 0,
'issue': 20200416,
'lag': 2
'lag': 2,
'signal': 'sig',
}],
'message': 'success',
})
Expand Down Expand Up @@ -189,7 +260,7 @@ def test_covidcast_meta(self):
'last_update': 345,
'max_issue': 20200416,
'min_lag': 1,
'max_lag': 2
'max_lag': 2,
}],
'message': 'success',
})
Loading

0 comments on commit 530612d

Please sign in to comment.