def test_repo_expenses(self): repo = RepoExpense() assert (repo.size() == 0) expense = Expense(23, 56, "tranport") repo.add(expense) assert (repo.size() == 1) expense = Expense(None, 60, None) repo.remove(expense) assert (repo.size() == 0)
def test_validator_expense(self): validExpense = ValidateExpense() expense = Expense(23, 56, "transport") validExpense.validate(expense) expense2 = Expense(-30, 2, "food") try: validExpense.validate(expense2) assert (False) except Exception as ex: assert (str(ex) == "Invalid day!\n") expense3 = Expense(20, -6, "") try: validExpense.validate(expense3) assert (False) except Exception as ex: assert (str(ex) == "Invalid amount of money!\nInvalid type of expense!\n")
def examples(self, x): expense = Expense(1, 40, "transport") x.append(expense) expense = Expense(29, 8, "internet") x.append(expense) expense = Expense(19, 10, "internet") x.append(expense) expense = Expense(6, 100, "others") x.append(expense) expense = Expense(22, 55, "transport") x.append(expense) expense = Expense(9, 60, "food") x.append(expense) expense = Expense(9, 40, "housekeeping") x.append(expense) expense = Expense(3, 21, "transport") x.append(expense) expense = Expense(5, 77, "internet") x.append(expense) expense = Expense(30, 5, "others") x.append(expense) self.__repo.ten_examples(x)
def add_expense(self, day, amount, exp_type): new_expense = Expense(day, amount, exp_type) self._expenses.append(copy.deepcopy(new_expense))
def filter_list(self, x): expense = Expense(None, x, None) self.__repo.remove(expense)
def add_expenses(self, day, money, extype): expense = Expense(day, money, extype) self.__valid.validate(expense) self.__repo.add(expense)
def test_create_expense(self): expense = Expense(23, 56, "transport") assert (expense.get_day() == 23) assert (expense.get_money() == 56) assert (expense.get_extype() == "transport") expense.set_day(3) assert (expense.get_day() == 3) expense.set_money(50) assert (expense.get_money() == 50) expense.set_extype("others") assert (expense.get_extype() == "others")