def init(): # TODO- delete after release phase return [ create_expense("1", 100, "food"), create_expense("3", 145, "water"), create_expense("5", 400, "clothes"), create_expense("5", 300, "soap"), create_expense("7", 200, "food"), create_expense("7", 200, "bed"), create_expense("7", 375, "books"), create_expense("18", 40, "keyboard"), create_expense("19", 100, "shoes"), create_expense("24", 15, "food"), ]
def test_undo(): l = init() u = [] ui_insert(l, u, "2", "300", "food") ui_undo(l, u) assert create_expense("2", "300", "food") not in l
def test_add_exepnse(): l = init() lenght = len(l) obj = create_expense("30", 200, "drinks") add_expense(l, obj) assert (lenght + 1) == len(l) assert obj in l obj = create_expense("1", 300, "batteries") lenght = len(l) add_expense(l, obj) assert lenght + 1 == len(l) assert (obj in l) assert int(l[l.index(obj) + 1][0]) \ > int(l[l.index(obj)][0]) # Obj should be affter last expense in day 1
def ui_insert(month, undo_list, day, amount, category): ''' Adds to day the amount of money and in category tag Input: month - a dictionary that consists in a dictionary of "days" and a dictionary of "categories" day - day when amount was spent amount - sum that was spent category - type of amount spent ''' undo_list.append(copy.deepcopy(month)) add_expense(month, create_expense(day, amount, category))
def ui_add(month, undo_list, amount, category): ''' Adds to the current day the amount of money and in category tag Input: month - a dictionary that consists in a dictionary of "days" and a dictionary of "categories" day - day when amount was spent amount - sum that was spent category - type of amount spent ''' undo_list.append(copy.deepcopy(month)) add_expense(month, create_expense(str(datetime.now().day), amount, category))