diff options
Diffstat (limited to 'test/lib/test_bsie.py')
-rw-r--r-- | test/lib/test_bsie.py | 74 |
1 files changed, 11 insertions, 63 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, |