class URLSourceTestCase(unittest.TestCase): """Test the URL source module.""" def setUp(self): self.module = URLSourceModule() def ready_state_test(self): """Check ready state of URL source. It will be always True there is no state. """ self.assertTrue(self.module.get_state()) def set_up_with_tasks_test(self): """Get set up tasks for url source. No task is required. Will be an empty list. """ self.assertEqual(self.module.set_up_with_tasks(), []) def tear_down_with_tasks_test(self): """Get tear down tasks for url source. No task is required. Will be an empty list. """ self.assertEqual(self.module.tear_down_with_tasks(), [])
def test_name_uniqueness_properties(self): module1 = URLSourceModule() interface1 = URLSourceInterface(module1) module2 = URLSourceModule() interface2 = URLSourceInterface(module2) conf1 = RepoConfigurationData.from_structure(interface1.RepoConfiguration) conf2 = RepoConfigurationData.from_structure(interface2.RepoConfiguration) assert conf1.name != conf2.name
class URLSourceTestCase(unittest.TestCase): """Test the URL source module.""" def setUp(self): self.module = URLSourceModule() def test_network_required(self): """Test the property network_required.""" assert self.module.network_required is False self.module.repo_configuration.url = "http://my/path" assert self.module.network_required is True self.module.repo_configuration.url = "https://my/path" assert self.module.network_required is True self.module.repo_configuration.url = "file://my/path" assert self.module.network_required is False self.module.repo_configuration.url = "ftp://my/path" assert self.module.network_required is True def test_required_space(self): """Test the required_space property.""" assert self.module.required_space == 0 def test_ready_state(self): """Check ready state of URL source. It will be always True there is no state. """ assert self.module.get_state() def test_set_up_with_tasks(self): """Get set up tasks for url source. No task is required. Will be an empty list. """ assert self.module.set_up_with_tasks() == [] def test_tear_down_with_tasks(self): """Get tear down tasks for url source. No task is required. Will be an empty list. """ assert self.module.tear_down_with_tasks() == [] def test_repr(self): config = RepoConfigurationData() config.url = "http://some.example.com/repository" self.module.set_repo_configuration(config) assert repr(self.module) == \ "Source(type='URL', url='http://some.example.com/repository')"
def name_uniqueness_properties_test(self): module1 = URLSourceModule() interface1 = URLSourceInterface(module1) module2 = URLSourceModule() interface2 = URLSourceInterface(module2) conf1 = RepoConfigurationData.from_structure( interface1.RepoConfiguration) conf2 = RepoConfigurationData.from_structure( interface2.RepoConfiguration) self.assertNotEqual(conf1.name, conf2.name)
class URLSourceTestCase(unittest.TestCase): """Test the URL source module.""" def setUp(self): self.module = URLSourceModule() def network_required_test(self): """Test the property network_required.""" self.assertEqual(self.module.network_required, False) self.module.repo_configuration.url = "http://my/path" self.assertEqual(self.module.network_required, True) self.module.repo_configuration.url = "https://my/path" self.assertEqual(self.module.network_required, True) self.module.repo_configuration.url = "file://my/path" self.assertEqual(self.module.network_required, False) self.module.repo_configuration.url = "ftp://my/path" self.assertEqual(self.module.network_required, True) def ready_state_test(self): """Check ready state of URL source. It will be always True there is no state. """ self.assertTrue(self.module.get_state()) def set_up_with_tasks_test(self): """Get set up tasks for url source. No task is required. Will be an empty list. """ self.assertEqual(self.module.set_up_with_tasks(), []) def tear_down_with_tasks_test(self): """Get tear down tasks for url source. No task is required. Will be an empty list. """ self.assertEqual(self.module.tear_down_with_tasks(), []) def repr_test(self): config = RepoConfigurationData() config.url = "http://some.example.com/repository" self.module.set_repo_configuration(config) self.assertEqual( repr(self.module), "Source(type='URL', url='http://some.example.com/repository')")
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))
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))
def setUp(self): URLSourceModule.REPO_NAME_ID = 0 self.url_source_module = URLSourceModule() self.url_source_interface = URLSourceInterface(self.url_source_module)
def setUp(self): self.module = URLSourceModule()