Esempio n. 1
0
class OSTreeSourceTestCase(unittest.TestCase):
    """Test the OSTree source module."""

    def setUp(self):
        self.module = RPMOSTreeSourceModule()

    def test_type(self):
        """Test the type property."""
        assert SourceType.RPM_OSTREE == self.module.type

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

        self.module.configuration.url = "file://my/path"
        assert self.module.network_required is False

        self.module.configuration.url = "http://my/path"
        assert self.module.network_required is True

        self.module.configuration.url = "https://my/path"
        assert self.module.network_required is True

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

    def test_get_state(self):
        """Test the source state."""
        assert SourceState.NOT_APPLICABLE == self.module.get_state()

    def test_set_up_with_tasks(self):
        """Test the set-up tasks."""
        assert self.module.set_up_with_tasks() == []

    def test_tear_down_with_tasks(self):
        """Test the tear-down tasks."""
        assert self.module.tear_down_with_tasks() == []

    def test_repr(self):
        """Test the string representation."""
        assert repr(self.module) == str(
            "Source("
            "type='RPM_OSTREE', "
            "osname='', "
            "url=''"
            ")"
        )

        self.module.configuration.osname = "fedora-atomic"
        self.module.configuration.url = "https://kojipkgs.fedoraproject.org/atomic/repo"

        assert repr(self.module) == str(
            "Source("
            "type='RPM_OSTREE', "
            "osname='fedora-atomic', "
            "url='https://kojipkgs.fedoraproject.org/atomic/repo'"
            ")"
        )
Esempio n. 2
0
class OSTreeSourceTestCase(unittest.TestCase):
    """Test the OSTree source module."""
    def setUp(self):
        self.module = RPMOSTreeSourceModule()

    def type_test(self):
        """Test the type property."""
        self.assertEqual(SourceType.RPM_OSTREE, self.module.type)

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

        self.module.configuration.url = "file://my/path"
        self.assertEqual(self.module.network_required, False)

        self.module.configuration.url = "http://my/path"
        self.assertEqual(self.module.network_required, True)

        self.module.configuration.url = "https://my/path"
        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 get_state_test(self):
        """Test the source state."""
        self.assertEqual(SourceState.NOT_APPLICABLE, self.module.get_state())

    def set_up_with_tasks_test(self):
        """Test the set-up tasks."""
        self.assertEqual(self.module.set_up_with_tasks(), [])

    def tear_down_with_tasks_test(self):
        """Test the tear-down tasks."""
        self.assertEqual(self.module.tear_down_with_tasks(), [])

    def repr_test(self):
        """Test the string representation."""
        self.assertEqual(
            repr(self.module),
            str("Source("
                "type='RPM_OSTREE', "
                "osname='', "
                "url=''"
                ")"))

        self.module.configuration.osname = "fedora-atomic"
        self.module.configuration.url = "https://kojipkgs.fedoraproject.org/atomic/repo"

        self.assertEqual(
            repr(self.module),
            str("Source("
                "type='RPM_OSTREE', "
                "osname='fedora-atomic', "
                "url='https://kojipkgs.fedoraproject.org/atomic/repo'"
                ")"))
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.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))
Esempio n. 4
0
class OSTreeSourceTestCase(unittest.TestCase):
    """Test the OSTree source module."""
    def setUp(self):
        self.module = RPMOSTreeSourceModule()

    def type_test(self):
        """Test the type property."""
        self.assertEqual(SourceType.RPM_OSTREE, self.module.type)

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

    def get_state_test(self):
        """Test the source state."""
        self.assertEqual(SourceState.NOT_APPLICABLE, self.module.get_state())

    def set_up_with_tasks_test(self):
        """Test the set-up tasks."""
        self.assertEqual(self.module.set_up_with_tasks(), [])

    def tear_down_with_tasks_test(self):
        """Test the tear-down tasks."""
        self.assertEqual(self.module.tear_down_with_tasks(), [])
Esempio n. 5
0
 def setUp(self):
     self.module = RPMOSTreeSourceModule()
Esempio n. 6
0
 def setUp(self):
     self.module = RPMOSTreeSourceModule()
     self.interface = RPMOSTreeSourceInterface(self.module)