def test_census_chart(census_floor_df): chart = build_census_chart(alt=alt, census_floor_df=census_floor_df) assert isinstance(chart, (alt.Chart, alt.LayerChart)) assert chart.data.iloc[1].hospitalized == 3 assert chart.data.iloc[49].ventilated == 365 # test fx call with no params with pytest.raises(TypeError): build_census_chart()
def test_census_chart(): census_df = pd.read_csv( "tests/by_doubling_time/2020-03-28_projected_census.csv") chart = build_census_chart(alt=alt, census_df=census_df) assert isinstance(chart, (alt.Chart, alt.LayerChart)) assert chart.data.iloc[1].hospitalized == 3 assert chart.data.iloc[49].ventilated == 365 # test fx call with no params with pytest.raises(TypeError): build_census_chart()
def test_build_descriptions(): param = copy(PARAM) admits_file = 'tests/by_doubling_time/2020-03-28_projected_admits.csv' census_file = 'tests/by_doubling_time/2020-03-28_projected_census.csv' admits_df = pd.read_csv(admits_file, parse_dates=['date']) chart = build_admits_chart(alt=alt, admits_df=admits_df) description = build_descriptions(chart=chart, labels=param.labels) hosp, icu, vent = description.split( "\n\n") # break out the description into lines max_hosp = chart.data['hospitalized'].max() assert str(ceil(max_hosp)) in hosp # TODO add test for asterisk # test no asterisk param.n_days = 600 admits_df = pd.read_csv(admits_file, parse_dates=['date']) chart = build_admits_chart(alt=alt, admits_df=admits_df) description = build_descriptions(chart=chart, labels=param.labels) assert "*" not in description # census chart census_df = pd.read_csv(census_file, parse_dates=['date']) chart = build_census_chart(alt=alt, census_df=census_df) description = build_descriptions(chart=chart, labels=param.labels) assert str(ceil(chart.data['ventilated'].max())) in description assert str(chart.data['icu'].idxmax()) not in description assert datetime.strftime(chart.data.iloc[chart.data['icu'].idxmax()].date, '%b %d') in description
def test_census(census_df, param): chart = build_census_chart(alt=alt, census_df=census_df) description = build_descriptions(chart=chart, labels=param.labels) assert str(ceil(chart.data['ventilated'].max())) in description assert str(chart.data['icu'].idxmax()) not in description assert datetime.strftime(chart.data.iloc[chart.data['icu'].idxmax()].date, '%b %d') in description
def test_census(census_floor_df, param): chart = build_census_chart(alt=alt, census_floor_df=census_floor_df) description = build_descriptions(chart=chart, labels=param.labels) assert str(ceil(chart.data["ventilated"].max())) in description assert str(chart.data["icu"].idxmax()) not in description assert ( datetime.strftime(chart.data.iloc[chart.data["icu"].idxmax()].date, "%b %d") in description )