install: download_apk() fetchs APKs by appid based on the index

This commit is contained in:
Hans-Christoph Steiner 2024-02-21 18:01:56 +01:00
parent 97b156a963
commit 56bed02a29
3 changed files with 152 additions and 2 deletions

View file

@ -36,6 +36,7 @@ if localmodule not in sys.path:
sys.path.insert(0, localmodule)
import fdroidserver.index
import fdroidserver.install
import fdroidserver.signindex
import fdroidserver.common
import fdroidserver.metadata
@ -2967,6 +2968,21 @@ class CommonTest(unittest.TestCase):
knownapks.recordapk(fake_apk, default_date=datetime.now(timezone.utc))
self.assertEqual(knownapks.apks[fake_apk], now)
def test_append_filename_to_mirrors(self):
filename = 'test.apk'
url = 'https://example.com/fdroid/repo'
mirrors = [{'url': url}]
self.assertEqual(
[{'url': url + '/' + filename}],
fdroidserver.common.append_filename_to_mirrors(filename, mirrors),
)
def test_append_filename_to_mirrors_full(self):
filename = 'test.apk'
mirrors = fdroidserver.common.FDROIDORG_MIRRORS
for mirror in fdroidserver.common.append_filename_to_mirrors(filename, mirrors):
self.assertTrue(mirror['url'].endswith('/' + filename))
APKS_WITH_JAR_SIGNATURES = (
(