Exemple #1
0
 def deposit(self, amount, id):
     if amount < 0:
         raise ValueError('Invalid amount.')
     acc = Account(self.get_events(id))
     acc.make_deposit(amount)
     event_store = store()
     event_store.save(acc.id, acc.changes)
Exemple #2
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 #3
0
 def process_account(self, client_id):
     event_store = store()
     client_stream = event_store.load(client_id)
     if client_stream.version == -1:
         raise ClientNotFoundException(client_id)
     account = Account()
     account.create_account(client_id)
     event_store.save(account.id, account.changes)
     #self.send_email(account.id)
     return account.id
Exemple #4
0
 def test_load_account(self):
     a = Account()
     a.create_account(uuid.uuid4())
     a.make_deposit(20)
     load_acc = Account(a.changes)
     self.assertEquals(load_acc.balance, 20)
     self.assertEquals(load_acc.id, a.id)
Exemple #5
0
 def get(self, id):
     acc = Account(self.get_events(id))
     json_acc = {'balance': float(acc.balance)}
     return json_acc
Exemple #6
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 #7
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)
Exemple #8
0
 def test_deposit(self):
     a = Account()
     a.create_account(uuid.uuid4())
     a.make_deposit(50)
     self.assertEquals(len(a.changes), 2)
     self.assertEquals(a.balance, 50)
Exemple #9
0
 def test_create_account(self):
     a = Account()
     a.create_account(uuid.uuid4())
     self.assertEquals(len(a.changes), 1)
     self.assertEquals(a.balance, 0)