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)
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)