mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-09-11 15:13:27 +02:00
Merge branch 'biplist' into 'master'
gitlab-ci: install biplist if available, otherwise skip test_parse_ipa See merge request fdroid/fdroidserver!1429
This commit is contained in:
commit
5983962107
@ -99,6 +99,7 @@ debian_testing:
|
|||||||
git
|
git
|
||||||
gnupg
|
gnupg
|
||||||
ipfs-cid
|
ipfs-cid
|
||||||
|
python3-biplist
|
||||||
python3-defusedxml
|
python3-defusedxml
|
||||||
python3-pycountry
|
python3-pycountry
|
||||||
python3-setuptools
|
python3-setuptools
|
||||||
@ -124,7 +125,14 @@ ubuntu_lts_ppa:
|
|||||||
- echo "deb http://ppa.launchpad.net/fdroid/fdroidserver/ubuntu $RELEASE main" >> /etc/apt/sources.list
|
- echo "deb http://ppa.launchpad.net/fdroid/fdroidserver/ubuntu $RELEASE main" >> /etc/apt/sources.list
|
||||||
- apt-get update
|
- apt-get update
|
||||||
- apt-get dist-upgrade
|
- apt-get dist-upgrade
|
||||||
- apt-get install --install-recommends dexdump fdroidserver git python3-pycountry python3-setuptools sdkmanager
|
- apt-get install --install-recommends
|
||||||
|
dexdump
|
||||||
|
fdroidserver
|
||||||
|
git
|
||||||
|
python3-biplist
|
||||||
|
python3-pycountry
|
||||||
|
python3-setuptools
|
||||||
|
sdkmanager
|
||||||
|
|
||||||
# Test things work with a default branch other than 'master'
|
# Test things work with a default branch other than 'master'
|
||||||
- git config --global init.defaultBranch thisisnotmasterormain
|
- git config --global init.defaultBranch thisisnotmasterormain
|
||||||
@ -350,7 +358,7 @@ macOS:
|
|||||||
- /bin/bash -n gradlew-fdroid tests/run-tests
|
- /bin/bash -n gradlew-fdroid tests/run-tests
|
||||||
|
|
||||||
# TODO remove the packages below once they are included in the Homebrew package
|
# TODO remove the packages below once they are included in the Homebrew package
|
||||||
- $(brew --prefix fdroidserver)/libexec/bin/python3 -m pip install pycountry
|
- $(brew --prefix fdroidserver)/libexec/bin/python3 -m pip install biplist pycountry
|
||||||
|
|
||||||
# test fdroidserver from git with current package's dependencies
|
# test fdroidserver from git with current package's dependencies
|
||||||
- fdroid="$(brew --prefix fdroidserver)/libexec/bin/python3 $PWD/fdroid" ./tests/run-tests
|
- fdroid="$(brew --prefix fdroidserver)/libexec/bin/python3 $PWD/fdroid" ./tests/run-tests
|
||||||
|
@ -167,12 +167,21 @@ class UpdateTest(unittest.TestCase):
|
|||||||
fdroidserver.update.insert_localized_app_metadata(apps)
|
fdroidserver.update.insert_localized_app_metadata(apps)
|
||||||
|
|
||||||
appdir = os.path.join('repo', 'info.guardianproject.urzip', 'en-US')
|
appdir = os.path.join('repo', 'info.guardianproject.urzip', 'en-US')
|
||||||
self.assertTrue(os.path.isfile(os.path.join(
|
self.assertTrue(
|
||||||
appdir,
|
os.path.isfile(
|
||||||
'icon_NJXNzMcyf-v9i5a1ElJi0j9X1LvllibCa48xXYPlOqQ=.png')))
|
os.path.join(
|
||||||
self.assertTrue(os.path.isfile(os.path.join(
|
appdir, 'icon_NJXNzMcyf-v9i5a1ElJi0j9X1LvllibCa48xXYPlOqQ=.png'
|
||||||
appdir,
|
)
|
||||||
'featureGraphic_GFRT5BovZsENGpJq1HqPODGWBRPWQsx25B95Ol5w_wU=.png')))
|
)
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
os.path.isfile(
|
||||||
|
os.path.join(
|
||||||
|
appdir,
|
||||||
|
'featureGraphic_GFRT5BovZsENGpJq1HqPODGWBRPWQsx25B95Ol5w_wU=.png',
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(6, len(apps))
|
self.assertEqual(6, len(apps))
|
||||||
for packageName, app in apps.items():
|
for packageName, app in apps.items():
|
||||||
@ -1894,7 +1903,10 @@ class UpdateTest(unittest.TestCase):
|
|||||||
with open('repo/index-v2.json') as fp:
|
with open('repo/index-v2.json') as fp:
|
||||||
index = json.load(fp)
|
index = json.load(fp)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
{'System': {'name': {'en-US': 'System Apps'}}, 'Time': {'name': {'en-US': 'Time'}}},
|
{
|
||||||
|
'System': {'name': {'en-US': 'System Apps'}},
|
||||||
|
'Time': {'name': {'en-US': 'Time'}},
|
||||||
|
},
|
||||||
index['repo'][CATEGORIES_CONFIG_NAME],
|
index['repo'][CATEGORIES_CONFIG_NAME],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -1923,28 +1935,46 @@ class UpdateTest(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_parse_ipa(self):
|
def test_parse_ipa(self):
|
||||||
ipa_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'com.fake.IpaApp_1000000000001.ipa')
|
try:
|
||||||
|
import biplist # Fedora does not have a biplist package
|
||||||
|
|
||||||
|
biplist # silence the linters
|
||||||
|
except ImportError as e:
|
||||||
|
self.skipTest(str(e))
|
||||||
|
ipa_path = os.path.join(
|
||||||
|
os.path.dirname(os.path.abspath(__file__)),
|
||||||
|
'com.fake.IpaApp_1000000000001.ipa',
|
||||||
|
)
|
||||||
result = fdroidserver.update.parse_ipa(ipa_path, 'fake_size', 'fake_sha')
|
result = fdroidserver.update.parse_ipa(ipa_path, 'fake_size', 'fake_sha')
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.assertDictEqual(result, {
|
self.assertDictEqual(
|
||||||
'apkName': 'com.fake.IpaApp_1000000000001.ipa',
|
result,
|
||||||
'hash': 'fake_sha',
|
{
|
||||||
'hashType': 'sha256',
|
'apkName': 'com.fake.IpaApp_1000000000001.ipa',
|
||||||
'packageName': 'org.onionshare.OnionShare',
|
'hash': 'fake_sha',
|
||||||
'size': 'fake_size',
|
'hashType': 'sha256',
|
||||||
'versionCode': 1000000000001,
|
'packageName': 'org.onionshare.OnionShare',
|
||||||
'versionName': '1.0.1',
|
'size': 'fake_size',
|
||||||
})
|
'versionCode': 1000000000001,
|
||||||
|
'versionName': '1.0.1',
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class TestUpdateVersionStringToInt(unittest.TestCase):
|
class TestUpdateVersionStringToInt(unittest.TestCase):
|
||||||
|
|
||||||
def test_version_string_to_int(self):
|
def test_version_string_to_int(self):
|
||||||
self.assertEqual(fdroidserver.update.version_string_to_int("1.2.3"), 1000002000003)
|
self.assertEqual(
|
||||||
|
fdroidserver.update.version_string_to_int("1.2.3"), 1000002000003
|
||||||
|
)
|
||||||
self.assertEqual(fdroidserver.update.version_string_to_int("0.0.0003"), 3)
|
self.assertEqual(fdroidserver.update.version_string_to_int("0.0.0003"), 3)
|
||||||
self.assertEqual(fdroidserver.update.version_string_to_int("0.0.0"), 0)
|
self.assertEqual(fdroidserver.update.version_string_to_int("0.0.0"), 0)
|
||||||
self.assertEqual(fdroidserver.update.version_string_to_int("4321.321.21"), 4321000321000021)
|
self.assertEqual(
|
||||||
self.assertEqual(fdroidserver.update.version_string_to_int("18446744.073709.551615"), 18446744073709551615)
|
fdroidserver.update.version_string_to_int("4321.321.21"), 4321000321000021
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
fdroidserver.update.version_string_to_int("18446744.073709.551615"),
|
||||||
|
18446744073709551615,
|
||||||
|
)
|
||||||
|
|
||||||
def test_version_string_to_int_value_errors(self):
|
def test_version_string_to_int_value_errors(self):
|
||||||
with self.assertRaises(ValueError):
|
with self.assertRaises(ValueError):
|
||||||
@ -1960,7 +1990,6 @@ class TestUpdateVersionStringToInt(unittest.TestCase):
|
|||||||
|
|
||||||
|
|
||||||
class TestScanRepoForIpas(unittest.TestCase):
|
class TestScanRepoForIpas(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
|
|
||||||
@ -1980,12 +2009,12 @@ class TestScanRepoForIpas(unittest.TestCase):
|
|||||||
|
|
||||||
def mocked_parse(p, s, c):
|
def mocked_parse(p, s, c):
|
||||||
# pylint: disable=unused-argument
|
# pylint: disable=unused-argument
|
||||||
return {
|
return {'packageName': 'abc' if 'abc' in p else 'xyz'}
|
||||||
'packageName': 'abc' if 'abc' in p else 'xyz'
|
|
||||||
}
|
|
||||||
|
|
||||||
with mock.patch('fdroidserver.update.parse_ipa', mocked_parse):
|
with mock.patch('fdroidserver.update.parse_ipa', mocked_parse):
|
||||||
ipas, checkchanged = fdroidserver.update.scan_repo_for_ipas(apkcache, repodir, knownapks)
|
ipas, checkchanged = fdroidserver.update.scan_repo_for_ipas(
|
||||||
|
apkcache, repodir, knownapks
|
||||||
|
)
|
||||||
|
|
||||||
self.assertEqual(checkchanged, True)
|
self.assertEqual(checkchanged, True)
|
||||||
self.assertEqual(len(ipas), 2)
|
self.assertEqual(len(ipas), 2)
|
||||||
@ -1993,14 +2022,22 @@ class TestScanRepoForIpas(unittest.TestCase):
|
|||||||
self.assertTrue('abc' in package_names_in_ipas)
|
self.assertTrue('abc' in package_names_in_ipas)
|
||||||
self.assertTrue('xyz' in package_names_in_ipas)
|
self.assertTrue('xyz' in package_names_in_ipas)
|
||||||
|
|
||||||
apkcache_setter_package_name = [x.args[1]['packageName'] for x in apkcache.__setitem__.mock_calls]
|
apkcache_setter_package_name = [
|
||||||
|
x.args[1]['packageName'] for x in apkcache.__setitem__.mock_calls
|
||||||
|
]
|
||||||
self.assertTrue('abc' in apkcache_setter_package_name)
|
self.assertTrue('abc' in apkcache_setter_package_name)
|
||||||
self.assertTrue('xyz' in apkcache_setter_package_name)
|
self.assertTrue('xyz' in apkcache_setter_package_name)
|
||||||
self.assertEqual(apkcache.__setitem__.call_count, 2)
|
self.assertEqual(apkcache.__setitem__.call_count, 2)
|
||||||
|
|
||||||
knownapks.recordapk.call_count = 2
|
knownapks.recordapk.call_count = 2
|
||||||
self.assertTrue(unittest.mock.call('abc.Def_123.ipa', 'abc') in knownapks.recordapk.mock_calls)
|
self.assertTrue(
|
||||||
self.assertTrue(unittest.mock.call('xyz.XXX_123.ipa', 'xyz') in knownapks.recordapk.mock_calls)
|
unittest.mock.call('abc.Def_123.ipa', 'abc')
|
||||||
|
in knownapks.recordapk.mock_calls
|
||||||
|
)
|
||||||
|
self.assertTrue(
|
||||||
|
unittest.mock.call('xyz.XXX_123.ipa', 'xyz')
|
||||||
|
in knownapks.recordapk.mock_calls
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user