From 07219685d01f803dc46c8d5465fa542c1d822cb4 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Sat, 24 Dec 2022 10:39:51 +0100 Subject: documentation: standard vs external import --- test/apps/test_index.py | 6 ++++-- test/apps/test_info.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'test/apps') diff --git a/test/apps/test_index.py b/test/apps/test_index.py index 9cdc656..6fc3335 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 diff --git a/test/apps/test_info.py b/test/apps/test_info.py index 6f4d98f..f52c581 100644 --- a/test/apps/test_info.py +++ b/test/apps/test_info.py @@ -4,7 +4,7 @@ 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 -- cgit v1.2.3 From 02bbad817077e9a23f7b24b82845fcde24de63a9 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Mon, 16 Jan 2023 20:55:13 +0100 Subject: image feature integration test --- test/apps/test_index.py | 14 ++++++++++++++ test/apps/testdir/testimage.jpg | Bin 0 -> 349264 bytes 2 files changed, 14 insertions(+) create mode 100644 test/apps/testdir/testimage.jpg (limited to 'test/apps') diff --git a/test/apps/test_index.py b/test/apps/test_index.py index 6fc3335..c3960b8 100644 --- a/test/apps/test_index.py +++ b/test/apps/test_index.py @@ -77,6 +77,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: @@ -91,6 +99,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'), @@ -104,6 +113,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): @@ -150,6 +160,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/testdir/testimage.jpg b/test/apps/testdir/testimage.jpg new file mode 100644 index 0000000..c80bb48 Binary files /dev/null and b/test/apps/testdir/testimage.jpg differ -- cgit v1.2.3 From 4f868bcb3be2658960eace3222563cc9a819366a Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Mon, 16 Jan 2023 21:36:11 +0100 Subject: info schema and feature tests --- test/apps/test_info.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test/apps') diff --git a/test/apps/test_info.py b/test/apps/test_info.py index f52c581..60e9ba1 100644 --- a/test/apps/test_info.py +++ b/test/apps/test_info.py @@ -10,6 +10,9 @@ 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): -- cgit v1.2.3 From 58aaa864f9747d27c065739256d4c6635ca9b751 Mon Sep 17 00:00:00 2001 From: Matthias Baumgartner Date: Mon, 16 Jan 2023 21:36:50 +0100 Subject: minor fixes --- test/apps/test_index.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test/apps') diff --git a/test/apps/test_index.py b/test/apps/test_index.py index c3960b8..7f5be8e 100644 --- a/test/apps/test_index.py +++ b/test/apps/test_index.py @@ -23,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', -- cgit v1.2.3