add test for allowing to write placeholder values to yaml metadata files

This commit is contained in:
Michael Pöhn 2018-08-19 14:11:16 +02:00 committed by Hans-Christoph Steiner
parent 3bea689f74
commit 67e46694d3
1 changed files with 45 additions and 0 deletions

View File

@ -165,6 +165,51 @@ class MetadataTest(unittest.TestCase):
with self.assertRaises(MetaDataException):
fdroidserver.metadata.parse_yaml_metadata(mf, {})
def test_write_yaml_with_allow_placeholder_values(self):
mf = io.StringIO()
app = fdroidserver.metadata.App()
app.Categories = ['None']
app.SourceCode = "https://gitlab.com/fdroid/fdroidclient.git"
app.IssueTracker = "https://gitlab.com/fdroid/fdroidclient/issues"
app.RepoType = 'git'
app.Repo = 'https://gitlab.com/fdroid/fdroidclient.git'
app.AutoUpdateMode = 'None'
app.UpdateCheckMode = 'Tags'
build = fdroidserver.metadata.Build()
build.versionCode = 'Unknown'
build.versionName = 'Unknown'
build.disable = 'Generated by import.py ...'
build.commit = 'Unknown'
build.gradle = [True]
app.builds = [build]
fdroidserver.metadata.write_yaml(mf, app,
allow_placeholder_values=True)
mf.seek(0)
self.assertEqual(mf.read(), textwrap.dedent("""\
Categories:
- None
License: Unknown
SourceCode: https://gitlab.com/fdroid/fdroidclient.git
IssueTracker: https://gitlab.com/fdroid/fdroidclient/issues
RepoType: git
Repo: https://gitlab.com/fdroid/fdroidclient.git
Builds:
- versionName: Unknown
versionCode: '?'
disable: Generated by import.py ...
commit: Unknown
gradle:
- true
AutoUpdateMode: None
UpdateCheckMode: Tags
"""))
if __name__ == "__main__":
os.chdir(os.path.dirname(__file__))