class HMCSourceModuleTestCase(unittest.TestCase):
    """Test the SE/HMC source module."""
    def setUp(self):
        self.module = HMCSourceModule()

    @patch("os.path.ismount")
    def ready_state_test(self, ismount):
        """Check whether SE/HMC is ready."""
        ismount.return_value = False
        self.assertFalse(self.module.is_ready())

        ismount.reset_mock()
        ismount.return_value = True

        self.assertTrue(self.module.is_ready())
        ismount.assert_called_once_with(INSTALL_TREE)

    def set_up_with_tasks_test(self):
        """Get tasks to set up SE/HMC."""
        tasks = self.module.set_up_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, SetUpHMCSourceTask)
        self.assertEqual(task._target_mount, INSTALL_TREE)

    def tear_down_with_tasks_test(self):
        """Get tasks to tear down SE/HMC."""
        tasks = self.module.tear_down_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, TearDownHMCSourceTask)
Exemple #2
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))
Exemple #3
0
class HMCSourceModuleTestCase(unittest.TestCase):
    """Test the SE/HMC source module."""
    def setUp(self):
        self.module = HMCSourceModule()

    def test_network_required(self):
        """Test the property network_required."""
        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 SE/HMC 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):
        """Get tasks to set up SE/HMC."""
        tasks = self.module.set_up_with_tasks()
        assert len(tasks) == 1

        task = tasks[0]
        assert isinstance(task, SetUpHMCSourceTask)
        assert task._target_mount == self.module.mount_point

    def test_tear_down_with_tasks(self):
        """Get tasks to tear down SE/HMC."""
        tasks = self.module.tear_down_with_tasks()
        assert len(tasks) == 1

        task = tasks[0]
        assert isinstance(task, TearDownMountTask)

    def test_repr(self):
        assert repr(self.module) == "Source(type='HMC')"
Exemple #4
0
class HMCSourceModuleTestCase(unittest.TestCase):
    """Test the SE/HMC source module."""
    def setUp(self):
        self.module = HMCSourceModule()

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

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

    @patch("os.path.ismount")
    def get_state_test(self, ismount_mock):
        """Test SE/HMC 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 set_up_with_tasks_test(self):
        """Get tasks to set up SE/HMC."""
        tasks = self.module.set_up_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, SetUpHMCSourceTask)
        self.assertEqual(task._target_mount, self.module.mount_point)

    def tear_down_with_tasks_test(self):
        """Get tasks to tear down SE/HMC."""
        tasks = self.module.tear_down_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, TearDownMountTask)

    def repr_test(self):
        self.assertEqual(repr(self.module), "Source(type='HMC')")
Exemple #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()
        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))
class HMCSourceModuleTestCase(unittest.TestCase):
    """Test the SE/HMC source module."""
    def setUp(self):
        self.module = HMCSourceModule()

    def set_up_with_tasks_test(self):
        """Get tasks to set up SE/HMC."""
        tasks = self.module.set_up_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, SetUpHMCSourceTask)
        self.assertEqual(task._target_mount, self.module.mount_point)

    def tear_down_with_tasks_test(self):
        """Get tasks to tear down SE/HMC."""
        tasks = self.module.tear_down_with_tasks()
        self.assertEqual(len(tasks), 1)

        task = tasks[0]
        self.assertIsInstance(task, TearDownMountTask)
Exemple #7
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()

        if source_type == SourceType.HMC:
            from pyanaconda.modules.payloads.source.hmc.hmc import HMCSourceModule
            return HMCSourceModule()

        raise ValueError("Unknown source type: {}".format(source_type))
Exemple #8
0
 def setUp(self):
     self.module = HMCSourceModule()
Exemple #9
0
 def setUp(self):
     self.module = HMCSourceModule()
     self.interface = HMCSourceInterface(self.module)