Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
paaige committed Oct 9, 2023
1 parent 162735c commit fe590fc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cirq-superstaq/cirq_superstaq/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def input_circuits(
"""
return self._get_circuits("input_circuit", index=index)

def pulse_gate_circuit(self) -> qiskit.QuantumCircuit:
def pulse_gate_circuits(self) -> qiskit.QuantumCircuit:
"""Gets the pulse gate circuit returned by this job.
Returns:
Expand All @@ -330,7 +330,6 @@ def pulse_gate_circuit(self) -> qiskit.QuantumCircuit:
Raises:
ValueError: If job was not run on an IBM pulse device.
"""

if "pulse_gate_circuits" not in self._job:
self._refresh_job()
if self._job.get("pulse_gate_circuits") is not None:
Expand Down
18 changes: 18 additions & 0 deletions cirq-superstaq/cirq_superstaq/job_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import cirq
import general_superstaq as gss
import pytest
import qiskit
import qiskit_superstaq as qss

import cirq_superstaq as css

Expand Down Expand Up @@ -134,6 +136,22 @@ def test_compiled_circuit(job: css.job.Job) -> None:
assert job.compiled_circuits(index=0) == compiled_circuit


def test_pulse_gate_circuit(job: css.job.Job) -> None:
pulse_gate_circuit = qiskit.QuantumCircuit(1, 1)
pulse_gate = qiskit.circuit.Gate("test_pulse_gate", 1, [3.14, 1])
pulse_gate_circuit.append(pulse_gate, [0])
pulse_gate.measure(0, 0)
job_dict = {"status": "Done", "pulse_gate_circuits": qss.serialize_circuits(pulse_gate_circuit)}

# The first call will trigger a refresh:
with mocked_get_job_requests(job_dict) as mocked_get_job:
assert job.pulse_gate_circuits(index=0) == pulse_gate_circuit
mocked_get_job.assert_called_once()

# Shouldn't need to retrieve anything now that `job._job` is populated:
assert job.pulse_gate_circuits(index=0) == pulse_gate_circuit


def test_multi_circuit_job() -> None:
job = css.Job(
gss.superstaq_client._SuperstaqClient(
Expand Down

0 comments on commit fe590fc

Please sign in to comment.