コード例 #1
0
def test_get_trans():
    storage = {23: [[100, "out", "pizza"], [1000, "in", "salary"]]}

    assert get_trans(storage, 23,
                     0) == [100, "out",
                            "pizza"], 'should get [100, "out", "pizza"]'
    assert get_trans(storage, 23,
                     1) == [1000, "in",
                            "salary"], 'should get [1000, "in", "salary"]'
コード例 #2
0
def remove_type(storage, tr_type):
    #input: dict storage, string tr_type
    #spec: removes all the transactions of type tr_type
    #return: -
    for i in range(31):
        length = len(get_day(storage, i))
        j = 0
        while (j < length):
            if (get_type(storage, i, j) == tr_type):
                get_day(storage, i).remove(get_trans(storage, i, j))
                length -= 1
            else:
                j += 1
コード例 #3
0
def filter(storage, tr_type, value):
    #function that keeps only tr_type tranzactions with values smaller than value
    #input: dict storage, str tr_type, int value
    #output: -
    filter_type(storage, tr_type)
    for i in range(31):
        length = len(get_day(storage, i))
        j = 0
        while (j < length):
            if (get_value(storage, i, j) >= value):
                get_day(storage, i).remove(get_trans(storage, i, j))
                length -= 1
            else:
                j += 1
コード例 #4
0
def test_insert():
    day = 23
    storage = {day: [[100, "out", "pizza"], [1000, "in", "salary"]]}
    insert(storage, 23, 150, "out", "jewlery")
    assert get_trans(storage, day, 2) == [150, "out", "jewlery"]
コード例 #5
0
def test_add():
    day = datetime.date.today().day
    storage = {day: [[100, "out", "pizza"], [1000, "in", "salary"]]}
    add(storage, 150, "out", "jewlery")
    assert get_trans(storage, day, 2) == [150, "out", "jewlery"]