Ejemplo n.º 1
0
class LiveOSSourceTestCase(unittest.TestCase):
    def setUp(self):
        self.module = LiveOSSourceModule()

    def set_up_with_tasks_test(self):
        """Test Live OS Source set up call."""
        task_classes = [SetUpLiveOSSourceTask]

        # task will not be public so it won't be published
        tasks = self.module.set_up_with_tasks()

        # Check the number of the tasks
        task_number = len(task_classes)
        self.assertEqual(task_number, len(tasks))

        for i in range(task_number):
            self.assertIsInstance(tasks[i], task_classes[i])

    def tear_down_with_tasks_test(self):
        """Test Live OS Source ready state for tear down."""
        task_classes = [TearDownMountTask]

        # task will not be public so it won't be published
        tasks = self.module.tear_down_with_tasks()

        # check the number of tasks
        task_number = len(task_classes)
        self.assertEqual(task_number, len(tasks))

        for i in range(task_number):
            self.assertIsInstance(tasks[i], task_classes[i])
class LiveOSSourceTestCase(unittest.TestCase):
    def setUp(self):
        self.live_os_source_module = LiveOSSourceModule()

    def type_test(self):
        """Test Live OS source module has a correct type."""
        self.assertEqual(SourceType.LIVE_OS_IMAGE,
                         self.live_os_source_module.type)

    def set_up_with_tasks_test(self):
        """Test Live OS Source set up call."""
        task_classes = [SetUpLiveOSSourceTask]

        # task will not be public so it won't be published
        tasks = self.live_os_source_module.set_up_with_tasks()

        # Check the number of the tasks
        task_number = len(task_classes)
        self.assertEqual(task_number, len(tasks))

        for i in range(task_number):
            self.assertIsInstance(tasks[i], task_classes[i])

    def tear_down_with_tasks_test(self):
        """Test Live OS Source ready state for tear down."""
        task_classes = [TearDownLiveOSSourceTask]

        # task will not be public so it won't be published
        tasks = self.live_os_source_module.tear_down_with_tasks()

        # check the number of tasks
        task_number = len(task_classes)
        self.assertEqual(task_number, len(tasks))

        for i in range(task_number):
            self.assertIsInstance(tasks[i], task_classes[i])

    @patch("os.path.ismount")
    def ready_state_test(self, ismount):
        """Test Live OS Source ready state for set up."""
        ismount.return_value = False
        self.assertFalse(self.live_os_source_module.is_ready())

        ismount.reset_mock()
        ismount.return_value = True

        self.assertTrue(self.live_os_source_module.is_ready())

        ismount.assert_called_once_with(INSTALL_TREE)
    def setUp(self):
        self.live_os_source_module = LiveOSSourceModule()
        self.live_os_source_interface = LiveOSSourceInterface(
            self.live_os_source_module)

        self.callback = PropertiesChangedCallback()
        self.live_os_source_interface.PropertiesChanged.connect(self.callback)
Ejemplo n.º 4
0
    def create_source(source_type: SourceType):
        """Create a source module.

        :param source_type: a source type
        :return: a source module
        """
        if source_type == SourceType.LIVE_OS_IMAGE:
            from pyanaconda.modules.payloads.source.live_os.live_os import LiveOSSourceModule
            return LiveOSSourceModule()
        elif source_type == SourceType.CDROM:
            from pyanaconda.modules.payloads.source.cdrom.cdrom import CdromSourceModule
            return CdromSourceModule()
        elif source_type == SourceType.HMC:
            from pyanaconda.modules.payloads.source.hmc.hmc import HMCSourceModule
            return HMCSourceModule()
        elif source_type == SourceType.REPO_FILES:
            from pyanaconda.modules.payloads.source.repo_files.repo_files import \
                RepoFilesSourceModule
            return RepoFilesSourceModule()
        elif source_type == SourceType.NFS:
            from pyanaconda.modules.payloads.source.nfs.nfs import NFSSourceModule
            return NFSSourceModule()
        elif source_type == SourceType.URL:
            from pyanaconda.modules.payloads.source.url.url import URLSourceModule
            return URLSourceModule()
        elif source_type == SourceType.HDD:
            from pyanaconda.modules.payloads.source.harddrive.harddrive import \
                HardDriveSourceModule
            return HardDriveSourceModule()

        raise ValueError("Unknown source type: {}".format(source_type))
Ejemplo n.º 5
0
    def create_source(source_type: SourceType):
        """Create a source module.

        :param source_type: a source type
        :return: a source module
        """
        if source_type == SourceType.LIVE_OS_IMAGE:
            from pyanaconda.modules.payloads.source.live_os.live_os import LiveOSSourceModule
            return LiveOSSourceModule()

        raise ValueError("Unknown source type: {}".format(source_type))
