def setUp(self): """Setup example files.""" primary_db = PrimaryDatabaseMD(PRIMARY_SQLITE_PATH) primary = PrimaryMD(PRIMARY_XML_PATH) updateinfo = UpdateInfoMD(UPDATEINFO_XML_PATH) modules = ModuleMD(MODULES_YAML_PATH) self.repository = Repository("repo_url", "content_set", "x86_64", "27") self.repository.primary = primary_db self.repository.updateinfo = updateinfo self.repository.modules = modules self.repository_without_updateinfo = Repository( "repo_url", "content_set", "x86_64", "27") self.repository_without_updateinfo.primary = primary_db self.repository_primary_xml = Repository("repo_url", "content_set", "x86_64", "27") self.repository_primary_xml.primary = primary self.repository_primary_xml.updateinfo = updateinfo
def add_db_repositories(self): """Queue all previously imported repositories.""" repos = self.repo_store.list_repositories() for (content_set, basearch, releasever), repo_dict in repos.items(): # Reference content_set_label -> content set id self.repo_store.content_set_to_db_id[content_set] = repo_dict[ "content_set_id"] self.repositories.add( Repository(repo_dict["url"], content_set, basearch, releasever, cert_name=repo_dict["cert_name"], ca_cert=repo_dict["ca_cert"], cert=repo_dict["cert"], key=repo_dict["key"]))
def add_repository(self, repo_url, content_set, basearch, releasever, cert_name=None, ca_cert=None, cert=None, key=None): """Queue repository to import/check updates.""" repo_url = repo_url.strip() if not repo_url.endswith("/"): repo_url += "/" self.repositories.add( Repository(repo_url, content_set, basearch, releasever, cert_name=cert_name, ca_cert=ca_cert, cert=cert, key=key))
def test_load_metadata(self): """Test package and update methods.""" repo = Repository(repo_url='', content_set='', basearch='', releasever='') self.assertEqual(repo.md_files, {}) self.assertIsNone(repo.primary) self.assertIsNone(repo.updateinfo) self.assertIsNone(repo.modules) repo.md_files = dict(primary_db=PRIMARY_SQLITE_PATH, primary=PRIMARY_XML_PATH, updateinfo=UPDATEINFO_XML_PATH, modules=MODULES_YAML_PATH) repo.load_metadata() self.assertIsNotNone(repo.primary) self.assertIsNotNone(repo.updateinfo) self.assertIsNotNone(repo.modules) repo.unload_metadata() self.assertIsNone(repo.primary) self.assertIsNone(repo.updateinfo) self.assertIsNone(repo.modules)
PRIMARY_DB = PrimaryDatabaseMD("test_data/repodata/primary_db.sqlite") PRIMARY = PrimaryMD("test_data/repodata/primary.xml") UPDATEINFO = UpdateInfoMD("test_data/repodata/updateinfo.xml") PRODUCTS = { "product": { "product_id": 9, "content_sets": { "cs_label": { "name": "cs_name" } } } } REPOSITORY = Repository("repo_url1", "cs_label", "x86_64", "27") REPOSITORY.primary = PRIMARY_DB REPOSITORY.updateinfo = UPDATEINFO REPOSITORY_WITHOUT_UPDATEINFO = Repository("repo_url2", "cs_label", "i386", "27") REPOSITORY_WITHOUT_UPDATEINFO.primary = PRIMARY_DB REPOSITORY_PRIMARY_XML = Repository("repo_url3", "cs_label", "ppc64le", "27") REPOSITORY_PRIMARY_XML.primary = PRIMARY REPOSITORY_PRIMARY_XML.updateinfo = UPDATEINFO REPOSITORIES = [ ("primary_db", REPOSITORY), ("primary_xml", REPOSITORY_PRIMARY_XML), ("without updateinfo", REPOSITORY_WITHOUT_UPDATEINFO), ]