mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
run black on new .ipa test cases
This commit is contained in:
parent
22d3ba81dd
commit
6eee83db47
1 changed files with 60 additions and 29 deletions
|
|
@ -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,40 @@ 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')
|
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 +1984,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 +2003,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 +2016,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…
Add table
Add a link
Reference in a new issue