Ejemplo n.º 6
0
    def create_source(source_type: SourceType):
        """Create a source module.

        :param source_type: a source type
        :return: a source module
        """
        if source_type == SourceType.LIVE_OS_IMAGE:
            from pyanaconda.modules.payloads.source.live_os.live_os import LiveOSSourceModule
            return LiveOSSourceModule()
        elif source_type == SourceType.LIVE_IMAGE:
            from pyanaconda.modules.payloads.source.live_image.live_image import \
                LiveImageSourceModule
            return LiveImageSourceModule()
        elif source_type == SourceType.LIVE_TAR:
            from pyanaconda.modules.payloads.source.live_tar.live_tar import LiveTarSourceModule
            return LiveTarSourceModule()
        elif source_type == SourceType.CDROM:
            from pyanaconda.modules.payloads.source.cdrom.cdrom import CdromSourceModule
            return CdromSourceModule()
        elif source_type == SourceType.HMC:
            from pyanaconda.modules.payloads.source.hmc.hmc import HMCSourceModule
            return HMCSourceModule()
        elif source_type == SourceType.REPO_FILES:
            from pyanaconda.modules.payloads.source.repo_files.repo_files import \
                RepoFilesSourceModule
            return RepoFilesSourceModule()
        elif source_type == SourceType.NFS:
            from pyanaconda.modules.payloads.source.nfs.nfs import NFSSourceModule
            return NFSSourceModule()
        elif source_type == SourceType.URL:
            from pyanaconda.modules.payloads.source.url.url import URLSourceModule
            return URLSourceModule()
        elif source_type == SourceType.HDD:
            from pyanaconda.modules.payloads.source.harddrive.harddrive import \
                HardDriveSourceModule
            return HardDriveSourceModule()
        elif source_type == SourceType.CDN:
            from pyanaconda.modules.payloads.source.cdn.cdn import CDNSourceModule
            return CDNSourceModule()
        elif source_type == SourceType.CLOSEST_MIRROR:
            from pyanaconda.modules.payloads.source.closest_mirror.closest_mirror import \
                ClosestMirrorSourceModule
            return ClosestMirrorSourceModule()
        elif source_type == SourceType.RPM_OSTREE:
            from pyanaconda.modules.payloads.source.rpm_ostree.rpm_ostree import \
                RPMOSTreeSourceModule
            return RPMOSTreeSourceModule()
        elif source_type == SourceType.FLATPAK:
            from pyanaconda.modules.payloads.source.flatpak.flatpak import \
                FlatpakSourceModule
            return FlatpakSourceModule()

        raise ValueError("Unknown source type: {}".format(source_type))
Ejemplo n.º 7
0
class LiveOSSourceTestCase(unittest.TestCase):
    def setUp(self):
        self.module = LiveOSSourceModule()

    def test_network_required(self):
        """Test the property network_required."""
        self.assertEqual(self.module.network_required, False)

    def test_required_space(self):
        """Test the required_space property."""
        self.assertEqual(self.module.required_space, 0)

    @patch("os.path.ismount")
    def test_get_state(self, ismount_mock):
        """Test LiveOS source state."""
        ismount_mock.return_value = False
        self.assertEqual(SourceState.UNREADY, self.module.get_state())

        ismount_mock.reset_mock()
        ismount_mock.return_value = True

        self.assertEqual(SourceState.READY, self.module.get_state())

        ismount_mock.assert_called_once_with(self.module.mount_point)

    def test_set_up_with_tasks(self):
        """Test Live OS Source set up call."""
        task_classes = [SetUpLiveOSSourceTask]

        # task will not be public so it won't be published
        tasks = self.module.set_up_with_tasks()

        # Check the number of the tasks
        task_number = len(task_classes)
        self.assertEqual(task_number, len(tasks))

        for i in range(task_number):
            self.assertIsInstance(tasks[i], task_classes[i])

    def test_tear_down_with_tasks(self):
        """Test Live OS Source ready state for tear down."""
        task_classes = [TearDownMountTask]

        # task will not be public so it won't be published
        tasks = self.module.tear_down_with_tasks()

        # check the number of tasks
        task_number = len(task_classes)
        self.assertEqual(task_number, len(tasks))

        for i in range(task_number):
            self.assertIsInstance(tasks[i], task_classes[i])

    def test_repr(self):
        self.module.set_image_path("/some/path")
        self.assertEqual(repr(self.module),
                         "Source(type='LIVE_OS_IMAGE', image='/some/path')")
class LiveOSSourceTestCase(unittest.TestCase):
    """Test the Live OS source."""
    def setUp(self):
        self.module = LiveOSSourceModule()

    def test_network_required(self):
        """Test the network_required property."""
        assert self.module.network_required is False

    def test_required_space(self):
        """Test the required_space property."""
        assert self.module.required_space > 0

    @patch("os.path.ismount")
    def test_get_state(self, ismount_mock):
        """Test the source state."""
        ismount_mock.return_value = False
        assert SourceState.UNREADY == self.module.get_state()

        ismount_mock.reset_mock()
        ismount_mock.return_value = True

        assert SourceState.READY == self.module.get_state()
        ismount_mock.assert_called_once_with(self.module.mount_point)

    def test_set_up_with_tasks(self):
        """Test the set up tasks."""
        tasks = self.module.set_up_with_tasks()
        assert len(tasks) == 1
        assert isinstance(tasks[0], SetUpLiveOSSourceTask)

    def test_tear_down_with_tasks(self):
        """Test the tear down tasks."""
        tasks = self.module.tear_down_with_tasks()
        assert len(tasks) == 1
        assert isinstance(tasks[0], TearDownMountTask)

    def test_repr(self):
        """Test the string representation."""
        self.module.set_image_path("/some/path")
        assert repr(
            self.module) == "Source(type='LIVE_OS_IMAGE', image='/some/path')"
 def setUp(self):
     self.module = LiveOSSourceModule()
Ejemplo n.º 10
0
 def setUp(self):
     self.module = LiveOSSourceModule()
     self.interface = LiveOSSourceInterface(self.module)
Ejemplo n.º 11
0
 def _create(cls, object_type):
     if object_type == SourceType.LIVE_OS_IMAGE:
         from pyanaconda.modules.payloads.source.live_os.live_os import LiveOSSourceModule
         return LiveOSSourceModule()
Ejemplo n.º 12
0
 def setUp(self):
     self.live_os_source_module = LiveOSSourceModule()