Beispiel #1
0
    def test_can_retrieve_account_statements_with_account_filtering(
        self,
        mocked_post,
    ):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Statements': [],
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_statements('request-1234',
                                               accounts_filter=[
                                                   'acc-1234',
                                               ])

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/GetStatements'
        )
        assert mocked_post.call_args[1]['json'] == {
            'RequestId': 'request-1234',
            'AccountsFilter': [
                'acc-1234',
            ],
        }
Beispiel #2
0
    def test_can_perform_a_standard_authorize_request_with_security_responses(
            self, mocked_post):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'RequestId': 'test-1234',
            'LoginId': 'test-5678',
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.authorize(
            request_id='test-1234',
            username='******',
            password='******',
            security_responses={
                'Who is the best?': 'ME',
            },
        )

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/Authorize'
        )
        assert mocked_post.call_args[1]['json'] == {
            'RequestId': 'test-1234',
            'Username': '******',
            'Password': '******',
            'SecurityResponses': {
                'Who is the best?': 'ME',
            },
            'MostRecentCached': False,
        }
Beispiel #3
0
    def test_can_perform_an_authorize_request_with_scheduled_refreshes(
            self, mocked_post):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'RequestId': 'test-1234',
            'LoginId': 'test-5678',
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.authorize(
            institution='AwesomeBank',
            username='******',
            password='******',
            save=True,
            schedule_refresh=True,
        )

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/Authorize'
        )
        assert mocked_post.call_args[1]['json'] == {
            'Institution': 'AwesomeBank',
            'Username': '******',
            'Password': '******',
            'Save': True,
            'ScheduleRefresh': True,
            'MostRecentCached': False,
        }
Beispiel #4
0
    def test_can_perform_a_standard_authorize_request(self, mocked_post):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'RequestId': 'test-1234',
            'LoginId': 'test-5678',
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.authorize(
            institution='Test',
            username='******',
            password='******',
            save=True,
            most_recent_cached=False,
            tag='42',
        )

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/Authorize'
        )
        assert mocked_post.call_args[1]['json'] == {
            'Institution': 'Test',
            'MostRecentCached': False,
            'Password': '******',
            'Save': True,
            'Tag': '42',
            'Username': '******',
        }
Beispiel #5
0
    def test_can_return_accounts_details_for_a_specific_user_by_filtering_specific_accounts(
        self,
        mocked_post,
    ):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Accounts': [],
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_accounts_detail(
            'request-1234',
            with_transactions=True,
            accounts_filter=[
                'acc-1234',
            ],
        )

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/GetAccountsDetail'
        )
        assert mocked_post.call_args[1]['json'] == {
            'RequestId': 'request-1234',
            'WithAccountIdentity': False,
            'WithTransactions': True,
            'AccountsFilter': [
                'acc-1234',
            ],
        }
Beispiel #6
0
    def test_can_return_accounts_details_for_a_specific_user_with_specific_transactions_date_range(
        self,
        mocked_post,
    ):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Accounts': [],
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_accounts_detail(
            'request-1234',
            with_transactions=True,
            date_from=dt.date(2017, 1, 1),
            date_to=dt.datetime.now(),
        )

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/GetAccountsDetail'
        )
        assert mocked_post.call_args[1]['json'] == {
            'RequestId': 'request-1234',
            'WithAccountIdentity': False,
            'WithTransactions': True,
            'DateFrom': '2017-01-01',
            'DateTo': dt.datetime.now().date().isoformat(),
        }
Beispiel #7
0
    def test_can_set_new_security_questions_for_a_specific_user(
            self, mocked_patch):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Result': '',
        }
        mocked_patch.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.set_mfa_questions(
            'login-1234',
            [
                {
                    'Question': 'Who is the best?',
                    'Answer': 'ME',
                },
            ],
        )

        assert (
            mocked_patch.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/AnswerMFAQuestions'
        )
        assert mocked_patch.call_args[1]['json'] == {
            'LoginId': 'login-1234',
            'Questions': [
                {
                    'Question': 'Who is the best?',
                    'Answer': 'ME',
                },
            ],
        }
