1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-07-07 01:40:10 +02:00

rename parse_srclib to parese_txt_srclib + test case

This commit is contained in:
Michael Pöhn 2019-12-13 23:51:18 +01:00
parent 0d42338d4d
commit c6a97939f1
2 changed files with 28 additions and 3 deletions

View File

@ -704,7 +704,7 @@ def description_html(s, linkres):
return ps.text_html
def parse_srclib(metadatapath):
def parse_txt_srclib(metadatapath):
thisinfo = {}
@ -746,7 +746,7 @@ def read_srclibs():
The information read will be accessible as metadata.srclibs, which is a
dictionary, keyed on srclib name, with the values each being a dictionary
in the same format as that returned by the parse_srclib function.
in the same format as that returned by the parse_txt_srclib function.
A MetaDataException is raised if there are any problems with the srclib
metadata.
@ -765,7 +765,7 @@ def read_srclibs():
for metadatapath in sorted(glob.glob(os.path.join(srcdir, '*.txt'))):
srclibname = os.path.basename(metadatapath[:-4])
srclibs[srclibname] = parse_srclib(metadatapath)
srclibs[srclibname] = parse_txt_srclib(metadatapath)
def read_metadata(xref=True, check_vcs=[], refresh=True, sort_by_time=False):

View File

@ -23,6 +23,8 @@ print('localmodule: ' + localmodule)
if localmodule not in sys.path:
sys.path.insert(0, localmodule)
from testcommon import TmpCwd
import fdroidserver.common
import fdroidserver.metadata
from fdroidserver.exception import MetaDataException
@ -568,6 +570,29 @@ class MetadataTest(unittest.TestCase):
UpdateCheckMode: None
"""))
def test_parse_txt_srclib(self):
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
with open('JSoup.txt', 'w', encoding='utf-8') as f:
f.write(textwrap.dedent('''\
# Source details (the only mandatory fields)
Repo Type:git
Repo:https://github.com/jhy/jsoup.git
# Comma-separated list of subdirs to use. The first existing subdirectory
# found between those given will be used. If none is found or provided, the
# root of the repo directory will be used instead.
Subdir:
# Any extra commands to prepare the source library
Prepare:
'''))
srclib = fdroidserver.metadata.parse_txt_srclib('JSoup.txt')
self.assertDictEqual({'Repo': 'https://github.com/jhy/jsoup.git',
'Repo Type': 'git',
'Subdir': [''],
'Prepare': ''},
srclib)
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))