Skip to content
This repository was archived by the owner on Jul 28, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ stage_generic: &stage_generic
# Install step for jobs that require compilation and qa.
# TODO: until the split is complete, install a terra branch.
# - pip install -U -r requirements.txt
- git clone --single-branch --branch feature/remove-ibmq git@github.com:diego-plan9/qiskit-sdk-py.git
- git clone --single-branch --branch feature/remove-ibmq https://github.com/diego-plan9/qiskit-sdk-py.git
- pip install -e qiskit-sdk-py
- pip install "requests>=2.19"
- pip install "requests-ntlm>=1.1.0"
Expand Down
20 changes: 20 additions & 0 deletions test/ibmq/test_ibmq_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""Tests for all IBMQ backends."""

from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.providers.exceptions import QiskitBackendNotFoundError
from qiskit.providers.ibmq import IBMQ
from qiskit.qobj import QobjHeader
from qiskit.test import QiskitTestCase, requires_qe_access, slow_test
Expand Down Expand Up @@ -116,3 +117,22 @@ def test_qobj_headers_in_result_devices(self, qe_token, qe_url):
self.assertEqual(result.header.to_dict(), custom_qobj_header)
self.assertEqual(result.results[0].header.some_field,
'extra info')

@requires_qe_access
def test_aliases(self, qe_token, qe_url):
"""Test that display names of devices map the regular names."""
IBMQ.enable_account(qe_token, qe_url)
aliased_names = IBMQ._aliased_backend_names()

for display_name, backend_name in aliased_names.items():
with self.subTest(display_name=display_name,
backend_name=backend_name):
try:
backend_by_name = IBMQ.get_backend(backend_name)
except QiskitBackendNotFoundError:
# The real name of the backend might not exist
pass
else:
backend_by_display_name = IBMQ.get_backend(display_name)
self.assertEqual(backend_by_name, backend_by_display_name)
self.assertEqual(backend_by_display_name.name(), backend_name)
1 change: 0 additions & 1 deletion test/ibmq/test_ibmq_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""Test IBMQConnector."""

import re
import unittest

from qiskit.providers.ibmq.api import (ApiError, BadBackendError,
IBMQConnector, RegisterSizeError)
Expand Down
2 changes: 0 additions & 2 deletions test/ibmq/test_ibmq_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

"""IBMQ provider integration tests (compile and run)."""

import unittest

from qiskit import ClassicalRegister, QuantumCircuit, QuantumRegister
from qiskit.providers.ibmq import IBMQ, least_busy
from qiskit.result import Result
Expand Down
11 changes: 5 additions & 6 deletions test/ibmq/test_ibmq_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ def test_get_jobs_filter_job_status(self, qe_token, qe_url):
job_list = backend.jobs(limit=5, skip=0, status=JobStatus.DONE)

self.log.info('found %s matching jobs', len(job_list))
for i, job in enumerate(job_list):
self.log.info('match #%d: %s', i, job.result().status)
for job in job_list:
self.assertTrue(job.status() is JobStatus.DONE)

@requires_qe_access
Expand Down Expand Up @@ -341,8 +340,8 @@ def test_double_submit_fails(self, qe_token, qe_url):


@unittest.skip('Temporarily disabled, see #1162')
class TestQObjectBasedIBMQJob(JobTestCase):
"""Test jobs supporting QObject."""
class TestQobjBasedIBMQJob(JobTestCase):
"""Test jobs supporting Qobj."""

def setUp(self):
super().setUp()
Expand All @@ -358,13 +357,13 @@ def setUp(self):

self._qc = _bell_circuit()

def test_qobject_enabled_job(self):
def test_qobj_enabled_job(self):
"""Job should be an instance of IBMQJob."""
qobj = compile(self._qc, self._backend)
job = self._backend.run(qobj)
self.assertIsInstance(job, IBMQJob)

def test_qobject_result(self):
def test_qobj_enabled_result(self):
"""Jobs can be retrieved."""
qobj = compile(self._qc, self._backend)
job = self._backend.run(qobj)
Expand Down
22 changes: 3 additions & 19 deletions test/ibmq/test_ibmq_job_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
"""IBMQJob states test-suite."""

import time
import unittest
from contextlib import suppress

from qiskit.test.mock import new_fake_qobj, FakeRueschlikon
from qiskit.providers import JobError, JobTimeoutError
from qiskit.providers.ibmq.api import ApiError
from qiskit.providers.ibmq.ibmqjob import API_FINAL_STATES, IBMQJob, IBMQJobPreQobj
from qiskit.providers.ibmq.ibmqjob import API_FINAL_STATES, IBMQJobPreQobj
from qiskit.providers.jobstatus import JobStatus
from ..jobtestcase import JobTestCase
from ..mockutils import FakeBackend, new_fake_qobj


class TestIBMQJobStates(JobTestCase):
Expand Down Expand Up @@ -247,26 +246,11 @@ def test_only_final_states_cause_datailed_request(self):
else:
self.assertFalse(self._current_api.get_job.called)

# TODO: Once qobj results come by default from all the simulator
# backends, move to integration tests in test_result.py
def test_qobj_result(self):
job = self.run_with_api(QObjResultAPI(), job_class=IBMQJob)

self.wait_for_initialization(job)
self._current_api.progress()
result = job.result()
self.assertEqual(result.success, True)
self.assertEqual(result.get_counts('Bell state'),
{'00': 480, '11': 490, '01': 20, '10': 34})
self.assertEqual(result.get_counts('Bell state XY'),
{'00': 29, '11': 15, '01': 510, '10': 480})
self.assertEqual(len(result.results), 2)

def run_with_api(self, api, job_class=IBMQJobPreQobj):
"""Creates a new ``IBMQJobPreQobj`` instance running with the provided API
object.
"""
backend = FakeBackend()
backend = FakeRueschlikon()
self._current_api = api
self._current_qjob = job_class(backend, None, api, False, qobj=new_fake_qobj())
self._current_qjob.submit()
Expand Down
1 change: 0 additions & 1 deletion test/ibmq/test_ibmq_qobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"""IBMQ Remote Backend Qobj Tests."""

import os
import unittest

from qiskit import (BasicAer, ClassicalRegister, QuantumCircuit,
QuantumRegister)
Expand Down
68 changes: 0 additions & 68 deletions test/mockutils.py

This file was deleted.