示例#1
0
 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"])
示例#2
0
class TestPrimaryDatabaseMD(TestPrimaryMD):
    """Test PrimaryDatabaseMD class."""
    def setUp(self):
        """Setup example primary_db file."""
        self.primary_db = PrimaryDatabaseMD("test_data/repodata/primary_db.sqlite")

    def test_invalid_file(self):
        """Test case when file doesn't exist or is invalid."""
        with self.assertRaises(OperationalError):
            PrimaryDatabaseMD("/file/does/not/exist")
            PrimaryDatabaseMD("/dev/null")

    def test_packages(self):
        """Test parsed package metadata fields and counts."""
        self.assertGreater(self.primary_db.get_package_count(), 0)
        packages = self.primary_db.list_packages()
        # Test fields of packages in list
        for pkg in packages:
            self._test_package(pkg)
示例#3
0
    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
示例#4
0
class TestPrimaryDatabaseMD(unittest.TestCase):
    def setUp(self):
        """Setup example primary_db file."""
        self.primary_db = PrimaryDatabaseMD("test_data/repodata/primary_db.sqlite")

    def _test_package(self, pkg):
        intended_fields = ["name", "epoch", "ver", "rel", "arch", "checksum_type", "checksum"]
        actual_fields = pkg.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_invalid_file(self):
        with self.assertRaises(OperationalError):
            PrimaryDatabaseMD("/file/does/not/exist")
            PrimaryDatabaseMD("/dev/null")

    def test_packages(self):
        self.assertGreater(self.primary_db.get_package_count(), 0)
        packages = self.primary_db.list_packages()
        # Test fields of packages in list
        for pkg in packages:
            self._test_package(pkg)
示例#5
0
    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
示例#6
0
    CS_LABEL,
    CS_NAME,
    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),
示例#7
0
 def test_invalid_file(self):
     """Test case when file doesn't exist or is invalid."""
     with self.assertRaises(OperationalError):
         PrimaryDatabaseMD("/file/does/not/exist")
         PrimaryDatabaseMD("/dev/null")
示例#8
0
 def setUp(self):
     """Setup example primary_db file."""
     self.primary_db = PrimaryDatabaseMD("test_data/repodata/primary_db.sqlite")
示例#9
0
 def test_invalid_file(self):
     with self.assertRaises(OperationalError):
         PrimaryDatabaseMD("/file/does/not/exist")
         PrimaryDatabaseMD("/dev/null")