-
Notifications
You must be signed in to change notification settings - Fork 67
Leonlu2/error on geo values #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
dd8c5c8
d024995
a6cc058
6ed27d9
e89692e
14463c8
3648a74
e884b7c
9fe6196
6dac204
7b7b5e7
0a2bdf9
ef362d8
6e29946
e3fe68b
43a232e
e3054cd
1e75209
5fed93c
79cdc26
bec5621
4578420
4a59ead
00b4ff2
58fcc7f
94e8b5f
59ce3c9
d41eeaa
b01bb82
e2d12ee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
# first party | ||
from delphi_utils import Nans | ||
from delphi.epidata.acquisition.covidcast.test_utils import CovidcastBase, CovidcastTestRow | ||
from delphi.epidata.acquisition.covidcast.test_utils import CovidcastBase, CovidcastTestRow, FIPS, MSA | ||
from delphi.epidata.client.delphi_epidata import Epidata | ||
|
||
# use the local instance of the Epidata API | ||
|
@@ -37,23 +37,22 @@ def _insert_placeholder_set_one(self): | |
|
||
def _insert_placeholder_set_two(self): | ||
rows = [ | ||
CovidcastTestRow.make_default_row(geo_type='county', geo_value=str(i)*5, value=i*1., stderr=i*10., sample_size=i*100.) | ||
CovidcastTestRow.make_default_row(geo_type='msa', geo_value=MSA[i-1], value=i*1., stderr=i*10., sample_size=i*100.) | ||
for i in [1, 2, 3] | ||
] + [ | ||
# geo value intended to overlap with counties above | ||
CovidcastTestRow.make_default_row(geo_type='msa', geo_value=str(i-3)*5, value=i*1., stderr=i*10., sample_size=i*100.) | ||
CovidcastTestRow.make_default_row(geo_type='fips', geo_value=FIPS[i-4], value=i*1., stderr=i*10., sample_size=i*100.) | ||
for i in [4, 5, 6] | ||
] | ||
self._insert_rows(rows) | ||
return rows | ||
|
||
def _insert_placeholder_set_three(self): | ||
rows = [ | ||
CovidcastTestRow.make_default_row(geo_type='county', geo_value='11111', time_value=2000_01_01+i, value=i*1., stderr=i*10., sample_size=i*100., issue=2000_01_03, lag=2-i) | ||
CovidcastTestRow.make_default_row(geo_value=MSA[0], time_value=2000_01_01+i, value=i*1., stderr=i*10., sample_size=i*100., issue=2000_01_03, lag=2-i) | ||
LeonLu2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for i in [1, 2, 3] | ||
] + [ | ||
# time value intended to overlap with 11111 above, with disjoint geo values | ||
CovidcastTestRow.make_default_row(geo_type='county', geo_value=str(i)*5, time_value=2000_01_01+i-3, value=i*1., stderr=i*10., sample_size=i*100., issue=2000_01_03, lag=5-i) | ||
# time value intended to overlap with the time values above, with disjoint geo values | ||
CovidcastTestRow.make_default_row(geo_value=str(i)*5, time_value=2000_01_01+i-3, value=i*1., stderr=i*10., sample_size=i*100., issue=2000_01_03, lag=5-i) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it your intention to make rows with invalid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why dont we see the "invalid geo" messages when we use this row set? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh sorry that I overlooked these comments, somehow it did not show on the conversation page. Yeah I think using some FIPS here would be good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
for i in [4, 5, 6] | ||
] | ||
self._insert_rows(rows) | ||
|
@@ -295,7 +294,7 @@ def test_signal_wildcard(self): | |
}) | ||
|
||
def test_geo_value(self): | ||
"""test different variants of geo types: single, *, multi.""" | ||
"""test whether geo values are valid for specific geo types""" | ||
|
||
# insert placeholder data | ||
rows = self._insert_placeholder_set_two() | ||
|
@@ -308,26 +307,28 @@ def fetch(geo_value): | |
return response | ||
|
||
# test fetch a specific region | ||
r = fetch('11111') | ||
r = fetch(MSA[0]) | ||
self.assertEqual(r['message'], 'success') | ||
self.assertEqual(r['epidata'], expected[0:1]) | ||
# test fetch a specific yet not existing region | ||
r = fetch('55555') | ||
self.assertEqual(r['message'], 'no results') | ||
r = fetch('11111') | ||
self.assertEqual(r['message'], 'Invalid geo_value(s) 11111 for the requested geo_type msa') | ||
# test fetch multiple regions | ||
r = fetch('11111,22222') | ||
r = fetch('{},{}'.format(MSA[0], MSA[1])) | ||
LeonLu2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(r['message'], 'success') | ||
self.assertEqual(r['epidata'], expected[0:2]) | ||
# test fetch multiple noncontiguous regions | ||
r = fetch('11111,33333') | ||
r = fetch('{},{}'.format(MSA[0], MSA[2])) | ||
LeonLu2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(r['message'], 'success') | ||
self.assertEqual(r['epidata'], [expected[0], expected[2]]) | ||
# test fetch multiple regions but one is not existing | ||
r = fetch('11111,55555') | ||
self.assertEqual(r['message'], 'success') | ||
self.assertEqual(r['epidata'], expected[0:1]) | ||
r = fetch('{},11111'.format(MSA[0])) | ||
LeonLu2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(r['message'], 'Invalid geo_value(s) 11111 for the requested geo_type msa') | ||
# test fetch empty region | ||
r = fetch('') | ||
self.assertEqual(r['message'], 'geo_value is empty for the requested geo_type msa!') | ||
# test a region that has no results | ||
r = fetch(MSA[3]) | ||
LeonLu2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(r['message'], 'no results') | ||
|
||
def test_location_timeline(self): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
delphi_utils==0.3.6 | ||
epiweeks==2.1.2 | ||
Flask==2.2.2 | ||
itsdangerous<2.1 | ||
|
Uh oh!
There was an error while loading. Please reload this page.