Skip to content

Commit

Permalink
[QI2-1081] Fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
NischalQuTech committed Sep 18, 2024
1 parent 2dd409b commit 101c501
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
6 changes: 4 additions & 2 deletions qiskit_quantuminspire/qi_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
class CircuitExecutionData:
"""Class for bookkeping of individual jobs."""

def __init__(self, circuit: QuantumCircuit, job_id: int = None, results: List[RawJobResult] = None) -> None:
def __init__(
self, circuit: QuantumCircuit, job_id: Union[int, None] = None, results: Union[List[RawJobResult], None] = None
) -> None:
self.job_id = job_id
self.circuit = circuit
self.results = [] if results is None else results
Expand Down Expand Up @@ -77,7 +79,7 @@ async def _fetch_job_results(self) -> None:

for circuit_data, result_item in zip(self.circuits_run_data, result_items):
circuit_data.results = result_item

def result(self) -> Result:
"""Return the results of the job."""
if not self.done():
Expand Down
15 changes: 15 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from unittest.mock import AsyncMock

import pytest
from pytest_mock import MockFixture

from qiskit_quantuminspire.api.pagination import PageReader


@pytest.fixture
def page_reader_mock(mocker: MockFixture) -> AsyncMock:
# Simply calling mocker.patch() doesn't work because PageReader is a generic class
page_reader_mock = AsyncMock()
page_reader_mock.get_all = AsyncMock()
mocker.patch.object(PageReader, "get_all", page_reader_mock.get_all)
return page_reader_mock
2 changes: 1 addition & 1 deletion tests/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_result_raises_error_when_status_not_done(mocker: MockerFixture) -> None
)
def test_fetch_job_result(
mocker: MockerFixture,
page_reader_mock: MockerFixture,
page_reader_mock: AsyncMock,
circuits: Union[QuantumCircuit, List[QuantumCircuit]],
expected_n_jobs: int,
) -> None:
Expand Down
10 changes: 0 additions & 10 deletions tests/test_qi_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import pytest
from pytest_mock import MockFixture

from qiskit_quantuminspire.api.pagination import PageReader
from qiskit_quantuminspire.qi_backend import QIBackend
from qiskit_quantuminspire.qi_provider import QIProvider
from tests.helpers import create_backend_type
Expand All @@ -17,15 +16,6 @@ def mock_api(mocker: MockFixture) -> None:
mocker.patch("qiskit_quantuminspire.qi_provider.BackendTypesApi")


@pytest.fixture
def page_reader_mock(mocker: MockFixture) -> AsyncMock:
# Simply calling mocker.patch() doesn't work because PageReader is a generic class
page_reader_mock = AsyncMock()
page_reader_mock.get_all = AsyncMock()
mocker.patch.object(PageReader, "get_all", page_reader_mock.get_all)
return page_reader_mock


def test_qi_provider_construct(mock_api: Any, page_reader_mock: AsyncMock) -> None:
# Arrange
page_reader_mock.get_all.return_value = [
Expand Down

0 comments on commit 101c501

Please sign in to comment.