mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-12 10:10:30 +03:00
rewrite to yaml works for app data now (builds still missing)
This commit is contained in:
parent
0be224b3e0
commit
0f90ab9aac
3 changed files with 157 additions and 1 deletions
37
tests/rewrite-metadata/fake.ota.update.yml
Normal file
37
tests/rewrite-metadata/fake.ota.update.yml
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
Categories:
|
||||
- System
|
||||
License: Apache-2.0
|
||||
WebSite: https://f-droid.org
|
||||
SourceCode: https://gitlab.com/fdroid/privileged-extension
|
||||
IssueTracker: https://gitlab.com/fdroid/privileged-extension/issues
|
||||
Donate: https://f-droid.org/about
|
||||
|
||||
AutoName: Fake OTA Update
|
||||
Summary: Tests whether OTA ZIP files are being include
|
||||
Description: |-
|
||||
F-Droid can make use of system privileges or permissions to
|
||||
install, update and remove applications on its own. The only way to obtain those
|
||||
privileges is to become a system app.
|
||||
|
||||
This is where the Privileged Extension comes in - being a separate app and much
|
||||
smaller, it can be installed as a system app and communicate with the main app
|
||||
via AIDL IPC.
|
||||
|
||||
This has several advantages:
|
||||
|
||||
* Reduced disk usage in the system partition
|
||||
* System updates don't remove F-Droid
|
||||
* The process of installing into system via root is safer
|
||||
|
||||
This is packaged as an OTA (Over-The-Air) update ZIP file. It must be installed
|
||||
using TWRP or other Android recovery that can flash updates to the system from
|
||||
the /data/data/org.fdroid.fdroid folder on the /data partition. The standalone
|
||||
APK is called F-Droid Privileged Extension.
|
||||
|
||||
RepoType: git
|
||||
Repo: https://gitlab.com/fdroid/privileged-extension.git
|
||||
|
||||
AutoUpdateMode: Version %v
|
||||
UpdateCheckMode: Tags
|
||||
CurrentVersion: 0.2.1
|
||||
CurrentVersionCode: '2000'
|
||||
54
tests/rewritemeta.TestCase
Executable file
54
tests/rewritemeta.TestCase
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import inspect
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import unittest
|
||||
import yaml
|
||||
import tempfile
|
||||
import textwrap
|
||||
|
||||
localmodule = os.path.realpath(
|
||||
os.path.join(os.path.dirname(inspect.getfile(inspect.currentframe())), '..'))
|
||||
if localmodule not in sys.path:
|
||||
sys.path.insert(0, localmodule)
|
||||
|
||||
import fdroidserver.common
|
||||
import fdroidserver.metadata
|
||||
|
||||
|
||||
class RewritemetaTest(unittest.TestCase):
|
||||
''' fdroidserver/metadata.py'''
|
||||
|
||||
def test_rewrite_yaml(self):
|
||||
|
||||
# setup/reset test dir if necessary and setup params
|
||||
tmpdir = os.path.join(os.path.dirname(__file__), '..', '.testfiles')
|
||||
if not os.path.exists(tmpdir):
|
||||
os.makedirs(tmpdir)
|
||||
testdir = tempfile.mkdtemp(prefix='test_rewrite_metadata_', dir=tmpdir)
|
||||
fdroidserver.common.config = {'accepted_formats': ['txt', 'yml']}
|
||||
|
||||
# rewrite metadata
|
||||
allapps = fdroidserver.metadata.read_metadata(xref=True)
|
||||
for appid, app in allapps.items():
|
||||
if appid == 'fake.ota.update':
|
||||
fdroidserver.metadata.write_metadata(os.path.join(testdir, appid + '.yml'), app)
|
||||
|
||||
# assert rewrite result
|
||||
with open(os.path.join(testdir, 'fake.ota.update.yml'), 'r', encoding='utf-8') as result:
|
||||
with open('rewrite-metadata/fake.ota.update.yml', 'r', encoding='utf-8') as orig:
|
||||
self.maxDiff = None
|
||||
self.assertEqual(result.read(), orig.read())
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-v", "--verbose", action="store_true", default=False,
|
||||
help="Spew out even more information than normal")
|
||||
(fdroidserver.common.options, args) = parser.parse_args(['--verbose'])
|
||||
|
||||
newSuite = unittest.TestSuite()
|
||||
newSuite.addTest(unittest.makeSuite(RewritemetaTest))
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue