def root(current_account_id=None): # check whether the user is logged in if not 'figo_token' in session: return redirect( connection.login_url( scope="accounts=ro transactions=ro balance=ro user=ro", state="qweqwe")) # open user figo connection figo_session = FigoSession(session['figo_token']) # open demo figo connection #figo_session = FigoSession("ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ") if current_account_id: current_account = figo_session.get_account(current_account_id) else: current_account = None if current_account: transactions = current_account.transactions else: transactions = figo_session.transactions return render_template('banking_root.html', accounts=figo_session.accounts, current_account=current_account, transactions=transactions, user=figo_session.user)
def test_get_supported_payment_services(access_token): figo_session = FigoSession(access_token) services = figo_session.get_supported_payment_services("de") assert len( services ) > 10 # this a changing value, this tests that at least some are returned assert isinstance(services[0], Service)
def figo_session(figo_connection, new_user_id): figo_connection.add_user("Test", new_user_id, PASSWORD) response = figo_connection.credential_login(new_user_id, PASSWORD) scope = response['scope'] required_scopes = [ 'accounts=rw', 'transactions=rw', 'user=rw', 'create_user', ] if any(s not in scope for s in required_scopes): pytest.skip("The client ID needs write access to the servers.") session = FigoSession(response['access_token']) task_token = session.add_account("de", ("figo", "figo"), "90090042") state = session.get_task_state(task_token) while not (state.is_ended or state.is_erroneous): state = session.get_task_state(task_token) time.sleep(2) assert not state.is_erroneous yield session session.remove_user()
def test_set_unset_language(access_token): figo_session = FigoSession(access_token) assert figo_session.language is None figo_session.language = 'de' assert figo_session.language == 'de' figo_session.language = '' assert figo_session.language is None figo_session.language = 'de'
def access_token(figo_connection, new_user_id): figo_connection.add_user("Test", new_user_id, PASSWORD) response = figo_connection.credential_login(new_user_id, PASSWORD) access_token = response['access_token'] yield access_token session = FigoSession(access_token) session.remove_user()
def demo_session(): # TODO(Valentin): we need to run `test_session` (both read-only) against production API # using demo credentials, since there is no adequate client or data available # on `staging`. we could: # - drop these tests entirely and lose quite some code coverage # - replace by write-then-read tests which cannot be run on external PRs # - create a non-expiring demo session on `staging` return FigoSession(DEMO_TOKEN, api_endpoint=DEMO_CREDENTIALS['api_endpoint'], fingerprints=DEMO_CREDENTIALS['ssl_fingerprints'])
def main(): session = FigoSession( "ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ" ) # print out a list of accounts including its balance for account in session.accounts: print account print account.balance # print out the list of all transactions on a specific account for transaction in session.get_account("A1.2").transactions: print transaction
def figo_session(figo_connection, new_user_id): figo_connection.add_user("Test", new_user_id, PASSWORD) response = figo_connection.credential_login(new_user_id, PASSWORD) scope = response['scope'] required_scopes = [ 'accounts=rw', 'transactions=rw', 'user=rw', 'categorization=rw', 'create_user', ] if any(s not in scope for s in required_scopes): pytest.skip("The client ID needs write access to the servers.") session = FigoSession(response['access_token']) yield session session.remove_user()
def test_get_catalog_en(access_token, language, country): figo_session = FigoSession(access_token) figo_session.language = language catalog = figo_session.get_catalog(country) for bank in catalog["banks"]: assert bank.country == country
def test_create_token_and_session(figo_connection): token = figo_connection.credential_login(pytest.new_user_id, PASSWORD) pytest.token = token["access_token"] assert pytest.token pytest.session = FigoSession(token["access_token"]) assert pytest.session.user.full_name == "Jimmy"
def setUp(self): self.sut = FigoSession( "ASHWLIkouP2O6_bgA2wWReRhletgWKHYjLqDaqb0LFfamim9RjexTo22ujRIP_cjLiRiSyQXyt2kM1eXU2XLFZQ0Hro15HikJQT_eNeT_9XQ" )
def test_get_catalog_invalid_language(access_token): figo_session = FigoSession(access_token) with pytest.raises(FigoException) as e: figo_session.get_catalog("XY") assert e.value.code == CLIENT_ERROR
def test_create_token_and_session(): token = connection.credential_login("*****@*****.**", "password") pytest.token = token["access_token"] assert pytest.token pytest.session = FigoSession(token["access_token"]) assert pytest.session.user.full_name == "John Doe"
import json import webbrowser from figo import FigoConnection, FigoSession from pprint import pprint from .transaction import Transaction from .contact import Contact #connection = FigoConnection("<client ID>", "<client secret>", "http://my-domain.org/redirect-url") with open("config.json", "r") as data_file: data = json.loads(data_file.read()) session = FigoSession(data["figo"]["token"]) def get_accounts(): accountlist = [] for account in session.accounts: accountlist.append(account) return accountlist def get_transactions(account): transact_list = [] for trans in session.get_account(account.account_id).transactions: c = Contact(account.name, account.iban, account.bic) x = Transaction(trans.transaction_id, c, trans.type, trans.purpose, trans.booking_text, trans.amount) transact_list.append(x) return transact_list
def test_get_payments(): session = FigoSession(pytest.payments_token) response = session.get_payments(pytest.account_id, None, None, None, None) assert response == []
def test_get_login_settings(access_token): figo_session = FigoSession(access_token) login_settings = figo_session.get_login_settings("de", BANK_CODE) assert isinstance(login_settings, LoginSettings) assert login_settings.advice assert login_settings.credentials
def figo_session(figo_connection, new_user_id): figo_connection.add_user("Test", new_user_id, PASSWORD) response = figo_connection.credential_login(new_user_id, PASSWORD) return FigoSession(response['access_token'])
def test_get_catalog_en(access_token, language): figo_session = FigoSession(access_token) figo_session.language = language catalog = figo_session.get_catalog() for bank in catalog['banks']: assert bank.language == language
def test_get_catalog_invalid_language(access_token): figo_session = FigoSession(access_token) catalog = figo_session.get_catalog("XY") assert catalog == {"banks": [], "services": []}
def test_get_catalog(access_token): figo_session = FigoSession(access_token) catalog = figo_session.get_catalog() assert len(catalog) == 2
def test_add_access_with_wrong_access_id(access_token): figo_session = FigoSession(access_token) access_method_id = "pipo" response = figo_session.add_access(access_method_id, CREDENTIALS, CONSENT) assert response.has_key("error") == True