示例#1
0
 def start_modules_with_task(self):
     """Start modules with the task."""
     task = StartModulesTask(DBus, conf.anaconda.kickstart_modules,
                             conf.anaconda.addons_enabled)
     task.succeeded_signal.connect(
         lambda: self.set_module_observers(task.get_result()))
     return task
示例#2
0
    def test_start_module_failed(self):
        """Fail to start a module."""
        service_names = [
            "org.fedoraproject.Anaconda.Modules.A",
            "org.fedoraproject.Anaconda.Modules.B",
            "org.fedoraproject.Anaconda.Modules.C",
        ]

        task = StartModulesTask(self._message_bus,
                                service_names,
                                addons_enabled=False)

        def call():
            raise DBusError("Fake error!")

        def fake_callbacks(fake_observer):
            for observer in task._module_observers:
                task._start_service_by_name_callback(call, observer)

        task._callbacks.put((None, fake_callbacks))

        with self.assertRaises(UnavailableModuleError) as cm:
            task.run()

        expected = "Service org.fedoraproject.Anaconda.Modules.A has failed to start: Fake error!"
        self.assertEqual(str(cm.exception), expected)
示例#3
0
    def test_start_addon_failed(self, gio):
        """Fail to start an add-on."""
        service_names = [
            "org.fedoraproject.Anaconda.Addons.A",
            "org.fedoraproject.Anaconda.Addons.B",
            "org.fedoraproject.Anaconda.Addons.C"
        ]

        bus_proxy = self._message_bus.proxy
        bus_proxy.ListActivatableNames.return_value = [
            *service_names,
            "org.fedoraproject.Anaconda.D",
            "org.fedoraproject.E",
        ]

        task = StartModulesTask(self._message_bus, [], addons_enabled=True)
        self._check_started_modules(task, service_names)

        def call():
            raise DBusError("Fake error!")

        def fake_callbacks(fake_observer):
            for observer in task._module_observers:
                task._start_service_by_name_callback(call, observer)

        task._callbacks.put((None, fake_callbacks))
        self.assertEqual(task.run(), [])
示例#4
0
    def test_start_addon_failed(self, gio):
        """Fail to start an add-on."""
        service_namespaces = [
            "org.fedoraproject.Anaconda.Addons.*"
        ]
        service_names = [
            "org.fedoraproject.Anaconda.Addons.A",
            "org.fedoraproject.Anaconda.Addons.B",
            "org.fedoraproject.Anaconda.Addons.C"
        ]

        task = StartModulesTask(
            message_bus=self._message_bus,
            activatable=service_namespaces,
            optional=service_namespaces,
            forbidden=[]
        )
        self._check_started_modules(task, service_names)

        def call():
            raise DBusError("Fake error!")

        def fake_callbacks(fake_observer):
            for observer in task._module_observers:
                task._start_service_by_name_callback(call, observer)

        task._callbacks.put((None, fake_callbacks))
        self.assertEqual(task.run(), [])
示例#5
0
 def start_modules_with_task(self):
     """Start modules with the task."""
     task = StartModulesTask(
         message_bus=DBus,
         activatable=conf.anaconda.activatable_modules,
         forbidden=conf.anaconda.forbidden_modules,
         optional=conf.anaconda.optional_modules,
     )
     task.succeeded_signal.connect(
         lambda: self.set_module_observers(task.get_result()))
     return task
示例#6
0
    def test_start_modules_forbidden(self, gio):
        """Try to start forbidden modules."""
        service_namespaces = [
            "org.fedoraproject.Anaconda.Modules.*",
            "org.fedoraproject.Anaconda.Addons.*",
            "org.fedoraproject.InitialSetup.Modules.*",
        ]
        forbidden_names = [
            "org.fedoraproject.Anaconda.Modules.B",
            "org.fedoraproject.Anaconda.Addons.C",
            "org.fedoraproject.InitialSetup.*",
        ]
        service_names = [
            "org.fedoraproject.Anaconda.Addons.A",
            "org.fedoraproject.Anaconda.Addons.B",
            "org.fedoraproject.Anaconda.Modules.A",
            "org.fedoraproject.Anaconda.Modules.C",
        ]

        task = StartModulesTask(message_bus=self._message_bus,
                                activatable=service_namespaces,
                                forbidden=forbidden_names,
                                optional=[])

        self._check_started_modules(task, service_names)
示例#7
0
    def start_modules_test(self):
        """Start some modules."""
        service_names = [
            "org.fedoraproject.Anaconda.Modules.A",
            "org.fedoraproject.Anaconda.Modules.B",
            "org.fedoraproject.Anaconda.Modules.C",
        ]

        task = StartModulesTask(self._message_bus, service_names, addons_enabled=False)
        self._check_started_modules(task, service_names)
