| |
@@ -20,6 +20,16 @@
|
| |
from pyrpkg.errors import DownloadError, InvalidHashType, UploadError
|
| |
|
| |
|
| |
+ old_stat = os.stat
|
| |
+
|
| |
+
|
| |
+ def mock_stat(path):
|
| |
+ """Fake mtime for tarballs, but keep stat working for any other file."""
|
| |
+ if path.endswith(".tar.xz"):
|
| |
+ return mock.Mock(st_mtime=1234)
|
| |
+ return old_stat(path)
|
| |
+
|
| |
+
|
| |
class CGILookasideCacheTestCase(unittest.TestCase):
|
| |
def setUp(self):
|
| |
self.workdir = tempfile.mkdtemp(prefix='rpkg-tests.')
|
| |
@@ -450,6 +460,7 @@
|
| |
self.assertRaises(UploadError, lc.remote_file_exists, 'pyrpkg',
|
| |
'pyrpkg-0.tar.xz', 'thehash')
|
| |
|
| |
+ @mock.patch('os.stat', new=mock_stat)
|
| |
@mock.patch('pyrpkg.lookaside.logging.getLogger')
|
| |
@mock.patch('pyrpkg.lookaside.pycurl.Curl')
|
| |
def test_upload(self, mock_curl, mock_logger):
|
| |
@@ -478,9 +489,15 @@
|
| |
lc.upload('pyrpkg', 'pyrpkg-0.0.tar.xz', 'thehash')
|
| |
|
| |
self.assertTrue(pycurl.HTTPPOST in curlopts)
|
| |
- self.assertEqual(curlopts[pycurl.HTTPPOST], [
|
| |
- ('name', 'pyrpkg'), ('sha512sum', 'thehash'),
|
| |
- ('file', (pycurl.FORM_FILE, 'pyrpkg-0.0.tar.xz'))])
|
| |
+ self.assertEqual(
|
| |
+ curlopts[pycurl.HTTPPOST],
|
| |
+ [
|
| |
+ ('name', 'pyrpkg'),
|
| |
+ ('sha512sum', 'thehash'),
|
| |
+ ('file', (pycurl.FORM_FILE, 'pyrpkg-0.0.tar.xz')),
|
| |
+ ('mtime', '1234'),
|
| |
+ ],
|
| |
+ )
|
| |
|
| |
self.assertEqual(debug_messages, [b'Some output'])
|
| |
|
| |
@@ -497,6 +514,7 @@
|
| |
self.assertEqual(curl.perform.call_count, 0)
|
| |
self.assertEqual(curl.setopt.call_count, 0)
|
| |
|
| |
+ @mock.patch('os.stat', new=mock_stat)
|
| |
@mock.patch('pyrpkg.lookaside.pycurl.Curl')
|
| |
def test_upload_with_custom_certs(self, mock_curl):
|
| |
def mock_setopt(opt, value):
|
| |
@@ -524,6 +542,7 @@
|
| |
self.assertEqual(curlopts[pycurl.SSLCERT], client_cert)
|
| |
self.assertEqual(curlopts[pycurl.CAINFO], ca_cert)
|
| |
|
| |
+ @mock.patch('os.stat', new=mock_stat)
|
| |
@mock.patch('pyrpkg.lookaside.logging.getLogger')
|
| |
@mock.patch('pyrpkg.lookaside.pycurl.Curl')
|
| |
def test_upload_missing_custom_certs(self, mock_curl, mock_logger):
|
| |
@@ -557,6 +576,7 @@
|
| |
self.assertTrue('Missing certificate: ' in warn_messages[0])
|
| |
self.assertTrue('Missing certificate: ' in warn_messages[1])
|
| |
|
| |
+ @mock.patch('os.stat', new=mock_stat)
|
| |
@mock.patch('pyrpkg.lookaside.pycurl.Curl')
|
| |
def test_upload_failed(self, mock_curl):
|
| |
curl = mock_curl.return_value
|
| |
@@ -569,6 +589,7 @@
|
| |
self.assertRaises(UploadError, lc.upload, 'pyrpkg',
|
| |
'pyrpkg-0.tar.xz', 'thehash')
|
| |
|
| |
+ @mock.patch('os.stat', new=mock_stat)
|
| |
@mock.patch('pyrpkg.lookaside.pycurl.Curl')
|
| |
def test_upload_failed_status_code(self, mock_curl):
|
| |
def mock_setopt(opt, value):
|
| |
This should be backwards compatible. Dist-git instances should hopefully ignore fields they don't understand.
Related: https://github.com/release-engineering/dist-git/pull/22/
Fixes: https://pagure.io/fedpkg/issue/220