@@ -81,6 +81,18 @@ def _insert_placeholder_set_five(self):
8181 self ._insert_rows (rows )
8282 return rows
8383
84+ def _insert_placeholder_set_with_weeks (self ):
85+ rows = [
86+ CovidcastTestRow .make_default_row (
87+ time_value = 2021_05 + i , time_type = "week" ,
88+ source = "nchs-mortality" , signal = "deaths_covid_incidence_num" ,
89+ geo_type = "state" , geo_value = "il" ,
90+ value = i * i )
91+ for i in [0 , 1 , 2 ]
92+ ]
93+ self ._insert_rows (rows )
94+ return rows
95+
8496 def test_round_trip (self ):
8597 """Make a simple round-trip with some sample data."""
8698
@@ -445,3 +457,22 @@ def test_date_formats(self):
445457
446458 # assert that the right data came back
447459 self .assertEqual (len (response ['epidata' ]), 2 * 3 )
460+
461+
462+ def test_week_formats (self ):
463+ """Test different ways to specify week ranges are accepted."""
464+
465+ rows = self ._insert_placeholder_set_with_weeks ()
466+ expected = {
467+ 'result' : 1 ,
468+ 'epidata' : [r .as_api_row_dict () for r in rows ],
469+ 'message' : 'success' ,
470+ }
471+
472+ colond = self .request_based_on_row (rows [0 ], time_values = "202105:202107" )
473+ dashed = self .request_based_on_row (rows [0 ], time_values = "202105-202107" )
474+ enumed = self .request_based_on_row (rows [0 ], time_values = "202105,202106,202107" )
475+
476+ self .assertEqual (expected , colond )
477+ self .assertEqual (expected , dashed )
478+ self .assertEqual (expected , enumed )
0 commit comments