def test_fulfill_check_transaction_no_money(self): member = Member(balance=2) transaction = PayTransaction(10) has_money = member.can_fulfill(transaction) self.assertFalse(has_money)
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())
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())
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)
def test_make_payment_negative(self): member = Member( balance=100 ) member.make_payment(-10) self.assertEqual(member.balance, 90)
def test_make_payment_positive(self): member = Member( balance=100 ) member.make_payment(10) self.assertEqual(member.balance, 110)
def test_fulfill_pay_transaction_rollback(self): member = Member( balance=2 ) transaction = PayTransaction(10) member.rollback(transaction) self.assertEqual(member.balance, 12)
def test_fulfill_pay_transaction(self): member = Member( balance=100 ) transaction = PayTransaction(10) member.fulfill(transaction) self.assertEqual(member.balance, 90)