From 10bb3b93f9d27885f8a2dd441103bbe55274b0f8 Mon Sep 17 00:00:00 2001 From: Ondřej Nosek Date: May 12 2024 22:49:01 +0000 Subject: Processing of another return message from lookaside cache Signed-off-by: Ondřej Nosek --- diff --git a/pyrpkg/lookaside.py b/pyrpkg/lookaside.py index 1f01c9b..b2abf2c 100644 --- a/pyrpkg/lookaside.py +++ b/pyrpkg/lookaside.py @@ -285,6 +285,9 @@ class CGILookasideCache(object): if output == b'Missing': return False + if output == b'Required checksum is not present': + return False + # Something unexpected happened self.log.debug(output) raise UploadError('Error checking for %s at %s' diff --git a/tests/test_lookaside.py b/tests/test_lookaside.py index 5c02f90..12da113 100644 --- a/tests/test_lookaside.py +++ b/tests/test_lookaside.py @@ -359,6 +359,24 @@ class CGILookasideCacheTestCase(unittest.TestCase): self.assertFalse(exists) @mock.patch('pyrpkg.lookaside.pycurl.Curl') + def test_remote_file_wrong_checksum(self, mock_curl): + def mock_perform(): + curlopts[pycurl.WRITEFUNCTION](b'Required checksum is not present') + + def mock_setopt(opt, value): + curlopts[opt] = value + + curlopts = {} + curl = mock_curl.return_value + curl.getinfo.return_value = 200 + curl.perform.side_effect = mock_perform + curl.setopt.side_effect = mock_setopt + + lc = CGILookasideCache('_', '_', '_') + exists = lc.remote_file_exists('pyrpkg', 'pyrpkg-0.tar.xz', 'thehash') + self.assertFalse(exists) + + @mock.patch('pyrpkg.lookaside.pycurl.Curl') def test_remote_file_exists_with_custom_certs(self, mock_curl): def mock_perform(): curlopts[pycurl.WRITEFUNCTION](b'Available')