示例#8
0
    def test_start_modules(self, gio):
        """Start modules."""
        service_names = [
            "org.fedoraproject.Anaconda.Modules.A",
            "org.fedoraproject.Anaconda.Modules.B",
            "org.fedoraproject.Anaconda.Modules.C",
        ]

        task = StartModulesTask(self._message_bus, service_names, [], [])
        observers = self._check_started_modules(task, service_names)

        for observer in observers:
            assert observer.is_addon == False
示例#9
0
    def get_service_names_test(self, gio):
        """Get service names of running modules."""
        self.assertEqual(self._manager.get_service_names(), [])

        service_names = [
            "org.fedoraproject.Anaconda.Modules.A",
            "org.fedoraproject.Anaconda.Modules.B",
            "org.fedoraproject.Anaconda.Modules.C",
        ]

        task = StartModulesTask(self._message_bus, service_names, addons_enabled=False)
        observers = self._check_started_modules(task, service_names)

        self._manager.set_module_observers(observers)
        self.assertEqual(self._manager.get_service_names(), service_names)
示例#10
0
    def test_start_one_module(self, gio):
        """Start one module."""
        service_names = ["org.fedoraproject.Anaconda.Modules.A"]
        task = StartModulesTask(self._message_bus, service_names, [], [])
        (observer, ) = self._check_started_modules(task, service_names)  # pylint: disable=unbalanced-tuple-unpacking

        bus_proxy = self._message_bus.proxy
        bus_proxy.StartServiceByName.assert_called_once_with(
            "org.fedoraproject.Anaconda.Modules.A",
            DBUS_FLAG_NONE,
            callback=task._start_service_by_name_callback,
            callback_args=(observer, ))

        gio.bus_watch_name_on_connection.assert_called_once()
        observer.proxy.Ping.assert_called_once_with()
示例#11
0
    def test_get_service_names(self, gio):
        """Get service names of running modules."""
        assert self._manager.get_service_names() == []

        service_names = [
            "org.fedoraproject.Anaconda.Modules.A",
            "org.fedoraproject.Anaconda.Modules.B",
            "org.fedoraproject.Anaconda.Modules.C",
        ]

        task = StartModulesTask(self._message_bus, service_names, [], [])
        observers = self._check_started_modules(task, service_names)

        self._manager.set_module_observers(observers)
        assert self._manager.get_service_names() == service_names
示例#12
0
    def test_start_addons(self, gio):
        """Start addons."""
        service_namespaces = [
            "org.fedoraproject.Anaconda.Addons.*"
        ]
        service_names = [
            "org.fedoraproject.Anaconda.Addons.A",
            "org.fedoraproject.Anaconda.Addons.B",
            "org.fedoraproject.Anaconda.Addons.C"
        ]

        task = StartModulesTask(self._message_bus, service_namespaces, [], [])
        observers = self._check_started_modules(task, service_names)

        for observer in observers:
            self.assertEqual(observer.is_addon, True)
示例#13
0
    def test_start_addons(self, gio):
        """Start addons."""
        service_names = [
            "org.fedoraproject.Anaconda.Addons.A",
            "org.fedoraproject.Anaconda.Addons.B",
            "org.fedoraproject.Anaconda.Addons.C"
        ]

        bus_proxy = self._message_bus.proxy
        bus_proxy.ListActivatableNames.return_value = [
            *service_names,
            "org.fedoraproject.Anaconda.D",
            "org.fedoraproject.E",
        ]

        task = StartModulesTask(self._message_bus, [], addons_enabled=True)
        self._check_started_modules(task, service_names)
示例#14
0
    def start_one_module_test(self, gio):
        """Start one module."""
        service_names = ["org.fedoraproject.Anaconda.Modules.A"]

        task = StartModulesTask(self._message_bus,
                                service_names,
                                addons_enabled=False)
        (observer, ) = self._check_started_modules(task, service_names)

        bus_proxy = self._message_bus.proxy
        bus_proxy.StartServiceByName.assert_called_once_with(
            "org.fedoraproject.Anaconda.Modules.A",
            DBUS_FLAG_NONE,
            callback=task._start_service_by_name_callback,
            callback_args=(observer, ))

        gio.bus_watch_name_on_connection.assert_called_once()
        observer.proxy.Ping.assert_called_once_with()
示例#15
0
 def test_start_no_modules(self):
     """Start no modules."""
     task = StartModulesTask(self._message_bus, [], addons_enabled=False)
     self._check_started_modules(task, [])
示例#16
0
 def test_start_no_modules(self):
     """Start no modules."""
     task = StartModulesTask(self._message_bus, [], [], [])
     self._check_started_modules(task, [])