diff options
Diffstat (limited to 'test/apps')
-rw-r--r-- | test/apps/schema-1.nt | 4 | ||||
-rw-r--r-- | test/apps/schema-2.nt | 7 | ||||
-rw-r--r-- | test/apps/test_init.py | 5 | ||||
-rw-r--r-- | test/apps/test_main.py | 37 | ||||
-rw-r--r-- | test/apps/test_migrate.py | 15 |
5 files changed, 48 insertions, 20 deletions
diff --git a/test/apps/schema-1.nt b/test/apps/schema-1.nt index e57146d..4daf0ad 100644 --- a/test/apps/schema-1.nt +++ b/test/apps/schema-1.nt @@ -3,8 +3,8 @@ prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> # common bsfs prefixes -prefix bsfs: <http://bsfs.ai/schema/> -prefix bse: <http://bsfs.ai/schema/Entity#> +prefix bsfs: <http://schema.bsfs.io/core/> +prefix bse: <http://schema.bsfs.io/core/Node/Entity#> # essential nodes bsfs:Entity rdfs:subClassOf bsfs:Node . diff --git a/test/apps/schema-2.nt b/test/apps/schema-2.nt index 525ac99..4eb2467 100644 --- a/test/apps/schema-2.nt +++ b/test/apps/schema-2.nt @@ -3,14 +3,15 @@ prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> # common bsfs prefixes -prefix bsfs: <http://bsfs.ai/schema/> -prefix bse: <http://bsfs.ai/schema/Entity#> +prefix bsfs: <http://schema.bsfs.io/core/> +prefix bse: <http://schema.bsfs.io/core/Node/Entity#> # essential nodes bsfs:Entity rdfs:subClassOf bsfs:Node . # common definitions -xsd:integer rdfs:subClassOf bsfs:Literal . +bsfs:Number rdfs:subClassOf bsfs:Literal . +xsd:integer rdfs:subClassOf bsfs:Number . bse:filesize rdfs:subClassOf bsfs:Predicate ; rdfs:domain bsfs:Entity ; diff --git a/test/apps/test_init.py b/test/apps/test_init.py index bae6a68..59e10eb 100644 --- a/test/apps/test_init.py +++ b/test/apps/test_init.py @@ -1,9 +1,4 @@ -""" -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 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 ## diff --git a/test/apps/test_migrate.py b/test/apps/test_migrate.py index 957509a..618cb37 100644 --- a/test/apps/test_migrate.py +++ b/test/apps/test_migrate.py @@ -1,9 +1,4 @@ -""" -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 @@ -13,7 +8,7 @@ import unittest import unittest.mock # bsie imports -from bsfs.schema import Schema +from bsfs import schema # objects to test from bsfs.apps.migrate import main @@ -33,21 +28,21 @@ class TestMigrate(unittest.TestCase): # read schema from file with open(schema_1) as ifile: - target = Schema.from_string(ifile.read()) + target = schema.from_string(ifile.read()) graph = main([config, schema_1]) self.assertTrue(target <= graph.schema) # read schema from multiple files with open(schema_1) as ifile: - target = Schema.from_string(ifile.read()) + target = schema.from_string(ifile.read()) with open(schema_2) as ifile: - target = target + Schema.from_string(ifile.read()) + target = target + schema.from_string(ifile.read()) graph = main([config, schema_1, schema_2]) self.assertTrue(target <= graph.schema) # read schema from stdin with open(schema_1, 'rt') as ifile: - target = Schema.from_string(ifile.read()) + target = schema.from_string(ifile.read()) with open(schema_1, 'rt') as ifile: with unittest.mock.patch('sys.stdin', ifile): graph = main([config]) |