Skip to content

Commit

Permalink
Python API: add_new_download return None regression test
Browse files Browse the repository at this point in the history
DownloadCallbacks.add_new_download can now return either None or an int.
This adds a regression test to check that add_new_download can still return
None.
  • Loading branch information
evan-goode committed Dec 13, 2024
1 parent f4b5ac7 commit eb120c5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/python3/libdnf5/repo/test_package_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,33 @@ def mirror_failure(self, user_cb_data, msg, url):
cbs.end_status,
[PackageDownloadCallbacks.TransferStatus_SUCCESSFUL, PackageDownloadCallbacks.TransferStatus_SUCCESSFUL])
self.assertEqual(cbs.end_msg, [None, None])


class TestPackageDownloaderReturnNone(base_test_case.BaseTestCase):
# Previously, add_new_download could only return None. This test adds a
# check to ensure backwards-compatibility with that API.
def test_package_downloader_return_none(self):
class PackageDownloadCallbacks(libdnf5.repo.DownloadCallbacks):
def __init__(self):
super(PackageDownloadCallbacks, self).__init__()

def add_new_download(self, user_data, description, total_to_download):
return None

repo = self.add_repo_rpm("rpm-repo1")

query = libdnf5.rpm.PackageQuery(self.base)
query.filter_name(["one"])
query.filter_arch(["noarch"])
self.assertEqual(query.size(), 2)

downloader = libdnf5.repo.PackageDownloader(self.base)

cbs = PackageDownloadCallbacks()
self.base.set_download_callbacks(
libdnf5.repo.DownloadCallbacksUniquePtr(cbs))

for package in query:
downloader.add(package)

downloader.download()

0 comments on commit eb120c5

Please sign in to comment.