aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2022-12-15 17:19:21 +0100
committerMatthias Baumgartner <dev@igsor.net>2022-12-15 17:19:21 +0100
commit37510d134458bf954ca2da6d40be0d6c76661e8c (patch)
tree41e1383485ccecf5f21ac035ffb96765e66d9e05 /test
parent3426b4e201cf03b78d2a3f144876955fcda2f66b (diff)
downloadbsie-37510d134458bf954ca2da6d40be0d6c76661e8c.tar.gz
bsie-37510d134458bf954ca2da6d40be0d6c76661e8c.tar.bz2
bsie-37510d134458bf954ca2da6d40be0d6c76661e8c.zip
bsie/pipeline interface revision:
* predicates -> principals * schema as property * principals as property * information hiding * full subschema instead of only predicates
Diffstat (limited to 'test')
-rw-r--r--test/lib/test_bsie.py74
-rw-r--r--test/tools/test_pipeline.py5
2 files changed, 13 insertions, 66 deletions
diff --git a/test/lib/test_bsie.py b/test/lib/test_bsie.py
index 43e7b1d..f3f476e 100644
--- a/test/lib/test_bsie.py
+++ b/test/lib/test_bsie.py
@@ -11,8 +11,6 @@ import unittest
# bsie imports
from bsie.base import extractor
from bsie.tools import builder
-from bsie.utils.bsfs import URI, schema
-from bsie.utils.node import Node
from bsie.utils import bsfs, node, ns
# objects to test
@@ -47,22 +45,12 @@ class TestBSIE(unittest.TestCase):
def test_construction(self):
# pipeline only
lib = BSIE(self.pipeline)
- self.assertSetEqual(lib.predicates, {
+ self.assertSetEqual(set(lib.principals), {
ns.bse.filename,
ns.bse.filesize,
ns.bse.author,
})
- self.assertEqual(lib.schema, schema.Schema.from_string('''
- prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
- # essential nodes
- bsfs:Entity rdfs:subClassOf bsfs:Node .
- # common definitions
- xsd:string rdfs:subClassOf bsfs:Literal .
- xsd:integer rdfs:subClassOf bsfs:Literal .
-
+ self.assertEqual(lib.schema, bsfs.schema.Schema.from_string(extractor.SCHEMA_PREAMBLE + '''
bse:filename rdfs:subClassOf bsfs:Predicate ;
rdfs:domain bsfs:File ;
rdfs:range xsd:string ;
@@ -85,21 +73,11 @@ class TestBSIE(unittest.TestCase):
ns.bse.author,
ns.bse.inexistent,
})
- self.assertSetEqual(lib.predicates, {
+ self.assertSetEqual(set(lib.principals), {
ns.bse.filesize,
ns.bse.author,
})
- self.assertEqual(lib.schema, schema.Schema.from_string('''
- prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
- # essential nodes
- bsfs:Entity rdfs:subClassOf bsfs:Node .
- # common definitions
- xsd:string rdfs:subClassOf bsfs:Literal .
- xsd:integer rdfs:subClassOf bsfs:Literal .
-
+ self.assertEqual(lib.schema, bsfs.schema.Schema.from_string(extractor.SCHEMA_PREAMBLE + '''
bse:filesize rdfs:subClassOf bsfs:Predicate ;
rdfs:domain bsfs:File ;
rdfs:range xsd:integer;
@@ -109,26 +87,15 @@ class TestBSIE(unittest.TestCase):
rdfs:domain bsfs:Entity ;
rdfs:range xsd:string ;
bsfs:unique "true"^^xsd:boolean .
-
'''))
# empty collect is disregarded
lib = BSIE(self.pipeline, collect={})
- self.assertSetEqual(lib.predicates, {
+ self.assertSetEqual(set(lib.principals), {
ns.bse.filename,
ns.bse.filesize,
ns.bse.author,
})
- self.assertEqual(lib.schema, schema.Schema.from_string('''
- prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
- # essential nodes
- bsfs:Entity rdfs:subClassOf bsfs:Node .
- # common definitions
- xsd:string rdfs:subClassOf bsfs:Literal .
- xsd:integer rdfs:subClassOf bsfs:Literal .
-
+ self.assertEqual(lib.schema, bsfs.schema.Schema.from_string(extractor.SCHEMA_PREAMBLE + '''
bse:filename rdfs:subClassOf bsfs:Predicate ;
rdfs:domain bsfs:File ;
rdfs:range xsd:string ;
@@ -152,24 +119,14 @@ class TestBSIE(unittest.TestCase):
ns.bse.filename,
ns.bse.inexistent,
})
- self.assertSetEqual(lib.predicates, {
+ self.assertSetEqual(set(lib.principals), {
ns.bse.author,
})
- self.assertEqual(lib.schema, schema.Schema.from_string('''
- prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
- # essential nodes
- bsfs:Entity rdfs:subClassOf bsfs:Node .
- # common definitions
- xsd:string rdfs:subClassOf bsfs:Literal .
-
+ self.assertEqual(lib.schema, bsfs.schema.Schema.from_string(extractor.SCHEMA_PREAMBLE + '''
bse:author rdfs:subClassOf bsfs:Predicate ;
rdfs:domain bsfs:Entity ;
rdfs:range xsd:string ;
bsfs:unique "true"^^xsd:boolean .
-
'''))
# specify collect and discard
@@ -177,19 +134,10 @@ class TestBSIE(unittest.TestCase):
collect={ns.bse.filesize, ns.bse.author, ns.bse.foo, ns.bse.bar},
discard={ns.bse.author, ns.bse.foo, ns.bse.foobar},
)
- self.assertSetEqual(lib.predicates, {
+ self.assertSetEqual(set(lib.principals), {
ns.bse.filesize,
})
- self.assertEqual(lib.schema, schema.Schema.from_string('''
- prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
- prefix xsd: <http://www.w3.org/2001/XMLSchema#>
- prefix bsfs: <http://bsfs.ai/schema/>
- prefix bse: <http://bsfs.ai/schema/Entity#>
- # essential nodes
- bsfs:Entity rdfs:subClassOf bsfs:Node .
- # common definitions
- xsd:integer rdfs:subClassOf bsfs:Literal .
-
+ self.assertEqual(lib.schema, bsfs.schema.Schema.from_string(extractor.SCHEMA_PREAMBLE + '''
bse:filesize rdfs:subClassOf bsfs:Predicate ;
rdfs:domain bsfs:File ;
rdfs:range xsd:integer;
@@ -201,7 +149,7 @@ class TestBSIE(unittest.TestCase):
def test_from_file(self):
# setup
lib = BSIE(self.pipeline)
- self.assertSetEqual(set(lib.predicates), {
+ self.assertSetEqual(set(lib.principals), {
ns.bse.filesize,
ns.bse.filename,
ns.bse.author,
diff --git a/test/tools/test_pipeline.py b/test/tools/test_pipeline.py
index e440ab5..91bf736 100644
--- a/test/tools/test_pipeline.py
+++ b/test/tools/test_pipeline.py
@@ -75,7 +75,7 @@ class TestPipeline(unittest.TestCase):
# equivalence respects schema
p2 = Pipeline(self.prefix, self.ext2rdr)
- p2.schema = pipeline.schema.Empty()
+ p2._schema = pipeline.schema.Empty()
self.assertNotEqual(pipeline, p2)
self.assertNotEqual(hash(pipeline), hash(p2))
@@ -160,8 +160,7 @@ class TestPipeline(unittest.TestCase):
# build pipeline
pipeline = Pipeline(self.prefix, self.ext2rdr)
#
- self.assertSetEqual(set(pipeline.predicates()), {
- pipeline.schema.predicate(ns.bsfs.Predicate),
+ self.assertSetEqual(set(pipeline.principals), {
pipeline.schema.predicate(ns.bse.filename),
pipeline.schema.predicate(ns.bse.filesize),
pipeline.schema.predicate(ns.bse.author),