Beispiel #8
0
    def test_can_perform_an_authorize_multiple_request(self, mocked_post):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'ValidLoginIds': [
                {
                    'LoginId': 'login-1234',
                    'RequestId': 'request-1234'
                },
            ],
            'InvalidLoginIds': [],
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.authorize_multiple(login_ids=[
            'test-1234',
        ])

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/AuthorizeMultiple'
        )
        assert mocked_post.call_args[1]['json'] == {
            'LoginIds': [
                'test-1234',
            ],
        }
Beispiel #9
0
 def test_raises_a_protocol_error_if_an_error_is_present_in_the_response(
         self, mocked_post):
     mocked_response = unittest.mock.Mock(status_code=400, content='{}')
     mocked_response.json.return_value = {'FlinksCode': 'INVALID_LOGING'}
     mocked_post.return_value = mocked_response
     client = Client('foo-12345', 'https://username.flinks-custom.io')
     with pytest.raises(ProtocolError):
         client.banking_services.authorize(login_id='test')
Beispiel #10
0
 def test_raises_a_protocol_error_if_a_response_cannot_be_deserialized(
         self, mocked_post):
     mocked_response = unittest.mock.Mock(status_code=200, content='BAD')
     mocked_response.json.side_effect = ValueError()
     mocked_post.return_value = mocked_response
     client = Client('foo-12345', 'https://username.flinks-custom.io')
     with pytest.raises(ProtocolError):
         client.banking_services.authorize(login_id='test')
Beispiel #11
0
 def test_raises_a_transport_error_if_an_unsuccessful_is_sent_back_from_the_service(
     self,
     mocked_post,
 ):
     mocked_response = unittest.mock.Mock(status_code=500, content='ERROR')
     mocked_response.raise_for_status.side_effect = HTTPError(
         response=mocked_response)
     mocked_post.return_value = mocked_response
     client = Client('foo-12345', 'https://username.flinks-custom.io')
     with pytest.raises(TransportError):
         client.banking_services.authorize(login_id='test')
Beispiel #12
0
    def test_can_retrieve_account_statements_in_async_mode(self, mocked_get):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Result': '',
        }
        mocked_get.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_statements_async('request-1234')

        assert (mocked_get.call_args[0][0] == (
            'https://username.flinks-custom.io/foo-12345/BankingServices/'
            'GetStatementsAsync/request-1234'))
Beispiel #13
0
    def test_can_retrieve_mfa_questions_for_a_specific_user(self, mocked_get):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Questions': [],
        }
        mocked_get.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_mfa_questions('login-1234')

        assert (mocked_get.call_args[0][0] == (
            'https://username.flinks-custom.io/foo-12345/BankingServices/'
            'GetMFAQuestions/login-1234'))
Beispiel #14
0
    def test_can_delete_traces_associated_with_a_specific_login_id(
            self, mocked_delete):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Result': '',
        }
        mocked_delete.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.delete_card('login-1234')

        assert (
            mocked_delete.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/DeleteCard/login-1234'
        )
Beispiel #15
0
    def test_can_deactivate_scheduled_refreshes(self, mocked_patch):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = 'DEACTIVATED'
        mocked_patch.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.set_scheduled_refresh('login-1234',
                                                      is_activated=False)

        assert (
            mocked_patch.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/SetScheduledRefresh'
        )
        assert mocked_patch.call_args[1]['json'] == {
            'LoginId': 'login-1234',
            'IsActivated': False,
        }
Beispiel #16
0
    def test_can_return_accounts_summary_for_a_specific_user(
            self, mocked_post):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Accounts': [],
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_accounts_summary('request-1234')

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/GetAccountsSummary'
        )
        assert mocked_post.call_args[1]['json'] == {
            'RequestId': 'request-1234',
        }
Beispiel #17
0
    def test_can_retrieve_account_statements_with_a_specific_number_of_statements(
        self,
        mocked_post,
    ):
        mocked_response = unittest.mock.Mock(status_code=200, content='{}')
        mocked_response.json.return_value = {
            'Statements': [],
        }
        mocked_post.return_value = mocked_response

        client = Client('foo-12345', 'https://username.flinks-custom.io')
        client.banking_services.get_statements('request-1234',
                                               number_of_statements='Months3')

        assert (
            mocked_post.call_args[0][0] ==
            'https://username.flinks-custom.io/foo-12345/BankingServices/GetStatements'
        )
        assert mocked_post.call_args[1]['json'] == {
            'RequestId': 'request-1234',
            'NumberOfStatements': 'Months3',
        }