def replace(storage, cmd): #input: dict storage, string cmd #spec: replaces the value of transaction in day day with type tr_type and description description with value value day = int(cmd[1]) value = int(cmd[5]) tr_type = cmd[2] description = cmd[3] for i in range(len(get_day(storage, day))): if (get_descr(storage, day, i) == description): if (get_type(storage, day, i) == tr_type): set_value(storage, day, i, value)
def test_set_value(): storage = {23: [[100, "out", "pizza"], [1000, "in", "salary"]]} set_value(storage, 23, 0, 150) set_value(storage, 23, 1, 1050) assert get_value(storage, 23, 0) == 150, 'should get 150' assert get_value(storage, 23, 1) == 1050, 'should get 1050'