Skip to content

Commit

Permalink
test: fix controller simulations
Browse files Browse the repository at this point in the history
sbourdeauducq committed Mar 22, 2016
1 parent abac528 commit 2bb4ad1
Showing 3 changed files with 64 additions and 14 deletions.
14 changes: 11 additions & 3 deletions artiq/test/hardware_testbench.py
Original file line number Diff line number Diff line change
@@ -21,10 +21,12 @@
logger = logging.getLogger(__name__)


@unittest.skipUnless(artiq_root, "no ARTIQ_ROOT")
class ControllerCase(unittest.TestCase):
class GenericControllerCase(unittest.TestCase):
def get_device_db(self):
raise NotImplementedError

def setUp(self):
self.device_db = DeviceDB(os.path.join(artiq_root, "device_db.pyon"))
self.device_db = self.get_device_db()
self.device_mgr = DeviceManager(self.device_db)
self.controllers = {}

@@ -87,6 +89,12 @@ def stop_controller(self, name, default_timeout=1):
del self.controllers[name]


@unittest.skipUnless(artiq_root, "no ARTIQ_ROOT")
class ControllerCase(GenericControllerCase):
def get_device_db(self):
return DeviceDB(os.path.join(artiq_root, "device_db.pyon"))


@unittest.skipUnless(artiq_root, "no ARTIQ_ROOT")
class ExperimentCase(unittest.TestCase):
def setUp(self):
22 changes: 18 additions & 4 deletions artiq/test/test_novatech409b.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import unittest

from artiq.devices.novatech409b.driver import Novatech409B
from artiq.test.hardware_testbench import ControllerCase
from artiq.test.hardware_testbench import GenericControllerCase, ControllerCase


class GenericNovatech409BTest:
@@ -27,6 +27,20 @@ def setUp(self):
self.driver = self.device_mgr.get("novatech409b")


class TestNovatech409BSim(GenericNovatech409BTest, unittest.TestCase):
class TestNovatech409BSim(GenericNovatech409BTest, GenericControllerCase):
def get_device_db(self):
return {
"novatech409b": {
"type": "controller",
"host": "::1",
"port": 3254,
"command": (sys.executable.replace("\\", "\\\\")
+ " -m artiq.frontend.novatech409b_controller "
+ "-p {port} --simulation")
}
}

def setUp(self):
self.driver = Novatech409B(None)
GenericControllerCase.setUp(self)
self.start_controller("novatech409b")
self.driver = self.device_mgr.get("novatech409b")
42 changes: 35 additions & 7 deletions artiq/test/test_thorlabs_tcube.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import unittest
import time
import sys
import unittest

from artiq.devices.thorlabs_tcube.driver import TdcSim, TpzSim
from artiq.language.units import V
from artiq.test.hardware_testbench import ControllerCase
from artiq.test.hardware_testbench import ControllerCase, GenericControllerCase


class GenericTdcTest:
@@ -138,9 +138,23 @@ def setUp(self):
self.cont = self.device_mgr.get("tdc")


class TestTdcSim(unittest.TestCase, GenericTdcTest):
class TestTdcSim(GenericControllerCase, GenericTdcTest):
def get_device_db(self):
return {
"tdc": {
"type": "controller",
"host": "::1",
"port": 3255,
"command": (sys.executable.replace("\\", "\\\\")
+ " -m artiq.frontend.thorlabs_tcube_controller "
+ "-p {port} -P tdc001 --simulation")
}
}

def setUp(self):
self.cont = TdcSim()
GenericControllerCase.setUp(self)
self.start_controller("tdc")
self.cont = self.device_mgr.get("tdc")


class TestTpz(ControllerCase, GenericTpzTest):
@@ -150,6 +164,20 @@ def setUp(self):
self.cont = self.device_mgr.get("tpz")


class TestTpzSim(unittest.TestCase, GenericTpzTest):
class TestTpzSim(GenericControllerCase, GenericTpzTest):
def get_device_db(self):
return {
"tpz": {
"type": "controller",
"host": "::1",
"port": 3255,
"command": (sys.executable.replace("\\", "\\\\")
+ " -m artiq.frontend.thorlabs_tcube_controller "
+ "-p {port} -P tpz001 --simulation")
}
}

def setUp(self):
self.cont = TpzSim()
GenericControllerCase.setUp(self)
self.start_controller("tpz")
self.cont = self.device_mgr.get("tpz")

0 comments on commit 2bb4ad1

Please sign in to comment.