1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-04 16:30:12 +02:00

Merge 'fix-ndk-long-form-version' into 'master'

* fix-ndk-long-form-version:
  test whether NDK version parsing is working properly
  Fix invalid key error due to NDK versions in "revision" form  (e.g. 21.4.7075529)

fdroid/fdroidserver!1020
This commit is contained in:
Hans-Christoph Steiner 2021-09-20 10:20:07 +02:00
commit cc666907a3
No known key found for this signature in database
GPG Key ID: 3E177817BA1B9BFA
2 changed files with 34 additions and 1 deletions

View File

@ -4310,7 +4310,7 @@ def _install_ndk(ndk):
"""
if re.match(r'[1-9][0-9.]+[0-9]', ndk):
for ndkdict in NDKS:
if ndk == ndkdict['revision']:
if ndk == ndkdict.get('revision'):
ndk = ndkdict['release']
break

View File

@ -2082,6 +2082,39 @@ class CommonTest(unittest.TestCase):
fdroidserver.common.fill_config_defaults(config)
self.assertEqual({'r10e': r10e}, config['ndk_paths'])
def test_install_ndk_versions(self):
"""Test whether NDK version parsing is working properly"""
def fake_download(url, zipball):
print(url, zipball)
with ZipFile(zipball, 'w') as zipfp:
zipfp.writestr(os.path.basename(url), url)
sdk_path = tempfile.mkdtemp(
prefix=inspect.currentframe().f_code.co_name, dir=self.tmpdir
)
config = {'sdk_path': sdk_path}
fdroidserver.common.config = config
for r, sha256 in (
(
'r10e',
'ee5f405f3b57c4f5c3b3b8b5d495ae12b660e03d2112e4ed5c728d349f1e520c',
),
('r20', '57435158f109162f41f2f43d5563d2164e4d5d0364783a9a6fab3ef12cb06ce0'),
(
'23.0.7599858',
'e3eacf80016b91d4cd2c8ca9f34eebd32df912bb799c859cc5450b6b19277b4f',
),
):
with mock.patch(
'fdroidserver.net.download_file', side_effect=fake_download
) as _ignored, mock.patch(
'fdroidserver.common.get_ndk_version', return_value=r
) as _ignored, mock.patch(
'fdroidserver.common.sha256sum', return_value=sha256
):
fdroidserver.common._install_ndk(r)
def test_fill_config_defaults(self):
"""Test the auto-detection of NDKs installed in standard paths"""
sdk_path = tempfile.mkdtemp(