Ejemplo n.º 1
0
class TestPrimaryMD(unittest.TestCase):
    """Test PrimaryMD class."""
    def setUp(self):
        """Setup example primary file."""
        self.primary = PrimaryMD("test_data/repodata/primary.xml")

    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):
        """Test case when file doesn't exist or is invalid."""
        with self.assertRaises(FileNotFoundError):
            PrimaryMD("/file/does/not/exist")
        with self.assertRaises(ParseError):
            PrimaryMD("/dev/null")

    def test_packages(self):
        """Test parsed package metadata fields and counts."""
        pkg_count = self.primary.get_package_count()
        packages = self.primary.list_packages()
        # Package count read from field and number of actually parsed packages should be same
        self.assertEqual(pkg_count, len(packages))
        # Test fields of packages in list
        for pkg in packages:
            self._test_package(pkg)
Ejemplo n.º 2
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"])
Ejemplo n.º 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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def test_invalid_file(self):
     """Test case when file doesn't exist or is invalid."""
     with self.assertRaises(FileNotFoundError):
         PrimaryMD("/file/does/not/exist")
     with self.assertRaises(ParseError):
         PrimaryMD("/dev/null")
Ejemplo n.º 6
0
 def setUp(self):
     """Setup example primary file."""
     self.primary = PrimaryMD("test_data/repodata/primary.xml")
Ejemplo n.º 7
0
    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),
    ("primary_xml", REPOSITORY_PRIMARY_XML),
Ejemplo n.º 8
0
 def test_invalid_file(self):
     with self.assertRaises(FileNotFoundError):
         PrimaryMD("/file/does/not/exist")
     with self.assertRaises(ParseError):
         PrimaryMD("/dev/null")