add test for parsing build field prebuild as string

This commit is contained in:
Michael Pöhn 2018-08-28 10:04:05 +02:00 committed by Michael Pöhn
parent 942de28fa5
commit d0a129c216
1 changed files with 23 additions and 1 deletions

View File

@ -209,7 +209,7 @@ class MetadataTest(unittest.TestCase):
UpdateCheckMode: Tags
"""))
def test_parse_yaml_metadata_prebuild(self):
def test_parse_yaml_metadata_prebuild_list(self):
mf = io.StringIO(textwrap.dedent("""\
AutoName: F-Droid
RepoType: git
@ -232,6 +232,28 @@ class MetadataTest(unittest.TestCase):
'versionName': 'v0.1.0',
'prebuild': 'a && b && c'}]})
def test_parse_yaml_metadata_prebuild_string(self):
mf = io.StringIO(textwrap.dedent("""\
AutoName: F-Droid
RepoType: git
Builds:
- versionCode: 1
versionName: v0.1.0
prebuild: |-
a && b && sed -i 's,a,b,'
"""))
mf.name = 'mock_filename.yaml'
mf.seek(0)
result = {}
with mock.patch('fdroidserver.metadata.warnings_action', 'error'):
fdroidserver.metadata.parse_yaml_metadata(mf, result)
self.assertDictEqual(result, {'AutoName': 'F-Droid',
'RepoType': 'git',
'Builds': [{'versionCode': 1,
'versionName': 'v0.1.0',
'prebuild': "a && b && "
"sed -i 's,a,b,'"}]})
def test_write_yaml_prebuild(self):
mf = io.StringIO()
app = fdroidserver.metadata.App()