class RepoFilesSourceTestCase(unittest.TestCase):

    def setUp(self):
        self.module = RepoFilesSourceModule()
        self.interface = RepoFilesSourceInterface(self.module)

    def test_type(self):
        """Test Repo files source module has a correct type."""
        assert SourceType.REPO_FILES == self.module.type

    def test_network_required(self):
        """Test the property network_required."""
        assert self.module.network_required == True

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

    def test_repr(self):
        assert repr(self.module) == "Source(type='REPO_FILES')"

    def test_set_up_with_tasks(self):
        """Test Repo files Source set up call."""
        tasks = self.module.set_up_with_tasks()
        assert len(tasks) == 1
        assert isinstance(tasks[0], SetUpRepoFilesSourceTask)

    def test_tear_down_with_tasks(self):
        """Test Repo files Source ready state for tear down."""
        tasks = self.module.tear_down_with_tasks()
        assert [] == tasks

    def test_ready_state(self):
        """Test Repo files Source ready state for set up."""
        assert self.module.get_state()
class RepoFilesSourceTestCase(unittest.TestCase):

    def setUp(self):
        self.module = RepoFilesSourceModule()
        self.interface = RepoFilesSourceInterface(self.module)

    def type_test(self):
        """Test Repo files source module has a correct type."""
        self.assertEqual(SourceType.REPO_FILES, self.module.type)

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

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

    def repr_test(self):
        self.assertEqual(repr(self.module), "Source(type='REPO_FILES')")

    def set_up_with_tasks_test(self):
        """Test Repo files Source set up call."""
        tasks = self.module.set_up_with_tasks()
        self.assertEqual(len(tasks), 1)
        self.assertIsInstance(tasks[0], SetUpRepoFilesSourceTask)

    def tear_down_with_tasks_test(self):
        """Test Repo files Source ready state for tear down."""
        tasks = self.module.tear_down_with_tasks()
        self.assertEqual([], tasks)

    def ready_state_test(self):
        """Test Repo files Source ready state for set up."""
        self.assertTrue(self.module.get_state())
Esempio n. 3
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))
Esempio 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.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 RepoFilesSourceTestCase(unittest.TestCase):
    def setUp(self):
        self.module = RepoFilesSourceModule()
        self.interface = RepoFilesSourceInterface(self.module)

    def type_test(self):
        """Test Repo files source module has a correct type."""
        self.assertEqual(SourceType.REPO_FILES, self.module.type)

    def set_up_with_tasks_test(self):
        """Test Repo files Source set up call."""
        tasks = self.module.set_up_with_tasks()
        self.assertEqual(len(tasks), 1)
        self.assertIsInstance(tasks[0], SetUpRepoFilesSourceTask)

    def tear_down_with_tasks_test(self):
        """Test Repo files Source ready state for tear down."""
        tasks = self.module.tear_down_with_tasks()
        self.assertEqual([], tasks)

    def ready_state_test(self):
        """Test Repo files Source ready state for set up."""
        self.assertTrue(self.module.get_state())
 def setUp(self):
     self.module = RepoFilesSourceModule()
     self.interface = RepoFilesSourceInterface(self.module)