Beispiel #1
0
    def setUp(self):
        self.module = RPMOSTreeModule()
        self.interface = RPMOSTreeInterface(self.module)

        self.shared_tests = PayloadSharedTest(test=self,
                                              payload=self.module,
                                              payload_intf=self.interface)
Beispiel #2
0
    def create_payload(payload_type: PayloadType):
        """Create a partitioning module.

        :param payload_type: a payload type
        :return: a payload module
        """
        if payload_type == PayloadType.LIVE_IMAGE:
            from pyanaconda.modules.payloads.payload.live_image.live_image import \
                LiveImageModule
            return LiveImageModule()

        if payload_type == PayloadType.LIVE_OS:
            from pyanaconda.modules.payloads.payload.live_os.live_os import LiveOSModule
            return LiveOSModule()

        if payload_type == PayloadType.DNF:
            from pyanaconda.modules.payloads.payload.dnf.dnf import DNFModule
            return DNFModule()

        if payload_type == PayloadType.RPM_OSTREE:
            from pyanaconda.modules.payloads.payload.rpm_ostree.rpm_ostree import RPMOSTreeModule
            return RPMOSTreeModule()

        raise ValueError("Unknown payload type: {}".format(payload_type))
Beispiel #3
0
 def setUp(self):
     self.maxDiff = None
     self.module = RPMOSTreeModule()
Beispiel #4
0
class RPMOSTreeModuleTestCase(unittest.TestCase):
    """Test the RPM OSTree module."""
    def setUp(self):
        self.maxDiff = None
        self.module = RPMOSTreeModule()

    def _assert_is_instance_list(self, objects, classes):
        """Check if objects are instances of classes."""
        self.assertEqual(len(objects), len(classes))

        for obj, cls in zip(objects, classes):
            self.assertIsInstance(obj, cls)

    def test_get_kernel_version_list(self):
        """Test the get_kernel_version_list method."""
        self.assertEqual(self.module.get_kernel_version_list(), [])

    def test_install_with_tasks(self):
        """Test the install_with_tasks method."""
        self.assertEqual(self.module.install_with_tasks(), [])

        rpm_source = SourceFactory.create_source(SourceType.RPM_OSTREE)
        self.module.set_sources([rpm_source])

        tasks = self.module.install_with_tasks()
        self._assert_is_instance_list(tasks, [
            InitOSTreeFsAndRepoTask,
            ChangeOSTreeRemoteTask,
            PullRemoteAndDeleteTask,
            DeployOSTreeTask,
            SetSystemRootTask,
            CopyBootloaderDataTask,
            PrepareOSTreeMountTargetsTask,
        ])

        flatpak_source = SourceFactory.create_source(SourceType.FLATPAK)
        self.module.set_sources([rpm_source, flatpak_source])

        tasks = self.module.install_with_tasks()
        self._assert_is_instance_list(tasks, [
            InitOSTreeFsAndRepoTask,
            ChangeOSTreeRemoteTask,
            PullRemoteAndDeleteTask,
            DeployOSTreeTask,
            SetSystemRootTask,
            CopyBootloaderDataTask,
            PrepareOSTreeMountTargetsTask,
            InstallFlatpaksTask,
        ])

    def test_collect_mount_points(self):
        """Collect mount points from successful tasks."""
        rpm_source = SourceFactory.create_source(SourceType.RPM_OSTREE)
        self.module.set_sources([rpm_source])
        tasks = self.module.install_with_tasks()

        for task in tasks:
            # Fake the task results.
            task_id = task.__class__.__name__
            task._set_result(
                ["/path/{}/1".format(task_id), "/path/{}/2".format(task_id)])

            # Fake the task run.
            task.succeeded_signal.emit()

        self.assertEqual(self.module._internal_mounts, [
            "/path/PrepareOSTreeMountTargetsTask/1",
            "/path/PrepareOSTreeMountTargetsTask/2"
        ])

    def test_post_install_with_tasks(self):
        """Test the post_install_with_tasks method."""
        self.assertEqual(self.module.post_install_with_tasks(), [])

        rpm_source = SourceFactory.create_source(SourceType.RPM_OSTREE)
        self.module.set_sources([rpm_source])

        tasks = self.module.post_install_with_tasks()
        self._assert_is_instance_list(tasks, [
            ChangeOSTreeRemoteTask,
            ConfigureBootloader,
        ])

    def test_tear_down_with_tasks(self):
        """Test the tear_down_with_tasks method."""
        rpm_source = SourceFactory.create_source(SourceType.RPM_OSTREE)

        self.module.set_sources([rpm_source])
        self.module._add_internal_mounts(["/path/1", "/path/2"])

        tasks = self.module.tear_down_with_tasks()

        self._assert_is_instance_list(
            tasks, [TearDownSourcesTask, TearDownOSTreeMountTargetsTask])

        self.assertEqual(tasks[0]._sources, [rpm_source])
        self.assertEqual(tasks[1]._internal_mounts, ["/path/1", "/path/2"])
 def setUp(self):
     self.module = RPMOSTreeModule()
     self.interface = RPMOSTreeInterface(self.module)