Exemple #1
0
class ExpenseTest(Test):

    def setUp(self):
        Test.setUp(self)
        self.expense_type = ExpenseType(
            name="Test Type"
        )
        self.expense_type.add()
        self.expense = Expense(
            concept="Test Expense",
            type_id=self.expense_type.id
        )
        self.expense.add()
Exemple #2
0
class TestFilterExpensesByType(ExpenseTest):
    def setUp(self):
        ExpenseTest.setUp(self)
        other_expense_type = ExpenseType(name="Other Type")
        other_expense_type.add()
        self.other_expense = Expense(concept="Other Expense",
                                     type_id=other_expense_type.id)
        self.other_expense.add()

    def test_should_return_list_of_expenses_of_the_same_type_given_type_obj(
            self):
        all_expenses = Expense.query.all()
        expenses = filter_expenses_by_type(all_expenses, self.expense_type.id)

        self.assertEqual(expenses, [self.expense])

    def test_should_return_all_expenses_given_expense_type_id_is_0(self):
        all_expenses = Expense.query.all()
        expenses = filter_expenses_by_type(all_expenses, 0)

        self.assertEqual(expenses, all_expenses)
Exemple #3
0
    def test_should_add_expense(self):
        expense = Expense(concept="Some Expense", type_id=self.expense_type.id)
        expense.add()

        self.assertIn(expense, self.db.session)