aboutsummaryrefslogtreecommitdiffstats
path: root/test/apps/test_main.py
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-03-05 19:25:29 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-03-05 19:25:29 +0100
commit48b6081d0092e9c5a1b0ad79bdde2e51649bf61a (patch)
tree634198c34aae3c0306ce30ac7452abd7b53a14e8 /test/apps/test_main.py
parent91437ba89d35bf482f3d9671bb99ef2fc69f5985 (diff)
parente4845c627e97a6d125bf33d9e7a4a8d373d7fc4a (diff)
downloadbsfs-0.23.03.tar.gz
bsfs-0.23.03.tar.bz2
bsfs-0.23.03.zip
Merge branch 'develop'v0.23.03
Diffstat (limited to 'test/apps/test_main.py')
-rw-r--r--test/apps/test_main.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/apps/test_main.py b/test/apps/test_main.py
new file mode 100644
index 0000000..d61372f
--- /dev/null
+++ b/test/apps/test_main.py
@@ -0,0 +1,37 @@
+
+# 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 ##