diff --git a/tests/metadata.TestCase b/tests/metadata.TestCase index 6b469875..c8f8b283 100755 --- a/tests/metadata.TestCase +++ b/tests/metadata.TestCase @@ -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__))