Exemple #1
0
 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))
Exemple #2
0
 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"]))
Exemple #3
0
 def add_synced_repositories(self):
     """Queue all previously synced repositories."""
     repos = self.repo_store.list_repositories()
     for repo_label, repo_dict in repos.items():
         # Reference content_set_label -> content set id
         self.repo_store.content_set_to_db_id[
             repo_dict["content_set"]] = repo_dict["content_set_id"]
         self.repositories.add(
             Repository(repo_label,
                        repo_dict["url"],
                        content_set=repo_dict["content_set"],
                        cert_name=repo_dict["cert_name"],
                        ca_cert=repo_dict["ca_cert"],
                        cert=repo_dict["cert"],
                        key=repo_dict["key"]))
Exemple #4
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
Exemple #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
Exemple #6
0
    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)
Exemple #7
0
class TestRepository(unittest.TestCase):
    def setUp(self):
        """Setup example files."""
        repomd = RepoMD("test_data/repodata/repomd.xml")
        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 test_counting(self):
        # Package count should be same in all repositories
        self.assertGreater(self.repository.get_package_count(), 0)
        self.assertGreater(self.repository_without_updateinfo.get_package_count(), 0)
        self.assertEqual(self.repository.get_package_count(), self.repository_primary_xml.get_package_count())
        self.assertEqual(self.repository.get_package_count(), self.repository_without_updateinfo.get_package_count())

        # Only repository with updateinfo has more than 0 updates
        self.assertGreater(self.repository.get_update_count(), 0)
        self.assertEqual(self.repository_without_updateinfo.get_update_count(), 0)

        # Re-count updates of all known types
        update_sum = 0
        for update_type in KNOWN_UPDATE_TYPES:
            cnt = self.repository.get_update_count(update_type=update_type)
            self.assertGreater(cnt, 0)
            update_sum += cnt
        self.assertEqual(update_sum, self.repository.get_update_count())

        # Repository without updateinfo returns 0 regardless of specified update type
        for update_type in KNOWN_UPDATE_TYPES:
            self.assertEqual(self.repository_without_updateinfo.get_update_count(update_type=update_type), 0)

    def test_listing(self):
        self.assertEqual(len(self.repository.list_packages()), self.repository.get_package_count())
        self.assertEqual(len(self.repository.list_updates()), self.repository.get_update_count())
    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),
]

Exemple #9
0
 def add_repository(self, repo_url):
     """Queue repository to import/check updates."""
     repo_url = repo_url.strip()
     if not repo_url.endswith("/"):
         repo_url += "/"
     self.repositories.add(Repository(repo_url))
Exemple #10
0
class TestRepository(unittest.TestCase):
    """Test Repository class."""
    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 test_counting(self):
        """Test counts of packages from parsed primary and primary_db."""
        # Package count should be same in all repositories
        self.assertGreater(self.repository.get_package_count(), 0)
        self.assertGreater(
            self.repository_without_updateinfo.get_package_count(), 0)
        self.assertEqual(self.repository.get_package_count(),
                         self.repository_primary_xml.get_package_count())
        self.assertEqual(
            self.repository.get_package_count(),
            self.repository_without_updateinfo.get_package_count())

        # Only repository with updateinfo has more than 0 updates
        self.assertGreater(self.repository.get_update_count(), 0)
        self.assertEqual(self.repository_without_updateinfo.get_update_count(),
                         0)

        # Re-count updates of all known types
        update_sum = 0
        for update_type in KNOWN_UPDATE_TYPES:
            cnt = self.repository.get_update_count(update_type=update_type)
            update_sum += cnt
        self.assertEqual(update_sum, self.repository.get_update_count())

        # Repository without updateinfo returns 0 regardless of specified update type
        for update_type in KNOWN_UPDATE_TYPES:
            self.assertEqual(
                self.repository_without_updateinfo.get_update_count(
                    update_type=update_type), 0)

    def test_listing(self):
        """Test package and update methods."""
        self.assertEqual(12, len(self.repository.list_packages()))
        self.assertEqual(12, self.repository.get_package_count())

        self.assertEqual(9, len(self.repository.list_updates()))
        self.assertEqual(9, self.repository.get_update_count())

        self.assertEqual(2, len(self.repository.list_modules()))

    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)