예제 #1
0
    def setUp(self):
        self.live_image_module = LiveImageModule()
        self.live_image_interface = LiveImageInterface(self.live_image_module)

        self.shared_tests = PayloadSharedTest(
            self,
            payload=self.live_image_module,
            payload_intf=self.live_image_interface)
    def setUp(self):
        self.live_image_module = LiveImageModule()
        self.live_image_interface = LiveImageInterface(self.live_image_module)

        self.source_tests = SourceSharedTest(
            self,
            payload=self.live_image_module,
            payload_intf=self.live_image_interface)

        self.callback = PropertiesChangedCallback()
        self.live_image_interface.PropertiesChanged.connect(self.callback)
예제 #3
0
 def _create(cls, object_type):
     if object_type == PayloadType.LIVE_IMAGE:
         from pyanaconda.modules.payloads.payload.live_image.live_image import \
             LiveImageModule
         return LiveImageModule()
     elif object_type == PayloadType.LIVE_OS:
         from pyanaconda.modules.payloads.payload.live_os.live_os import LiveOSModule
         return LiveOSModule()
     elif object_type == PayloadType.DNF:
         from pyanaconda.modules.payloads.payload.dnf.dnf import DNFModule
         return DNFModule()
class LiveImageModuleTestCase(unittest.TestCase):
    def setUp(self):
        self.module = LiveImageModule()

    def test_calculate_required_space(self):
        """Test the calculate_required_space method."""
        self.assertEqual(self.module.calculate_required_space(), 0)

        source = SourceFactory.create_source(SourceType.LIVE_IMAGE)
        self.module.add_source(source)

        self.assertEqual(self.module.calculate_required_space(),
                         1024 * 1024 * 1024)

    def test_install_with_task_from_tar(self):
        """Test Live Image install with tasks from tarfile."""
        # task_path = self.live_image_interface.PreInstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [SetupInstallationSourceImageTask])

        # task_path = self.live_image_interface.InstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [InstallFromTarTask])
        self.assertEqual(self.module.install_with_tasks(), [])

    @patch_dbus_publish_object
    def test_install_with_task_from_image(self, publisher):
        """Test Live Image install with tasks from image."""
        # task_path = self.live_image_interface.PreInstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [SetupInstallationSourceImageTask])

        # task_path = self.live_image_interface.InstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [InstallFromImageTask])
        self.assertEqual(self.module.install_with_tasks(), [])

    @patch_dbus_publish_object
    def test_post_install_with_tasks(self, publisher):
        """Test Live Image post installation configuration task."""
        # task_classes = [
        #     TeardownInstallationSourceImageTask
        # ]
        #
        # task_paths = self.live_image_interface.PostInstallWithTasks()
        #
        # # Check the number of installation tasks.
        # task_number = len(task_classes)
        # self.assertEqual(task_number, len(task_paths))
        # self.assertEqual(task_number, publisher.call_count)
        #
        # # Check the tasks.
        # for i in range(task_number):
        #     object_path, obj = publisher.call_args_list[i][0]
        #     self.assertEqual(object_path, task_paths[i])
        #     self.assertIsInstance(obj, TaskInterface)
        #     self.assertIsInstance(obj.implementation, task_classes[i])
        self.assertEqual(self.module.post_install_with_tasks(), [])
예제 #5
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()

        raise ValueError("Unknown payload type: {}".format(payload_type))
