aboutsummaryrefslogtreecommitdiffstats
path: root/test/apps
diff options
context:
space:
mode:
Diffstat (limited to 'test/apps')
-rw-r--r--test/apps/test_index.py26
-rw-r--r--test/apps/test_info.py21
-rw-r--r--test/apps/testdir/testimage.jpgbin0 -> 349264 bytes
3 files changed, 44 insertions, 3 deletions
diff --git a/test/apps/test_index.py b/test/apps/test_index.py
index 9cdc656..7f5be8e 100644
--- a/test/apps/test_index.py
+++ b/test/apps/test_index.py
@@ -4,13 +4,15 @@ Part of the bsie test suite.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2022
"""
-# imports
+# standard imports
import contextlib
import io
import os
-import rdflib
import unittest
+# external imports
+import rdflib
+
# bsie imports
from bsie.utils import ns
@@ -21,6 +23,12 @@ from bsie.apps.index import main
## code ##
class TestIndex(unittest.TestCase):
+ def test_main_invalid(self):
+ outbuf = io.StringIO()
+ with contextlib.redirect_stdout(outbuf):
+ bsfs = main([os.path.join(os.path.dirname(__file__), 'inexistent-file.t')])
+ self.assertEqual(outbuf.getvalue().strip(), '')
+
def test_main(self):
bsfs = main([
'-r',
@@ -75,6 +83,14 @@ class TestIndex(unittest.TestCase):
(rdflib.URIRef(prefix + 'd803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1'), rdflib.URIRef(ns.bse.author), rdflib.Literal('Me, myself, and I', datatype=rdflib.XSD.string)),
(rdflib.URIRef(prefix + 'd803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1'), rdflib.URIRef(ns.bse.filename), rdflib.Literal('td_second', datatype=rdflib.XSD.string)),
(rdflib.URIRef(prefix + 'd803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1'), rdflib.URIRef(ns.bse.filesize), rdflib.Literal('703', datatype=rdflib.XSD.integer)),
+ (rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'), rdflib.RDF.type, rdflib.URIRef(ns.bsfs.File)),
+ (rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'), rdflib.URIRef(ns.bse.author), rdflib.Literal('Me, myself, and I', datatype=rdflib.XSD.string)),
+ (rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'), rdflib.URIRef(ns.bse.filename), rdflib.Literal('testimage.jpg', datatype=rdflib.XSD.string)),
+ (rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'), rdflib.URIRef(ns.bse.filesize), rdflib.Literal('349264', datatype=rdflib.XSD.integer)),
+ (rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'), rdflib.URIRef('http://bsfs.ai/schema/Entity/colors_spatial#0658f2234a054e1dd59a14462c89f7733e019160419c796356aa831498bd0a04'),
+ rdflib.Literal(
+ '(91, 127, 121, 94, 138, 167, 163, 134, 190, 138, 170, 156, 121, 142, 159)',
+ datatype=rdflib.URIRef('http://ie.bsfs.ai/schema/Feature/ColorsSpatial#0658f2234a054e1dd59a14462c89f7733e019160419c796356aa831498bd0a04'))),
}))
# NOTE: we don't check ns.bsm.t_created since it depends on the execution time. Triples would look like this:
@@ -89,6 +105,7 @@ class TestIndex(unittest.TestCase):
# (rdflib.URIRef(prefix + 'b8fd7fba818254166a6043195004138ebda6923e012442f819a2c49671136c70'), rdflib.URIRef(ns.bsm.t_created), rdflib.Literal('1670..........', datatype=rdflib.XSD.integer)),
# (rdflib.URIRef(prefix + 'd43758ace82154a1cc10ca0dfef63cb20dd831f9c87edd6dc06539eefe67371d'), rdflib.URIRef(ns.bsm.t_created), rdflib.Literal('1670..........', datatype=rdflib.XSD.integer)),
# (rdflib.URIRef(prefix + 'd803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1'), rdflib.URIRef(ns.bsm.t_created), rdflib.Literal('1670..........', datatype=rdflib.XSD.integer)),
+ # (rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'), rdflib.URIRef(ns.bsm.t_created), rdflib.Literal('1670..........', datatype=rdflib.XSD.integer)),
# instead, we simply check if there's such a predicate for each file
self.assertSetEqual({sub for sub, _ in bsfs._backend._graph.subject_objects(rdflib.URIRef(ns.bsm.t_created))}, {
rdflib.URIRef(prefix + '2f4109b40107cc50e0884755a1a961ed126887e49b8dbaf0e146b2e226aa6647'),
@@ -102,6 +119,7 @@ class TestIndex(unittest.TestCase):
rdflib.URIRef(prefix + 'b8fd7fba818254166a6043195004138ebda6923e012442f819a2c49671136c70'),
rdflib.URIRef(prefix + 'd43758ace82154a1cc10ca0dfef63cb20dd831f9c87edd6dc06539eefe67371d'),
rdflib.URIRef(prefix + 'd803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1'),
+ rdflib.URIRef(prefix + 'accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089'),
})
def test_print(self):
@@ -148,6 +166,10 @@ class TestIndex(unittest.TestCase):
f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#d803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1) Predicate({ns.bse.author}) Me, myself, and I',
f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#d803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1) Predicate({ns.bse.filename}) td_second',
f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#d803187cbf3676ae9d38126270a6152c60431589aa3bb3824baf8954e9c097f1) Predicate({ns.bse.filesize}) 703',
+ f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089) Predicate({ns.bse.filesize}) 349264',
+ f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089) Predicate({ns.bse.author}) Me, myself, and I',
+ f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089) Predicate({ns.bse.filename}) testimage.jpg',
+ f'Node(http://bsfs.ai/schema/File, http://example.com/me/file#accb115d266ad60c53cd01a7f7130f245886ce8eaf69bc85319febc11d9fe089) Predicate(http://bsfs.ai/schema/Entity/colors_spatial#0658f2234a054e1dd59a14462c89f7733e019160419c796356aa831498bd0a04) (91, 127, 121, 94, 138, 167, 163, 134, 190, 138, 170, 156, 121, 142, 159)',
})
diff --git a/test/apps/test_info.py b/test/apps/test_info.py
index 6f4d98f..60e9ba1 100644
--- a/test/apps/test_info.py
+++ b/test/apps/test_info.py
@@ -4,12 +4,15 @@ Part of the bsie test suite.
A copy of the license is provided with the project.
Author: Matthias Baumgartner, 2022
"""
-# imports
+# standard imports
import argparse
import contextlib
import io
import unittest
+# bsie imports
+from bsie.utils import bsfs
+
# objects to test
from bsie.apps.info import main
@@ -28,6 +31,22 @@ class TestIndex(unittest.TestCase):
'http://bsfs.ai/schema/Predicate',
'http://bsfs.ai/schema/Entity#filename',
'http://bsfs.ai/schema/Entity#filesize',
+ 'http://bsfs.ai/schema/Entity/colors_spatial#0658f2234a054e1dd59a14462c89f7733e019160419c796356aa831498bd0a04'
+ })
+
+ def test_schema(self):
+ outbuf = io.StringIO()
+ with contextlib.redirect_stdout(outbuf):
+ # show schema infos
+ main(['schema'])
+ # verify output
+ schema = bsfs.schema.from_string(outbuf.getvalue())
+ self.assertSetEqual({pred.uri for pred in schema.predicates()}, {
+ 'http://bsfs.ai/schema/Entity#author',
+ 'http://bsfs.ai/schema/Predicate',
+ 'http://bsfs.ai/schema/Entity#filename',
+ 'http://bsfs.ai/schema/Entity#filesize',
+ 'http://bsfs.ai/schema/Entity/colors_spatial#0658f2234a054e1dd59a14462c89f7733e019160419c796356aa831498bd0a04'
})
def test_invalid(self):
diff --git a/test/apps/testdir/testimage.jpg b/test/apps/testdir/testimage.jpg
new file mode 100644
index 0000000..c80bb48
--- /dev/null
+++ b/test/apps/testdir/testimage.jpg
Binary files differ