mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-10 17:20:29 +03:00
install: function to fetch, verify and install the F-Droid.apk
This commit is contained in:
parent
681d705da0
commit
c7bc8d0fea
2 changed files with 107 additions and 9 deletions
|
|
@ -171,13 +171,54 @@ class InstallTest(unittest.TestCase):
|
|||
common.fill_config_defaults(common.config)
|
||||
self.assertEqual([], fdroidserver.install.devices())
|
||||
|
||||
@staticmethod
|
||||
def _download_raise(privacy_mode):
|
||||
raise Exception('fake failed download')
|
||||
|
||||
@patch('fdroidserver.install.download_apk')
|
||||
@patch('fdroidserver.install.download_fdroid_apk')
|
||||
def test_install_fdroid_apk_privacy_mode_true(
|
||||
self, download_fdroid_apk, download_apk
|
||||
):
|
||||
download_apk.side_effect = self._download_raise
|
||||
download_fdroid_apk.side_effect = self._download_raise
|
||||
fdroidserver.common.config = {'jarsigner': 'fakepath'}
|
||||
install.install_fdroid_apk(privacy_mode=True)
|
||||
download_apk.assert_not_called()
|
||||
download_fdroid_apk.assert_called_once()
|
||||
|
||||
@patch('fdroidserver.install.download_apk')
|
||||
@patch('fdroidserver.install.download_fdroid_apk')
|
||||
def test_install_fdroid_apk_privacy_mode_false(
|
||||
self, download_fdroid_apk, download_apk
|
||||
):
|
||||
download_apk.side_effect = self._download_raise
|
||||
download_fdroid_apk.side_effect = self._download_raise
|
||||
fdroidserver.common.config = {'jarsigner': 'fakepath'}
|
||||
install.install_fdroid_apk(privacy_mode=False)
|
||||
download_apk.assert_not_called()
|
||||
download_fdroid_apk.assert_called_once()
|
||||
|
||||
@patch('fdroidserver.install.download_apk')
|
||||
@patch('fdroidserver.install.download_fdroid_apk')
|
||||
@patch('locale.getlocale', lambda: ('zh_CN', 'UTF-8'))
|
||||
def test_install_fdroid_apk_privacy_mode_locale_auto(
|
||||
self, download_fdroid_apk, download_apk
|
||||
):
|
||||
download_apk.side_effect = self._download_raise
|
||||
download_fdroid_apk.side_effect = self._download_raise
|
||||
fdroidserver.common.config = {'jarsigner': 'fakepath'}
|
||||
install.install_fdroid_apk(privacy_mode=None)
|
||||
download_apk.assert_not_called()
|
||||
download_fdroid_apk.assert_called_once()
|
||||
|
||||
@patch('fdroidserver.net.download_using_mirrors', lambda m: 'testvalue')
|
||||
def test_download_fdroid_apk_smokecheck(self):
|
||||
self.assertEqual('testvalue', install.download_fdroid_apk())
|
||||
|
||||
@unittest.skipUnless(os.getenv('test_download_fdroid_apk'), 'requires net access')
|
||||
def test_download_fdroid_apk(self):
|
||||
f = fdroidserver.install.download_fdroid_apk()
|
||||
f = install.download_fdroid_apk()
|
||||
self.assertTrue(Path(f).exists())
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue