diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-03-01 12:49:47 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-03-01 12:49:47 +0100 |
commit | d822df3dad0525f35dbacda9d5a66f4756f079ff (patch) | |
tree | 1387c5a7e8fd669c11f61d04a4ab71607867ecf8 /test | |
parent | f9eec185bf3d857c220e5d78de75ec6713437330 (diff) | |
download | bsfs-d822df3dad0525f35dbacda9d5a66f4756f079ff.tar.gz bsfs-d822df3dad0525f35dbacda9d5a66f4756f079ff.tar.bz2 bsfs-d822df3dad0525f35dbacda9d5a66f4756f079ff.zip |
Integrate main app into package
Diffstat (limited to 'test')
-rw-r--r-- | test/apps/test_main.py | 42 |
1 files changed, 42 insertions, 0 deletions
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 ## |