Exemplo n.º 1
0
    def _wrapper(self, *args, **kwargs):
        # To avoid checking the connection in each test
        global HAS_NET_CONNECTION  # pylint: disable=global-statement

        if os.getenv('QISKIT_TEST_SKIP_ONLINE'):
            raise unittest.SkipTest('Skipping online tests')

        if HAS_NET_CONNECTION is None:
            HAS_NET_CONNECTION = _has_connection('qapi.honeywell.com', 443)

        if not HAS_NET_CONNECTION:
            raise unittest.SkipTest("Test requires internet connection.")

        try:
            Honeywell.load_account()
        except exceptions.HoneywellError:
            raise unittest.SkipTest(
                "Test requires valid, configured honeywell credentials")

        return func(self, *args, **kwargs)
Exemplo n.º 2
0
    def _wrapper(self, *args, **kwargs):
        # To avoid checking the connection in each test
        global HAS_NET_CONNECTION  # pylint: disable=global-statement

        if TEST_OPTIONS['skip_online']:
            raise unittest.SkipTest('Skipping online tests')

        if HAS_NET_CONNECTION is None:
            HAS_NET_CONNECTION = _has_connection('qiskit.org', 443)

        if not HAS_NET_CONNECTION:
            raise unittest.SkipTest("Test requires internet connection.")

        credentials = _get_credentials(self, TEST_OPTIONS)
        self.using_ibmq_credentials = credentials.is_ibmq()
        kwargs.update({
            'qe_token': credentials.token,
            'qe_url': credentials.url
        })

        return func(self, *args, **kwargs)
Exemplo n.º 3
0
   VisualizationError
"""

import os
import sys

from qiskit.util import _has_connection
from qiskit.visualization.counts_visualization import plot_histogram
from qiskit.visualization.state_visualization import (
    plot_state_hinton, plot_bloch_vector, plot_bloch_multivector,
    plot_state_city, plot_state_paulivec, plot_state_qsphere)
from qiskit.visualization.transition_visualization import visualize_transition

from .circuit_visualization import circuit_drawer, qx_color_scheme
from .dag_visualization import dag_drawer
from .exceptions import VisualizationError
from .gate_map import plot_gate_map, plot_circuit_layout, plot_error_map
from .matplotlib import HAS_MATPLOTLIB
from .pass_manager_visualization import pass_manager_drawer
from .pulse.interpolation import step_wise, linear, cubic_spline
from .pulse.qcstyle import PulseStyle, SchedStyle
from .pulse_visualization import pulse_drawer
from .timeline import draw as timeline_drawer

if (('ipykernel' in sys.modules) and ('spyder' not in sys.modules)) \
        or os.getenv('QISKIT_DOCS') == 'TRUE':
    if _has_connection('qvisualization.mybluemix.net', 443):
        from qiskit.visualization.interactive import (
            iplot_bloch_multivector, iplot_state_city, iplot_state_qsphere,
            iplot_state_hinton, iplot_histogram, iplot_state_paulivec)
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""Tests for the wrapper functionality."""

import unittest
from unittest.mock import patch
from io import StringIO

from qiskit.tools.monitor import backend_overview, backend_monitor
from qiskit.test import QiskitTestCase, requires_qe_access
from qiskit.util import _has_connection
# Check if internet connection exists
HAS_NET_CONNECTION = _has_connection('qiskit.org', 443)


class TestBackendOverview(QiskitTestCase):
    """Tools test case."""
    @unittest.skipIf(not HAS_NET_CONNECTION, "requries internet connection.")
    @requires_qe_access
    def test_backend_overview(self, qe_token, qe_url):
        """Test backend_overview"""
        from qiskit import IBMQ  # pylint: disable: import-error
        IBMQ.enable_account(qe_token, qe_url)

        with patch('sys.stdout', new=StringIO()) as fake_stout:
            backend_overview()
        stdout = fake_stout.getvalue()
        self.assertIn('Operational:', stdout)