[groupamaes] use find_object in get_account

This commit is contained in:
Bezleputh 2014-04-17 12:00:04 +02:00
commit 98a70783a7
3 changed files with 3 additions and 12 deletions

View file

@ -20,7 +20,7 @@
from weboob.capabilities.bank import ICapBank, AccountNotFound from weboob.capabilities.bank import ICapBank, AccountNotFound
from weboob.tools.backend import BaseBackend, BackendConfig from weboob.tools.backend import BaseBackend, BackendConfig
from weboob.tools.value import ValueBackendPassword from weboob.tools.value import ValueBackendPassword
from weboob.capabilities.base import find_object
from .browser import GroupamaesBrowser from .browser import GroupamaesBrowser
@ -54,8 +54,4 @@ class GroupamaesBackend(BaseBackend, ICapBank):
return self.browser.get_history() return self.browser.get_history()
def get_account(self, _id): def get_account(self, _id):
account = self.browser.get_account(_id) return find_object(self.browser.get_accounts_list(), id=_id, error=AccountNotFound)
if account:
return account
else:
raise AccountNotFound()

View file

@ -59,9 +59,3 @@ class GroupamaesBrowser(LoginBrowser):
transactions = list(self.operations_futures.go().get_list()) transactions = list(self.operations_futures.go().get_list())
transactions.sort(key=lambda tr: tr.rdate, reverse=True) transactions.sort(key=lambda tr: tr.rdate, reverse=True)
return transactions return transactions
def get_account(self, id):
assert isinstance(id, basestring)
for a in self.get_accounts_list():
if a.id == id:
return a

View file

@ -28,4 +28,5 @@ class GroupamaesTest(BackendTest):
l = list(self.backend.iter_accounts()) l = list(self.backend.iter_accounts())
if len(l) > 0: if len(l) > 0:
a = l[0] a = l[0]
self.assertTrue(self.backend.get_account(l[0].id) is not None)
list(self.backend.iter_history(a)) list(self.backend.iter_history(a))