From 559e643bb1fa39feefd2eb73847ad9420daf1deb Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Wed, 14 Dec 2022 06:10:25 +0100 Subject: bsie extraction and info apps --- test/apps/test_info.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/apps/test_info.py (limited to 'test/apps/test_info.py') diff --git a/test/apps/test_info.py b/test/apps/test_info.py new file mode 100644 index 0000000..60a540e --- /dev/null +++ b/test/apps/test_info.py @@ -0,0 +1,42 @@ +""" + +Part of the bsie test suite. +A copy of the license is provided with the project. +Author: Matthias Baumgartner, 2022 +""" +# imports +import argparse +import io +import os +import sys +import unittest + +# objects to test +from bsie.apps.info import main + + +## code ## + +class TestIndex(unittest.TestCase): + def test_predicates(self): + stdout, sys.stdout = sys.stdout, io.StringIO() + # show predicates infos + main(['predicates']) + outbuf, sys.stdout = sys.stdout, stdout + # verify output + self.assertSetEqual({pred for pred in outbuf.getvalue().split('\n') if pred != ''}, { + 'http://bsfs.ai/schema/Entity#author', + 'http://bsfs.ai/schema/Predicate', + 'http://bsfs.ai/schema/Entity#filename', + 'http://bsfs.ai/schema/Entity#filesize', + }) + + def test_invalid(self): + self.assertRaises(SystemExit, main, ['foobar']) + +## main ## + +if __name__ == '__main__': + unittest.main() + +## EOF ## -- cgit v1.2.3 From 3b41b2a4b7532c911b63b41066a75b3e1546d214 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Thu, 15 Dec 2022 17:21:20 +0100 Subject: minor test improvements and information hiding in builder --- test/apps/test_info.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'test/apps/test_info.py') diff --git a/test/apps/test_info.py b/test/apps/test_info.py index 60a540e..ad39c64 100644 --- a/test/apps/test_info.py +++ b/test/apps/test_info.py @@ -6,9 +6,9 @@ Author: Matthias Baumgartner, 2022 """ # imports import argparse +import contextlib import io import os -import sys import unittest # objects to test @@ -19,10 +19,10 @@ from bsie.apps.info import main class TestIndex(unittest.TestCase): def test_predicates(self): - stdout, sys.stdout = sys.stdout, io.StringIO() - # show predicates infos - main(['predicates']) - outbuf, sys.stdout = sys.stdout, stdout + outbuf = io.StringIO() + with contextlib.redirect_stdout(outbuf): + # show predicates infos + main(['predicates']) # verify output self.assertSetEqual({pred for pred in outbuf.getvalue().split('\n') if pred != ''}, { 'http://bsfs.ai/schema/Entity#author', @@ -32,7 +32,8 @@ class TestIndex(unittest.TestCase): }) def test_invalid(self): - self.assertRaises(SystemExit, main, ['foobar']) + with contextlib.redirect_stderr(io.StringIO()): + self.assertRaises(SystemExit, main, ['foobar']) ## main ## -- cgit v1.2.3 From 5850ff2bcb1052883cf301590126609b0657fbc9 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sun, 18 Dec 2022 13:37:02 +0100 Subject: cosmetic changes --- test/apps/test_info.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test/apps/test_info.py') diff --git a/test/apps/test_info.py b/test/apps/test_info.py index ad39c64..6f4d98f 100644 --- a/test/apps/test_info.py +++ b/test/apps/test_info.py @@ -8,7 +8,6 @@ Author: Matthias Baumgartner, 2022 import argparse import contextlib import io -import os import unittest # objects to test -- cgit v1.2.3