def load_metadata(self): """Parse available metadata files into memory.""" for md_type in self.md_files: if md_type == "primary_db": self.primary = PrimaryDatabaseMD(self.md_files["primary_db"]) elif md_type == "primary": self.primary = PrimaryMD(self.md_files["primary"]) elif md_type == "updateinfo": self.updateinfo = UpdateInfoMD(self.md_files["updateinfo"])
class TestUpdateInfoMD(unittest.TestCase): def setUp(self): """Setup example updateinfo file.""" self.updateinfo = UpdateInfoMD("test_data/repodata/updateinfo.xml") def _test_reference(self, reference): intended_fields = ["href", "id", "type", "title"] actual_fields = reference.keys() for field in intended_fields: self.assertTrue(field in actual_fields) for field in actual_fields: self.assertTrue(field in intended_fields) def _test_pkg_ref(self, pkg_ref): intended_fields = ["name", "epoch", "ver", "rel", "arch"] actual_fields = pkg_ref.keys() for field in intended_fields: self.assertTrue(field in actual_fields) for field in actual_fields: self.assertTrue(field in intended_fields) def _test_update(self, update): intended_fields = [ "from", "status", "type", "version", "id", "title", "issued", "rights", "release", "summary", "description", "references", "pkglist", "updated", "severity", "solution" ] actual_fields = update.keys() for field in intended_fields: self.assertTrue(field in actual_fields) for field in actual_fields: self.assertTrue(field in intended_fields) self.assertIsInstance(update["references"], list) self.assertIsInstance(update["pkglist"], list) for reference in update["references"]: self._test_reference(reference) for pkg_ref in update["pkglist"]: self._test_pkg_ref(pkg_ref) # Check known update types self.assertTrue(update["type"] in KNOWN_UPDATE_TYPES) def test_invalid_file(self): with self.assertRaises(FileNotFoundError): UpdateInfoMD("/file/does/not/exist") with self.assertRaises(ParseError): UpdateInfoMD("/dev/null") def test_updates(self): updates = self.updateinfo.list_updates() # Test fields of updates in list for update in updates: self._test_update(update)
def setUp(self): """Setup example files.""" primary_db = PrimaryDatabaseMD("test_data/repodata/primary_db.sqlite") primary = PrimaryMD("test_data/repodata/primary.xml") updateinfo = UpdateInfoMD("test_data/repodata/updateinfo.xml") self.repository = Repository("repo_url") self.repository.primary = primary_db self.repository.updateinfo = updateinfo self.repository_without_updateinfo = Repository("repo_url") self.repository_without_updateinfo.primary = primary_db self.repository_primary_xml = Repository("repo_url") self.repository_primary_xml.primary = primary self.repository_primary_xml.updateinfo = updateinfo
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
CS_PRODUCT_ID, PRODUCT_NAME, PRODUCT_RH_ID, REPO_BASEARCH_ID, REPO_CS_ID, REPO_RELEASEVER, REPO_URL, ) from repodata.primary import PrimaryMD from repodata.primary_db import PrimaryDatabaseMD from repodata.repository import Repository from repodata.updateinfo import UpdateInfoMD 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),
def setUp(self): """Setup example updateinfo file.""" self.updateinfo = UpdateInfoMD("test_data/repodata/updateinfo.xml")
def test_invalid_file(self): with self.assertRaises(FileNotFoundError): UpdateInfoMD("/file/does/not/exist") with self.assertRaises(ParseError): UpdateInfoMD("/dev/null")