Exemple #1
0
def update_expense(ID, category, amount, date):
    EM = ExpenseManager()
    EM.from_csv(expense_csv)

    expense = Expense(ID, category, amount, date)
    EM.upd_expense(ID, expense)
    EM.override_to_csv(expense_csv)
Exemple #2
0
def update_expense(ID, category, amount, date):
    """ 
    Updates the specified expense
    :param ID: ID of expense to be updated
    :type ID: int
    
    :return: None
    :rtype: None
    """
    EM = ExpenseManager()
    EM.from_csv(expense_csv)

    expense = Expense(ID, category, amount, date)
    EM.upd_expense(ID, expense)
    EM.override_to_csv(expense_csv)
Exemple #3
0
def test_upd_expense():
    """
    Tests for the upd_expense method
    """
    manager = ExpenseManager()
    expense = Expense(1, "Health", 300, "2020-05-12")
    updated_expense = Expense(1, "School", 100.1, "2020-05-11")

    # Checks if method exists
    assert hasattr(manager, "upd_expense")

    # Adds expense
    manager.add_expense(expense)
    assert manager._expenses[1] == expense

    # Checks that update expense works correctly
    manager.upd_expense(1, updated_expense)
    assert manager._expenses[1] == updated_expense