def test_generate_treeinfo_repositories_custom(self, mock_conf): """Test the generate_treeinfo_repositories function with custom repos.""" mock_conf.payload.enabled_repositories_from_treeinfo = ["variant"] root_url = self._load_treeinfo(TREE_INFO_CUSTOM) original = RepoConfigurationData() original.name = "anaconda" original.url = root_url generated = generate_treeinfo_repositories(original, self.metadata) optional = RepoConfigurationData() optional.origin = REPO_ORIGIN_TREEINFO optional.name = "MyOptional" optional.enabled = False optional.url = root_url + "/optional" variant = RepoConfigurationData() variant.origin = REPO_ORIGIN_TREEINFO variant.name = "MyVariant" variant.enabled = True variant.url = root_url + "/variant" # Anaconda ignores addons and child variants. self._assert_repo_list_equal(generated, [optional, variant])
def test_generate_treeinfo_repositories_fedora(self): """Test the generate_treeinfo_repositories function with Fedora repos.""" root_url = self._load_treeinfo(TREE_INFO_FEDORA) original = RepoConfigurationData() original.name = "anaconda" original.url = root_url original.proxy = "http://proxy" original.cost = 50 original.excluded_packages = ["p1", "p2"] original.included_packages = ["p2", "p3"] original.ssl_verification_enabled = False original.ssl_configuration.ca_cert_path = "file.cert" original.ssl_configuration.client_key_path = "client.key" original.ssl_configuration.client_cert_path = "client.cert" original.installation_enabled = True generated = generate_treeinfo_repositories(original, self.metadata) everything = RepoConfigurationData() everything.origin = REPO_ORIGIN_TREEINFO everything.name = "Everything" everything.enabled = True everything.url = root_url everything.proxy = "http://proxy" everything.cost = 50 everything.excluded_packages = ["p1", "p2"] everything.included_packages = ["p2", "p3"] everything.ssl_verification_enabled = False everything.ssl_configuration.ca_cert_path = "file.cert" everything.ssl_configuration.client_key_path = "client.key" everything.ssl_configuration.client_cert_path = "client.cert" everything.installation_enabled = False self._assert_repo_list_equal(generated, [everything])
def _reload_treeinfo_metadata(self, repo_data): """Reload treeinfo metadata. :param RepoConfigurationData repo_data: configuration data of the base repo :return: a URL of the base repository """ log.debug("Reload treeinfo metadata.") base_repo_url = None # Remove previous treeinfo repositories. removed_repos = self._remove_treeinfo_repositories() disabled_names = [r.name for r in removed_repos if not r.enabled] # Collect URLs of existing repositories. existing_urls = [ r.baseurl for r in self.data.repo.dataList() if r.baseurl ] try: # Load the treeinfo metadata. tree_info_metadata = TreeInfoMetadata() tree_info_metadata.load_data(repo_data) # Set up the substitutions. self._dnf_manager.configure_substitution( tree_info_metadata.release_version) # Get the new base repo URL. base_repo_url = tree_info_metadata.get_base_repo_url() existing_urls.append(base_repo_url) # Add the treeinfo repositories. repositories = generate_treeinfo_repositories( repo_data, tree_info_metadata) self._add_treeinfo_repositories( repositories=repositories, disabled_names=disabled_names, existing_urls=existing_urls, ) except NoTreeInfoError as e: log.debug("No treeinfo metadata to use: %s", str(e)) except TreeInfoMetadataError as e: log.warning("Couldn't use treeinfo metadata: %s", str(e)) return base_repo_url
def test_generate_treeinfo_repositories_rhel(self): """Test the generate_treeinfo_repositories function with RHEL repos.""" root_url = self._load_treeinfo(TREE_INFO_RHEL) original = RepoConfigurationData() original.name = "anaconda" original.url = root_url generated = generate_treeinfo_repositories(original, self.metadata) appstream = RepoConfigurationData() appstream.origin = REPO_ORIGIN_TREEINFO appstream.name = "AppStream" appstream.enabled = True appstream.url = "file:///tmp/appstream" baseos = RepoConfigurationData() baseos.origin = REPO_ORIGIN_TREEINFO baseos.name = "BaseOS" baseos.enabled = True baseos.url = "file:///tmp/baseos" self._assert_repo_list_equal(generated, [appstream, baseos])
def test_generate_treeinfo_repositories_none(self): """Test the generate_treeinfo_repositories function with no repos.""" original = RepoConfigurationData() generated = generate_treeinfo_repositories(original, self.metadata) self._assert_repo_list_equal(generated, [])