Skip to content

Commit

Permalink
add jupyter unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kt474 committed May 11, 2022
1 parent ee852ed commit 15e2aa2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
source = qiskit_ibm_provider

[mypy]
exclude = test/integration/test_jupyter.py
exclude = (test/integration/test_jupyter.py|test/unit/test_jupyter_dashboard.py)
python_version = 3.7
namespace_packages = True
ignore_missing_imports = True
Expand Down
30 changes: 0 additions & 30 deletions test/integration/test_jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
from qiskit import transpile
from qiskit.test.reference_circuits import ReferenceCircuits

from qiskit.test.mock import FakeBackendV2 as FakeBackend

from qiskit_ibm_provider.jupyter.config_widget import config_tab
from qiskit_ibm_provider.jupyter.dashboard.backend_widget import make_backend_widget
from qiskit_ibm_provider.jupyter.dashboard.job_widgets import create_job_widget
Expand All @@ -28,7 +26,6 @@
from qiskit_ibm_provider.jupyter.gates_widget import gates_tab
from qiskit_ibm_provider.jupyter.jobs_widget import jobs_tab
from qiskit_ibm_provider.jupyter.qubits_widget import qubits_tab
from qiskit_ibm_provider.jupyter.live_data_widget import LiveDataVisualization
from qiskit_ibm_provider.visualization.interactive.error_map import iplot_error_map
from ..decorators import (
IntegrationTestDependencies,
Expand All @@ -37,33 +34,6 @@
from ..ibm_test_case import IBMTestCase


class TestLiveDataVisualization(IBMTestCase):
"""Test Live Data Jupyter widget."""

@classmethod
@integration_test_setup()
def setUpClass(cls, dependencies: IntegrationTestDependencies) -> None:
# pylint: disable=arguments-differ
super().setUpClass()
cls.dependencies = dependencies
cls.sim_backend = dependencies.provider.get_backend(
"ibmq_qasm_simulator", instance=dependencies.instance
)
cls.backends = _get_backends(cls.dependencies.provider)

def test_live_data(self):
"""Test LiveDataVisualization class."""
livedata = LiveDataVisualization()
title = "example title"
html_title = livedata.create_title("example title")
backend = FakeBackend()
visualization = livedata.create_visualization(
backend, figsize=(11, 9), show_title=False
)
self.assertIn(title, str(html_title))
self.assertTrue(visualization)


class TestBackendInfo(IBMTestCase):
"""Test backend information Jupyter widget."""

Expand Down
34 changes: 34 additions & 0 deletions test/unit/test_jupyter_dashboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2022.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# 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.

"""Test jupyter dashboard widgets."""

from qiskit.test.mock import FakeBackendV2 as FakeBackend
from qiskit_ibm_provider.jupyter.live_data_widget import LiveDataVisualization

from ..ibm_test_case import IBMTestCase


class TestLiveDataVisualization(IBMTestCase):
"""Test Live Data Jupyter widget."""

def test_live_data(self):
"""Test LiveDataVisualization class."""
livedata = LiveDataVisualization()
title = "example title"
html_title = livedata.create_title("example title")
backend = FakeBackend()
visualization = livedata.create_visualization(
backend, figsize=(11, 9), show_title=False
)
self.assertIn(title, str(html_title))
self.assertTrue(visualization)

0 comments on commit 15e2aa2

Please sign in to comment.