Пример #1
0
    def test_invalid_url(self):
        """Test connecting to an invalid URL."""
        client = WebsocketClient('wss://127.0.0.1:9876', None)

        with self.assertRaises(WebsocketError):
            asyncio.get_event_loop().run_until_complete(
                client.get_job_status('job_id'))
Пример #2
0
 def test_timeout(self):
     """Test timeout during retrieving a job status."""
     client = WebsocketClient(
         'ws://{}:{}'.format(TEST_IP_ADDRESS, VALID_PORT), TOKEN_TIMEOUT)
     with self.assertRaises(WebsocketTimeoutError):
         _ = asyncio.get_event_loop().run_until_complete(
             client.get_job_status('job_id', timeout=2))
Пример #3
0
 def test_job_transition(self):
     """Test retrieving a job that transitions to final status."""
     client = WebsocketClient('ws://127.0.0.1:8765', TOKEN_JOB_TRANSITION)
     response = asyncio.get_event_loop().run_until_complete(
         client.get_job_status('job_id'))
     self.assertIsInstance(response, dict)
     self.assertIn('status', response)
     self.assertEqual(response['status'], 'COMPLETED')
Пример #4
0
    def test_invalid_url(self):
        """Test connecting to an invalid URL."""
        client = WebsocketClient(
            'wss://{}:{}'.format(TEST_IP_ADDRESS, INVALID_PORT), None)

        with self.assertRaises(WebsocketError):
            asyncio.get_event_loop().run_until_complete(
                client.get_job_status('job_id'))
Пример #5
0
 def test_invalid_response(self):
     """Test unparseable response from the server."""
     client = WebsocketClient(
         'ws://{}:{}'.format(TEST_IP_ADDRESS, VALID_PORT),
         TOKEN_WRONG_FORMAT)
     with self.assertRaises(WebsocketIBMQProtocolError):
         _ = asyncio.get_event_loop().run_until_complete(
             client.get_job_status('job_id'))
Пример #6
0
 def test_job_final_status(self):
     """Test retrieving a job already in final status."""
     client = WebsocketClient(
         'ws://{}:{}'.format(TEST_IP_ADDRESS, VALID_PORT),
         TOKEN_JOB_COMPLETED)
     response = asyncio.get_event_loop().run_until_complete(
         client.get_job_status('job_id'))
     self.assertIsInstance(response, dict)
     self.assertIn('status', response)
     self.assertEqual(response['status'], 'COMPLETED')
Пример #7
0
 def test_invalid_response(self):
     """Test unparseable response from the server."""
     client = WebsocketClient('ws://127.0.0.1:8765', TOKEN_WRONG_FORMAT)
     with self.assertRaises(WebsocketIBMQProtocolError):
         _ = asyncio.get_event_loop().run_until_complete(
             client.get_job_status('job_id'))
Пример #8
0
 def test_timeout(self):
     """Test timeout during retrieving a job status."""
     client = WebsocketClient('ws://127.0.0.1:8765', TOKEN_TIMEOUT)
     with self.assertRaises(WebsocketTimeoutError):
         _ = asyncio.get_event_loop().run_until_complete(
             client.get_job_status('job_id', timeout=2))