From 26df7f246f1afc0eedde9219b0615faeeadecd50 Mon Sep 17 00:00:00 2001 From: Alessandro Candido Date: Thu, 19 Sep 2024 13:46:07 +0200 Subject: [PATCH] test: Add test for platform localization --- tests/test_platform.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tests/test_platform.py b/tests/test_platform.py index 589812692..dbcd149bb 100644 --- a/tests/test_platform.py +++ b/tests/test_platform.py @@ -21,7 +21,7 @@ from qibolab._core.native import SingleQubitNatives, TwoQubitNatives from qibolab._core.parameters import NativeGates, Parameters, update_configs from qibolab._core.platform import Platform -from qibolab._core.platform.load import PLATFORM, PLATFORMS +from qibolab._core.platform.load import PLATFORM, PLATFORMS, locate_platform from qibolab._core.platform.platform import PARAMETERS from qibolab._core.pulses import Delay, Gaussian, Pulse, Rectangular from qibolab._core.sequence import PulseSequence @@ -67,6 +67,24 @@ def test_platform_basics(): assert (1, 6) in platform2.pairs +def test_locate_platform(tmp_path: Path): + some = tmp_path / "some" + some.mkdir() + + for p in [some / "platform0", some / "platform1"]: + p.mkdir() + (p / PLATFORM).write_text("'Ciao'") + + assert locate_platform("platform0", [some]) == some / "platform0" + + with pytest.raises(ValueError): + locate_platform("platform3") + + os.environ[PLATFORMS] = str(some) + + assert locate_platform("platform1") == some / "platform1" + + def test_create_platform_multipath(tmp_path: Path): some = tmp_path / "some" others = tmp_path / "others"