@@ -84,7 +84,7 @@ def from_json(json: Dict[str, Any]) -> "CovidcastRow":
84
84
sample_size = json ["sample_size" ],
85
85
missing_value = json ["missing_value" ],
86
86
missing_stderr = json ["missing_stderr" ],
87
- missing_sample_size = json ["missing_sample_size" ]
87
+ missing_sample_size = json ["missing_sample_size" ],
88
88
)
89
89
90
90
@property
@@ -361,3 +361,26 @@ def test_meta(self):
361
361
self .assertEqual (out [0 ]["source" ], first .source )
362
362
out = self ._fetch ("/meta" , signal = f"{ first .source } :X" )
363
363
self .assertEqual (len (out ), 0 )
364
+
365
+ def test_coverage (self ):
366
+ """Request a signal the /meta endpoint."""
367
+
368
+ num_geos_per_date = [10 , 20 , 30 , 40 , 44 ]
369
+ dates = [20200401 + i for i in range (num_geos_per_date )]
370
+ rows = [CovidcastRow (time_value = dates [i ], value = i , geo_value = str (geo_value )) for i , num_geo in enumerate (num_geos_per_date ) for geo_value in range (num_geo )]
371
+ self ._insert_rows (rows )
372
+
373
+ with self .subTest ("default" ):
374
+ out = self ._fetch ("/coverage" )
375
+ self .assertEqual (len (out ), len (num_geos_per_date ))
376
+ self .assertEqual ([o ["time_value" ] for o in out ], dates )
377
+ self .assertEqual ([o ["count" ] for o in out ], num_geos_per_date )
378
+
379
+ with self .subTest ("specify window" ):
380
+ out = self ._fetch ("/coverage" , window = "20200401-20200402" )
381
+ self .assertEqual (len (out ), 2 )
382
+ self .assertEqual ([o ["time_value" ] for o in out ], dates [:2 ])
383
+ self .assertEqual ([o ["count" ] for o in out ], num_geos_per_date [:2 ])
384
+ with self .subTest ("invalid geo_type" ):
385
+ out = self ._fetch ("/coverage" , geo_type = "state" )
386
+ self .assertEqual (len (out ), 0 )
0 commit comments