コード例 #1
0
 def test_add_paycheck(self):
     account = Account()
     paycheck = account.add_paycheck(1000, description="Paycheck from WebApps Inc.", interval=MONTHLY)
     self.assertIn(paycheck, account.transactions)
     self.assertEqual(paycheck.amount, Decimal("1000.00"))
     self.assertIn("WebApps Inc.", paycheck.description)
     self.assertEqual(paycheck.interval, MONTHLY)
コード例 #2
0
 def test_add_income(self):
     account = Account()
     income = account.add_income(amount=1000, description="Gift", timestamp=datetime(2012, 1, 1))
     self.assertIn(income, account.transactions)
     self.assertEqual(income.amount, Decimal("1000.00"))
     self.assertEqual(income.description, "Gift")
     self.assertEqual(income.timestamp, datetime(2012, 1, 1))
コード例 #3
0
 def test_add_budget(self):
     account = Account()
     budget = account.add_budget(name="Test Budget", interval=MONTHLY, limit=1000)
     self.assertIn(budget, account.budgets)
     self.assertEqual(budget.name, "Test Budget")
     self.assertEqual(budget.interval, MONTHLY)
     self.assertEqual(budget.limit, Decimal("1000.00"))
コード例 #4
0
 def test_add_bill(self):
     account = Account()
     bill = account.add_bill(amount=100, description="Electricity", interval=MONTHLY)
     self.assertIn(bill, account.transactions)
     self.assertEqual(bill.amount, Decimal("100.00"))
     self.assertEqual(bill.description, "Electricity")
     self.assertEqual(bill.interval, MONTHLY)
コード例 #5
0
    def test_get_budget_totals(self):
        account = Account()
        account.add_budget("Groceries", interval=MONTHLY, limit=1000)
        account.add_purchase(100, category="Groceries")

        result = account.get_budget_totals()
        expected = {"Groceries": Decimal(100)}
        self.assertEqual(result, expected)
コード例 #6
0
 def test_balance(self):
     account = Account()
     account.add_income(amount=100)
     result = account.balance
     expected = Decimal(100)
     self.assertEqual(expected, result)
コード例 #7
0
 def test_add_purchase(self):
     account = Account()
     purchase = account.add_purchase(1000, description="Morning Coffee")
     self.assertIn(purchase, account.transactions)
     self.assertEqual(purchase.amount, Decimal("1000.00"))
     self.assertEqual("Morning Coffee", purchase.description)