Example #1
0
 def test_login_system_credentials_200_and_saves_info(self):
     user = os.environ['B_AC']
     password = os.environ['B_AP']
     ba = BankApi()
     response_data = ba.login(user, password)
     self.assertEqual('OK', response_data['authenticationState'])
     # Tsec header and user id needed for every other call
     self.assertTrue(ba.session.headers['tsec'])
     self.assertTrue(ba.userid)
     self.assertTrue(len(ba.userid) > 10)
Example #2
0
class ApiTestGetRequests(TestCase):
    def setUp(self):
        user = os.environ['B_AC']
        password = os.environ['B_AP']
        self.ba = BankApi()
        self.ba.login(user, password)

    def test_get_customer_data(self):
        customer_data = self.ba.get_customer_data()
        self.assertTrue(customer_data['customer']['isCustomer'])

    def test_get_financial_dashboard(self):
        dashboard_data = self.ba.get_financial_dashboard()
        self.assertTrue(dashboard_data['assetBalance']['amount'] > -1)
Example #3
0
class ApiTestTsecAndRequestFuncion(TestCase):
    def setUp(self):
        user = os.environ['B_AC']
        password = os.environ['B_AP']
        self.ba = BankApi()
        self.ba.login(user, password)

    def test_login_saves_current_time(self):
        self.assertTrue(self.ba.last_tsec_time)

    @skip('No way of testing now without w8ing 4 minutes in real life')
    def test_request_refresh_tsec_if_needed(self):
        old_tsec = self.ba.session.headers['tsec']
        time.sleep(250)
        # Make a request
        self.ba.get_customer_data()
        new_tsec = self.ba.session.headers['tsec']
        # Expect the code to change the tsec on its own with new one
        self.assertTrue(old_tsec != new_tsec)
Example #4
0
class ApiTestPostRequests(TestCase):
    def setUp(self):
        user = os.environ['B_AC']
        password = os.environ['B_AP']
        self.ba = BankApi()
        self.ba.login(user, password)

    def test_wire_transfer_simulation_same_account(self):
        fd = self.ba.get_financial_dashboard()
        receiver_iban = fd['positions'][0]['contract']['account']['formats'][
            'iban']
        wt_data = {
            'beneficiary_iban': receiver_iban,
            'beneficiary_name': 'TEST NAME',
            'amount': 0.1,
            'description': 'test python'
        }
        wt_simulation = self.ba.post_wire_transfer_simulation(wt_data)
        expected_output = 'LAS CUENTAS DE CARGO Y ABONO SON IGUALES                                        '
        self.assertEqual(expected_output, wt_simulation['error-message'])
Example #5
0
 def test_create_api_object(self):
     ba = BankApi()
     self.assertEqual('/ASO/TechArchitecture/grantingTickets/V02',
                      ba.LOGIN_URL)
Example #6
0
 def setUp(self):
     user = os.environ['B_AC']
     password = os.environ['B_AP']
     self.ba = BankApi()
     self.ba.login(user, password)
Example #7
0
 def test_login_wrong_credentials_403(self):
     test_user = '******'
     test_password = '******'
     ba = BankApi()
     response_data = ba.login(test_user, test_password)
     self.assertEqual(403, response_data['http-status'])
Example #8
0
 def test_requests_session_creation(self):
     ba = BankApi()
     self.assertEqual(ba.session.headers['Content-Type'],
                      'application/json')