コード例 #1
0
    def test_load_camera(self, tmp_path):
        """Test loading a camera from class file directly."""
        name = "Dummy Camera"
        class_name = "DummyCamera"
        config_defaults = {
            "intval": "1",
            "boolval": "No",
            "strval": "This is a test string"
        }

        device_py_path = tmp_path / "dummy_camera.py"
        with open(device_py_path, "w+") as f:
            f.write(
                dummy_device.format(class_name=class_name,
                                    name=name,
                                    parent_class="CameraInterface"))

        loader = pylo.DeviceLoader()
        loader.addDeviceFromFile("camera", name, device_py_path, class_name,
                                 config_defaults, "Test description")
        controller = pylo.Controller(None, pylo.AbstractConfiguration())

        device = self.check_loaded_device(loader,
                                          name,
                                          class_name,
                                          "dummy-camera",
                                          kind="camera",
                                          controller=controller)

        assert hasattr(device, "controller")
        assert isinstance(device.controller, pylo.Controller)
        assert device.controller == controller

        assert isinstance(device, pylo.CameraInterface)
コード例 #2
0
    def test_load_device_from_object(self):
        """Test loading a camera from class file directly."""
        device = DummyDeviceObject("device")
        name = "Dummy Device Object"
        config_defaults = {
            "intval": "1",
            "boolval": "No",
            "strval": "This is a test string"
        }

        loader = pylo.DeviceLoader()
        loader.addDeviceObject("device", name, device, config_defaults,
                               "Test description")

        load_device = self.check_loaded_device(loader, name,
                                               "DummyDeviceObject",
                                               "dummy-device-object")

        assert load_device == device
コード例 #3
0
    def test_load_ini_abs(self, tmp_path):
        """Test loading a class from an absolute path in an ini file."""
        name = "Dummy Device 1"
        class_name = "DummyDevice1"
        device_py_path = tmp_path / "dummy_device.py"
        device_ini_path = tmp_path / "devices.ini"

        with open(device_py_path, "w+") as f:
            f.write(
                dummy_device.format(class_name=class_name,
                                    name=name,
                                    parent_class="Device"))

        with open(device_ini_path, "w+") as f:
            f.write(
                dummy_device_ini.format(class_name=class_name,
                                        name=name,
                                        file_path=device_py_path))
        loader = pylo.DeviceLoader()
        loader.device_ini_files.add(device_ini_path)

        self.check_loaded_device(loader, name, class_name, "dummy-device-1")
コード例 #4
0
    def test_load_class(self, tmp_path):
        """Test loading a class file directly."""
        name = "Dummy Device 3"
        class_name = "DummyDevice"
        config_defaults = {
            "intval": "1",
            "boolval": "No",
            "strval": "This is a test string"
        }

        device_py_path = tmp_path / "dummy_device_3.py"
        with open(device_py_path, "w+") as f:
            f.write(
                dummy_device.format(class_name=class_name,
                                    name=name,
                                    parent_class="Device"))

        loader = pylo.DeviceLoader()
        loader.addDeviceFromFile("device", name, device_py_path, class_name,
                                 config_defaults, "Test description")

        self.check_loaded_device(loader, name, class_name, "dummy-device-3")