def test_dl_count_sum_equal_or_less_than_period(get_dataframe): """ Sum of LocationVisits per subscriber should not be more than total number of days between 'start_date' and 'stop_date' """ # test 1 days = 7 start_date = "2016-01-01" stop_date = "2016-01-07" lv = LocationVisits( DayTrajectories(*[ daily_location(d, level="admin3", method="last") for d in list_of_dates(start_date, stop_date) ])) df = get_dataframe(lv) assert df[df["subscriber"] == df.iloc[0, 0]]["dl_count"].sum() <= days # test 2 days = 3 start_date = "2016-01-01" stop_date = "2016-01-03" lv = LocationVisits( DayTrajectories(*[ daily_location(d, level="admin3", method="last") for d in list_of_dates(start_date, stop_date) ])) df = get_dataframe(lv) assert df[df["subscriber"] == df.iloc[0, 0]]["dl_count"].sum() <= days
def test_column_names_location_visits(exemplar_spatial_unit_param): """Test that column_names property matches head(0) for LocationVisits""" lv = LocationVisits( DayTrajectories( daily_location("2016-01-01", spatial_unit=exemplar_spatial_unit_param))) assert lv.head(0).columns.tolist() == lv.column_names
def test_day_trajectories(get_dataframe): """ DailyLocations calculations within DayTrajectories.get_dataframe() are correct. """ traj = DayTrajectories( daily_location("2016-01-01", level="admin3", method="last")) df = get_dataframe(traj).drop("date", axis=1) dldf = daily_location("2016-01-01", level="admin3", method="last").get_dataframe() assert [df["subscriber"][0], df["pcod"][0]] == [ dldf["subscriber"][0], dldf["pcod"][0], ]
def test_column_names_day_trajectories(exemplar_level_param): """ Test that column_names property matches head(0) for DayTrajectories""" lv = DayTrajectories(daily_location("2016-01-01", **exemplar_level_param)) assert lv.head(0).columns.tolist() == lv.column_names