def test_filter__empty(): #If filtering twice with an inverted filter the result should be empty acc_data = AccountData(data_path1, cat_path) acc_data.filter_data("amount", ">=", 300) acc_data.filter_data("amount", "<", 300) assert (len(acc_data.get_data()) == 0) #Tags should also be empty assert (len(acc_data.get_tags()) == 0) #It should be possible to still call get_timeseries() assert (type(acc_data.get_timeseries()) == TimeSeries)
def test_get_timeseries__correct_sum(): #The total expenses should not change acc_data1 = AccountData(data_path2) sum1 = 0 for data in acc_data1.get_data(): sum1 += data[1] sum2 = 0 for data in acc_data1.get_timeseries().data: sum2 += data[1] assert (sum1 == sum2)
def test_get_timeseries(): acc_data2 = AccountData(data_path2) ts = acc_data2.get_timeseries().data #The lenght of the timeseries should be the number of number of days between first and last day of data 1 assert (len(ts) == 26) #All dates should be present between the first and the last, an only occur once last_date = ts[0][0] for data in ts[1:]: assert (last_date + datetime.timedelta(1) == data[0]) last_date = data[0]