From d24484a9501a51f37187fe363e55f8902f8e98a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20P=C3=B6hn?= Date: Fri, 24 Apr 2020 15:22:42 +0200 Subject: [PATCH] simple testcase for common.run_yamllint --- tests/common.TestCase | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/common.TestCase b/tests/common.TestCase index 2ee7852f..d5354284 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -1298,6 +1298,32 @@ class CommonTest(unittest.TestCase): dfm.assert_called_once_with('srclib/ACRA') self.assertEqual(ret, ('ACRA', None, 'srclib/ACRA')) + def test_run_yamllint_wellformed(self): + with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir): + with open('wellformed.yml', 'w') as f: + f.write(textwrap.dedent('''\ + yaml: + file: + - for + - test + purposeses: true + ''')) + result = fdroidserver.common.run_yamllint('wellformed.yml') + self.assertEqual(result, '') + + def test_run_yamllint_malformed(self): + with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir): + with open('malformed.yml', 'w') as f: + f.write(textwrap.dedent('''\ + yaml: + - that + fails + - test + ''')) + result = fdroidserver.common.run_yamllint('malformed.yml') + self.assertIsNotNone(result) + self.assertNotEqual(result, '') + if __name__ == "__main__": os.chdir(os.path.dirname(__file__))