Exemple #1
0
 def withdrawal(self, amount, id):
     if amount < 0:
         raise ValueError('Invalid amount.')
     acc = Account(self.get_events(id))
     if acc.balance - amount < 0:
         raise ValueError('You don\'t have that amount to withdrawal.')
     acc.make_withdrawal(amount)
     event_store = store()
     event_store.save(acc.id, acc.changes)
Exemple #2
0
 def test_withdrawal_deposit(self):
     a = Account()
     a.create_account(uuid.uuid4())
     a.make_deposit(500)
     a.make_deposit(20)
     a.make_withdrawal(50)
     a.make_deposit(5000)
     a.make_withdrawal(100)
     self.assertEquals(len(a.changes), 6)
     self.assertEquals(a.balance, 5370)
Exemple #3
0
 def test_withdrawal(self):
     a = Account()
     a.create_account(uuid.uuid4())
     a.make_withdrawal(50)
     self.assertEquals(len(a.changes), 2)
     self.assertEquals(a.balance, -50)