def test_auto_bunq_context_update(self): """ Tests the auto update of BunqContext. """ api_context: ApiContext = BunqContext.api_context() api_context_json: object = json.loads(api_context.to_json()) api_context_json[self.__FIELD_SESSION_CONTEXT][ self.__FIELD_EXPIRE_TIME] = self.__TIME_STAMP_IN_PAST expired_api_context = ApiContext.from_json(json.dumps(api_context_json)) self.assertNotEqual(api_context.session_context.expiry_time, expired_api_context.session_context.expiry_time) self.assertEqual(BunqContext.api_context().session_context.expiry_time, api_context.session_context.expiry_time) BunqContext.update_api_context(expired_api_context) BunqContext.user_context().refresh_user_context() self.assertNotEqual( BunqContext.api_context().session_context.expiry_time, api_context.session_context.expiry_time ) self.assertFalse(BunqContext.api_context().ensure_session_active())
def test_session_delete(self): """ Tests the deletion and resetting of the current active session This test has no assertion as of its testing to see if the code runs without errors. Notes ----- time.sleep() is needed as of you can only make 1 POST call to Session endpoint per second. """ Session.delete(self._SESSION_ID) time.sleep(2) BunqContext.api_context().reset_session() BunqContext.api_context().save(self._BUNQ_CONFIG_FILE)
def update_context(self): BunqContext.api_context().save(self.determine_bunq_conf_filename())