예제 #6
0
class LiveImageInterfaceTestCase(unittest.TestCase):
    def setUp(self):
        self.live_image_module = LiveImageModule()
        self.live_image_interface = LiveImageInterface(self.live_image_module)

        self.shared_tests = PayloadSharedTest(
            self,
            payload=self.live_image_module,
            payload_intf=self.live_image_interface)

    def type_test(self):
        self.shared_tests.check_type(PayloadType.LIVE_IMAGE)

    def calculate_required_space_test(self):
        """Test CalculateRequiredTest."""
        self.assertEqual(self.live_image_interface.CalculateRequiredSpace(), 0)

        source = SourceFactory.create_source(SourceType.LIVE_IMAGE)
        self.live_image_module.add_source(source)

        self.assertEqual(self.live_image_interface.CalculateRequiredSpace(),
                         1024 * 1024 * 1024)

    # TODO: Add set_source and supported_sources like in Live OS payload when source is available

    @patch_dbus_publish_object
    def prepare_system_for_installation_task_test(self, publisher):
        """Test Live Image is able to create a prepare installation task."""
        # task_path = self.live_image_interface.PreInstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [SetupInstallationSourceImageTask])
        self.assertEqual(self.live_image_interface.PreInstallWithTasks(), [])

    @patch_dbus_publish_object
    def install_with_task_from_tar_test(self, publisher):
        """Test Live Image install with tasks from tarfile."""
        # task_path = self.live_image_interface.InstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [InstallFromTarTask])
        self.assertEqual(self.live_image_interface.InstallWithTasks(), [])

    @patch_dbus_publish_object
    def install_with_task_from_image_test(self, publisher):
        """Test Live Image install with tasks from image."""
        # task_path = self.live_image_interface.InstallWithTasks()
        # check_task_creation_list(self, task_path, publisher, [InstallFromImageTask])
        self.assertEqual(self.live_image_interface.InstallWithTasks(), [])

    @patch_dbus_publish_object
    def post_install_with_tasks_test(self, publisher):
        """Test Live Image post installation configuration task."""
        # task_classes = [
        #     UpdateBLSConfigurationTask,
        #     CopyDriverDisksFilesTask,
        #     TeardownInstallationSourceImageTask
        # ]
        #
        # task_paths = self.live_image_interface.PostInstallWithTasks()
        #
        # # Check the number of installation tasks.
        # task_number = len(task_classes)
        # self.assertEqual(task_number, len(task_paths))
        # self.assertEqual(task_number, publisher.call_count)
        #
        # # Check the tasks.
        # for i in range(task_number):
        #     object_path, obj = publisher.call_args_list[i][0]
        #     self.assertEqual(object_path, task_paths[i])
        #     self.assertIsInstance(obj, TaskInterface)
        #     self.assertIsInstance(obj.implementation, task_classes[i])
        self.assertEqual(self.live_image_interface.PostInstallWithTasks(), [])
 def setUp(self):
     self.module = LiveImageModule()
예제 #8
0
class LiveImageModuleTestCase(unittest.TestCase):
    def setUp(self):
        self.module = LiveImageModule()

    def test_multiple_sources(self):
        """The live image payload cannot have multiple sources."""
        sources = [
            SourceFactory.create_source(SourceType.LIVE_IMAGE),
            SourceFactory.create_source(SourceType.LIVE_IMAGE)
        ]

        with pytest.raises(IncompatibleSourceError) as cm:
            self.module.set_sources(sources)

        assert str(
            cm.value) == "You can set only one source for this payload type."

    def test_calculate_required_space(self):
        """Test the calculate_required_space method."""
        assert self.module.calculate_required_space() == 0

        source = SourceFactory.create_source(SourceType.LIVE_IMAGE)
        self.module.add_source(source)

        assert self.module.calculate_required_space() == 1024 * 1024 * 1024

    def test_install_with_task_from_tar(self):
        """Test installation tasks with a tarfile."""
        assert self.module.install_with_tasks() == []

        source = SourceFactory.create_source(SourceType.LIVE_TAR)
        self.module.add_source(source)

        tasks = self.module.install_with_tasks()
        assert len(tasks) == 1
        assert isinstance(tasks[0], InstallLiveTarTask)

    def test_install_with_task_from_image(self):
        """Test installation tasks with an image."""
        assert self.module.install_with_tasks() == []

        source = SourceFactory.create_source(SourceType.LIVE_IMAGE)
        self.module.add_source(source)

        tasks = self.module.install_with_tasks()
        assert len(tasks) == 1
        assert isinstance(tasks[0], InstallLiveImageTask)

    def test_post_install_with_tasks(self):
        """Test post-installation tasks."""
        assert self.module.post_install_with_tasks() == []
예제 #9
0
 def setUp(self):
     self.module = LiveImageModule()
     self.interface = LiveImageInterface(self.module)
예제 #10
0
 def setUp(self):
     self.module = LiveImageModule()
     self.interface = LiveImageInterface(self.module)
     self.shared_tests = PayloadSharedTest(self.module, self.interface)