From d822df3dad0525f35dbacda9d5a66f4756f079ff Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Wed, 1 Mar 2023 12:49:47 +0100 Subject: Integrate main app into package --- test/apps/test_main.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/apps/test_main.py (limited to 'test') diff --git a/test/apps/test_main.py b/test/apps/test_main.py new file mode 100644 index 0000000..ae19b5e --- /dev/null +++ b/test/apps/test_main.py @@ -0,0 +1,42 @@ +""" + +Part of the bsfs test suite. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# imports +import contextlib +import io +import json +import unittest + +# objects to test +from bsfs.apps import main + + +## code ## + +class TestMain(unittest.TestCase): + def test_main(self): + # must at least pass an app + with contextlib.redirect_stderr(io.StringIO()): + self.assertRaises(SystemExit, main, []) + # app takes over + with contextlib.redirect_stderr(io.StringIO()): + self.assertRaises(SystemExit, main, ['init']) + outbuf = io.StringIO() + with contextlib.redirect_stdout(outbuf): + main(['init', 'sparql']) + self.assertEqual(json.loads(outbuf.getvalue()), { + 'Graph': { + 'user': 'http://example.com/me', + 'backend': { + 'SparqlStore': {}}}}) + + +## main ## + +if __name__ == '__main__': + unittest.main() + +## EOF ## -- cgit v1.2.3