Skip to content

Commit

Permalink
Fix an issue with updaterecord md generation w/ new api
Browse files Browse the repository at this point in the history
  • Loading branch information
dralley committed May 10, 2024
1 parent 4bde262 commit 6c59b82
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
4 changes: 1 addition & 3 deletions src/python/createrepo_c/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,10 +714,8 @@ def finish(self):
if self._updaterecords:
upd_xml_path = self.repodata_dir / ("updateinfo.xml" + self._compression_suffix)
writer = UpdateInfoXmlFile(str(upd_xml_path), compressiontype=self._compression)
updateinfo = UpdateInfo()
for rec in self._updaterecords:
updateinfo.append(rec)
writer.add_chunk(updateinfo.xml_dump())
writer.add_chunk(_createrepo_c.xml_dump_updaterecord(rec))
self.working_metadata_files["updateinfo"] = MetadataInfoHolder(upd_xml_path, writer)

# Create all the repomdrecords for the standard metadata
Expand Down
44 changes: 27 additions & 17 deletions tests/python/tests/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,18 @@ def test_defaults(self):
record_path = os.path.join(self.tmpdir, record.location_href)
assert os.path.exists(record_path)

reader = cr.RepositoryReader.from_path(self.tmpdir)
for pkg in reader.iter_packages():
# test that the package files are present where expected
pkg_path = os.path.join(self.tmpdir, pkg.location_href)
assert os.path.exists(pkg_path)
# test that the package checksum type is correct
assert pkg.checksum_type == "sha256"
reader = cr.RepositoryReader.from_path(self.tmpdir)
for pkg in reader.iter_packages():
# test that the package files are present where expected
pkg_path = os.path.join(self.tmpdir, pkg.location_href)
assert os.path.exists(pkg_path)
# test that the package checksum type is correct
assert pkg.checksum_type == "sha256"

expected_updaterecords = [TEST_UPDATERECORD_UPDATE1]
for expected, actual in zip(expected_updaterecords, reader.advisories):
assert expected == actual


def test_options(self):
"""Test that overriding default options works as intended"""
Expand Down Expand Up @@ -142,15 +147,20 @@ def test_options(self):
record_path = os.path.join(self.tmpdir, record.location_href)
assert os.path.exists(record_path)

reader = cr.RepositoryReader.from_path(self.tmpdir)
for pkg in reader.iter_packages():
# test that the package files are present where expected
pkg_path = os.path.join(self.tmpdir, pkg.location_href)
assert os.path.exists(pkg_path)
# test that changelog_limit works
assert len(pkg.changelogs) <= 1
# test that the package checksum type is correct
assert pkg.checksum_type == "sha512"
reader = cr.RepositoryReader.from_path(self.tmpdir)
for pkg in reader.iter_packages():
# test that the package files are present where expected
pkg_path = os.path.join(self.tmpdir, pkg.location_href)
assert os.path.exists(pkg_path)
# test that changelog_limit works
assert len(pkg.changelogs) <= 1
# test that the package checksum type is correct
assert pkg.checksum_type == "sha512"

expected_updaterecords = [TEST_UPDATERECORD_UPDATE1]
for expected, actual in zip(expected_updaterecords, reader.advisories):
assert expected == actual


def test_add_repo_metadata(self):
"""Test adding an additional repo metadata file to the repository."""
Expand Down Expand Up @@ -239,4 +249,4 @@ def test_add_package(self):
assert pkg.location_href.startswith("Packages/")
# test that the package files are present where expected
pkg_path = os.path.join(self.tmpdir, pkg.location_href)
assert os.path.exists(pkg_path)
assert os.path.exists(pkg_path)

0 comments on commit 6c59b82

Please sign in to comment.