diff --git a/tests_against_server/callable_from_qua/test_basic_qua_callable.py b/tests_against_server/callable_from_qua/test_basic_qua_callable.py new file mode 100644 index 00000000..98ac249f --- /dev/null +++ b/tests_against_server/callable_from_qua/test_basic_qua_callable.py @@ -0,0 +1,23 @@ +from qm.qua import * +from qualang_tools.callable_from_qua import * + +patch_qua_program_addons() + + +registered_calls = [] +@callable_from_qua +def register_calls(*args, **kwargs): + registered_calls.append({"args": args, "kwargs": kwargs}) + +def test_qua_callable_no_args(qmm, config): + registered_calls.clear() + with program() as prog: + register_calls() + + assert not registered_calls + qm = qmm.open_qm(config) + job = qm.execute(prog) + + from time import sleep + sleep(10) + assert registered_calls == [{"args": (), "kwargs": {}}] \ No newline at end of file diff --git a/tests_against_server/conftest.py b/tests_against_server/conftest.py new file mode 100644 index 00000000..1302d4be --- /dev/null +++ b/tests_against_server/conftest.py @@ -0,0 +1,101 @@ +from pathlib import Path +import toml +import pytest + +from qm import QuantumMachinesManager + + +@pytest.fixture +def qmm(): + config_file = Path.home() / ".qm_config.toml" + if not config_file.exists(): + raise FileNotFoundError( + "Could not locate ~/.qm_config.toml, cannot extract IP and port to execute tests" + ) + + config = toml.load(config_file) + if "qmm" not in config: + raise KeyError("'qmm' must be defined in ~/.qm_config.toml to run server tests") + + qmm = QuantumMachinesManager(**config["qmm"]) + qmm.close_all_quantum_machines() + + return qmm + + +@pytest.fixture +def config(): + + return { + "version": 1, + "controllers": { + "con1": { + "type": "opx1", + "analog_outputs": { + 1: {"offset": +0.0}, + 2: {"offset": +0.0}, + 3: {"offset": +0.0}, + }, + "digital_outputs": {1: {}, 2: {}}, + } + }, + "elements": { + "qe1": { + "singleInput": {"port": ("con1", 1)}, + "intermediate_frequency": 0, + "operations": { + "playOp": "constPulse", + "a_pulse": "arb_pulse1", + "playOp2": "constPulse2", + }, + "digitalInputs": { + "digital_input1": { + "port": ("con1", 1), + "delay": 0, + "buffer": 0, + } + }, + }, + }, + "pulses": { + "constPulse": { + "operation": "control", + "length": 1000, # in ns + "waveforms": {"single": "const_wf"}, + }, + "constPulse2": { + "operation": "control", + "length": 1000, # in ns + "waveforms": {"single": "const_wf"}, + "digital_marker": "ON", + }, + "arb_pulse1": { + "operation": "control", + "length": 100, # in ns + "waveforms": {"single": "arb_wf"}, + }, + "constPulse_mix": { + "operation": "control", + "length": 80, + "waveforms": {"I": "const_wf", "Q": "zero_wf"}, + }, + + }, + "waveforms": { + "zero_wf": {"type": "constant", "sample": 0.0}, + "const_wf": {"type": "constant", "sample": 0.2}, + "arb_wf": {"type": "arbitrary", "samples": [i / 200 for i in range(100)]}, + }, + "digital_waveforms": { + "ON": {"samples": [(1, 0)]}, + }, + "mixers": { + "mixer_qubit": [ + { + "intermediate_frequency": 0, + "lo_frequency": 0, + "correction": (1,0,0,1), + } + ], + }, + } \ No newline at end of file