Esempio n. 1
0
    def test_fulfill_pay_transaction_no_money(self):
        member = Member(
            balance=2
        )
        transaction = PayTransaction(10)
        with self.assertRaises(StregForbudError) as c:
            member.fulfill(transaction)

        self.assertTrue(c.exception)
        self.assertEqual(member.balance, 2)
Esempio n. 2
0
 def test_can_create_non_duplicate_username(self):
     not_jeff = Member(username="******",
                       firstname="jeff",
                       lastname="jefferson",
                       gender="M")
     form = MemberForm(model_to_dict(not_jeff))
     self.assertTrue(form.is_valid())
Esempio n. 3
0
 def test_cant_create_duplicate_username(self):
     jeff = Member(username="******",
                   firstname="jeffrey",
                   lastname="jefferson",
                   gender="M")
     form = MemberForm(model_to_dict(jeff))
     self.assertFalse(form.is_valid())
Esempio n. 4
0
    def test_make_payment_negative(self):
        member = Member(balance=100)

        member.make_payment(-10)

        self.assertEqual(member.balance, 90)
Esempio n. 5
0
    def test_make_payment_positive(self):
        member = Member(balance=100)

        member.make_payment(10)

        self.assertEqual(member.balance, 110)
Esempio n. 6
0
    def test_fulfill_pay_transaction_rollback(self):
        member = Member(balance=2)
        transaction = PayTransaction(10)
        member.rollback(transaction)

        self.assertEqual(member.balance, 12)
Esempio n. 7
0
    def test_fulfill_pay_transaction(self):
        member = Member(balance=100)
        transaction = PayTransaction(10)
        member.fulfill(transaction)

        self.assertEqual(member.balance, 90)