Commit 77aa28d2 authored by Florian Pritz's avatar Florian Pritz
Browse files

Add test for archive.org case-insensitive identifier names


Signed-off-by: Florian Pritz's avatarFlorian Pritz <bluewind@xinu.at>
parent 9acd6efa
......@@ -10,5 +10,10 @@
+ packages/f/
+ packages/f/fb-client/
+ packages/f/fb-client/*
+ packages/l/
+ packages/l/libreoffice-fresh-sr-latn/
+ packages/l/libreoffice-fresh-sr-latn/libreoffice-fresh-sr-latn-6.2.3-1-any.pkg.tar.xz*
+ packages/l/libreoffice-fresh-sr-Latn/
+ packages/l/libreoffice-fresh-sr-Latn/libreoffice-fresh-sr-Latn-5.3.0-1-any.pkg.tar.xz*
- *
......@@ -89,5 +89,43 @@ class TestUploader(unittest.TestCase):
self.assertTrue(app.db.exists('fb-client-2.0.4-1-any.pkg.tar.xz'))
self.assertTrue(app.db.exists('fb-client-2.0.3-2-any.pkg.tar.xz'))
def test_upload_pkg_multiple_case(self):
mock_uploader = MagicMock()
app = upload_pkg_internetarchive.ArchiveUploader(mock_uploader,
DB.DB(':memory:'))
app.chunksize = 2
response_ok = MagicMock(status_code=200)
mock_uploader.upload.side_effect = [
[response_ok, response_ok],
[response_ok, response_ok]
]
self.assertFalse(app.db.exists('libreoffice-fresh-sr-Latn-5.3.0-1-any.pkg.tar.xz'))
self.assertFalse(app.db.exists('libreoffice-fresh-sr-latn-6.2.3-1-any.pkg.tar.xz'))
app.main(['./test-data/archive/packages/l/libreoffice-fresh-sr-Latn'])
self.assertTrue(app.db.exists('libreoffice-fresh-sr-Latn-5.3.0-1-any.pkg.tar.xz'))
self.assertFalse(app.db.exists('libreoffice-fresh-sr-latn-6.2.3-1-any.pkg.tar.xz'))
app.main(['./test-data/archive/packages/l/libreoffice-fresh-sr-latn'])
self.assertTrue(app.db.exists('libreoffice-fresh-sr-Latn-5.3.0-1-any.pkg.tar.xz'))
self.assertTrue(app.db.exists('libreoffice-fresh-sr-latn-6.2.3-1-any.pkg.tar.xz'))
mock_uploader.upload.assert_has_calls([
call('archlinux_pkg_libreoffice-fresh-sr-Latn',
files=['./test-data/archive/packages/l/libreoffice-fresh-sr-Latn/libreoffice-fresh-sr-Latn-5.3.0-1-any.pkg.tar.xz',
'./test-data/archive/packages/l/libreoffice-fresh-sr-Latn/libreoffice-fresh-sr-Latn-5.3.0-1-any.pkg.tar.xz.sig',],
metadata=mock.ANY),
# should be uploaded with the previous identifier (i.e. Latn instead of latn)
call('archlinux_pkg_libreoffice-fresh-sr-Latn',
files=['./test-data/archive/packages/l/libreoffice-fresh-sr-latn/libreoffice-fresh-sr-latn-6.2.3-1-any.pkg.tar.xz',
'./test-data/archive/packages/l/libreoffice-fresh-sr-latn/libreoffice-fresh-sr-latn-6.2.3-1-any.pkg.tar.xz.sig',],
metadata=mock.ANY),
])
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment