33from os .path import join
44
55import pandas as pd
6+ import numpy as np
67from delphi_utils import GeoMapper
78from delphi_usafacts .pull import pull_usafacts_data
89
9- base_url_good = "test_data/small_{metric}.csv"
10+ base_url_good = "test_data/small_{metric}_pull .csv"
1011
1112base_url_bad = {
1213 "missing_days" : "test_data/bad_{metric}_missing_days.csv" ,
@@ -21,11 +22,17 @@ class TestPullUSAFacts:
2122 def test_good_file (self ):
2223 metric = "deaths"
2324 df = pull_usafacts_data (base_url_good , metric , geo_mapper )
24-
25- assert (
26- df .columns .values
27- == ["fips" , "timestamp" , "population" , "new_counts" , "cumulative_counts" ]
28- ).all ()
25+ expected_df = pd .DataFrame ({
26+ "fips" : ["00001" , "00001" , "00001" , "36009" , "36009" , "36009" ],
27+ "timestamp" : [pd .Timestamp ("2020-02-29" ), pd .Timestamp ("2020-03-01" ),
28+ pd .Timestamp ("2020-03-02" ), pd .Timestamp ("2020-02-29" ),
29+ pd .Timestamp ("2020-03-01" ), pd .Timestamp ("2020-03-02" )],
30+ "population" : [np .nan , np .nan , np .nan , 76117. , 76117. , 76117. ],
31+ "new_counts" : [0. , 0. , 1. , 2. , 2. , 2. ],
32+ "cumulative_counts" : [0 , 0 , 1 , 2 , 4 , 6 ]},
33+ index = [1 , 2 , 3 , 5 , 6 , 7 ])
34+ # sort since rows order doesn't matter
35+ pd .testing .assert_frame_equal (df .sort_index (), expected_df .sort_index ())
2936
3037 def test_missing_days (self ):
3138
0 commit comments