install: add IPNS download method

This commit is contained in:
Hans-Christoph Steiner 2024-10-21 23:20:11 +02:00
parent 3da48e64bc
commit 1eb6516f16
2 changed files with 30 additions and 3 deletions

View file

@ -177,48 +177,57 @@ class InstallTest(unittest.TestCase):
@patch('fdroidserver.install.download_apk')
@patch('fdroidserver.install.download_fdroid_apk')
@patch('fdroidserver.install.download_fdroid_apk_from_ipns')
@patch('fdroidserver.install.download_fdroid_apk_from_maven')
def test_install_fdroid_apk_privacy_mode_true(
self, maven, download_fdroid_apk, download_apk
self, maven, ipns, download_fdroid_apk, download_apk
):
download_apk.side_effect = self._download_raise
download_fdroid_apk.side_effect = self._download_raise
ipns.side_effect = self._download_raise
maven.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_not_called()
ipns.assert_called_once()
maven.assert_called_once()
@patch('fdroidserver.install.download_apk')
@patch('fdroidserver.install.download_fdroid_apk')
@patch('fdroidserver.install.download_fdroid_apk_from_ipns')
@patch('fdroidserver.install.download_fdroid_apk_from_maven')
def test_install_fdroid_apk_privacy_mode_false(
self, maven, download_fdroid_apk, download_apk
self, maven, ipns, download_fdroid_apk, download_apk
):
download_apk.side_effect = self._download_raise
download_fdroid_apk.side_effect = self._download_raise
ipns.side_effect = self._download_raise
maven.side_effect = self._download_raise
fdroidserver.common.config = {'jarsigner': 'fakepath'}
install.install_fdroid_apk(privacy_mode=False)
download_apk.assert_called_once()
download_fdroid_apk.assert_called_once()
ipns.assert_called_once()
maven.assert_called_once()
@patch('fdroidserver.install.download_apk')
@patch('fdroidserver.install.download_fdroid_apk')
@patch('fdroidserver.install.download_fdroid_apk_from_ipns')
@patch('fdroidserver.install.download_fdroid_apk_from_maven')
@patch('locale.getlocale', lambda: ('zh_CN', 'UTF-8'))
def test_install_fdroid_apk_privacy_mode_locale_auto(
self, maven, download_fdroid_apk, download_apk
self, maven, ipns, download_fdroid_apk, download_apk
):
download_apk.side_effect = self._download_raise
download_fdroid_apk.side_effect = self._download_raise
ipns.side_effect = self._download_raise
maven.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_not_called()
ipns.assert_called_once()
maven.assert_called_once()
@patch('fdroidserver.net.download_using_mirrors', lambda m: 'testvalue')
@ -235,6 +244,11 @@ class InstallTest(unittest.TestCase):
f = install.download_fdroid_apk_from_maven()
self.assertTrue(Path(f).exists())
@unittest.skipUnless(os.getenv('test_download_fdroid_apk'), 'requires net access')
def test_download_fdroid_apk_from_ipns(self):
f = install.download_fdroid_apk_from_ipns()
self.assertTrue(Path(f).exists())
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))