def test_websocket_status_queue(self): """Test status queue used by websocket client.""" status_queue = RefreshQueue(maxsize=10) cred = Credentials(token="", url="", websockets_url=MockWsServer.VALID_WS_URL, access_token=TOKEN_JOB_TRANSITION) client = WebsocketClient(MockWsServer.VALID_WS_URL, cred, "job_id", status_queue) client.get_job_status() self.assertEqual(status_queue.qsize(), 2)
def test_job_final_status_polling(self): """Test getting a job's final status via polling.""" status_queue = RefreshQueue(maxsize=1) response = self.client._job_final_status_polling( self.job_id, status_queue=status_queue) self.assertEqual(response.pop('status', None), ApiJobStatus.COMPLETED.value) self.assertNotEqual(status_queue.qsize(), 0)
def test_websocket_status_queue(self): """Test status queue used by websocket client.""" client = WebsocketClient( 'ws://{}:{}'.format(TEST_IP_ADDRESS, VALID_PORT), TOKEN_JOB_TRANSITION) status_queue = RefreshQueue(maxsize=10) _ = asyncio.get_event_loop().run_until_complete( client.get_job_status('job_id', status_queue=status_queue)) self.assertEqual(status_queue.qsize(), 2)