aboutsummaryrefslogtreecommitdiffstats
path: root/test/extractor/generic/test_constant.py
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2022-10-31 14:14:42 +0100
committerMatthias Baumgartner <dev@igsor.net>2022-10-31 14:14:42 +0100
commit2da348c638ac5058d5acf09ab5df323ee04503d5 (patch)
tree48ee0e912e2f19f51bd684d790f0bcc2d906e887 /test/extractor/generic/test_constant.py
parentd4023fa972af379a4235f51783954671de974372 (diff)
downloadbsie-2da348c638ac5058d5acf09ab5df323ee04503d5.tar.gz
bsie-2da348c638ac5058d5acf09ab5df323ee04503d5.tar.bz2
bsie-2da348c638ac5058d5acf09ab5df323ee04503d5.zip
constant, filesize, and filename extractors
Diffstat (limited to 'test/extractor/generic/test_constant.py')
-rw-r--r--test/extractor/generic/test_constant.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/extractor/generic/test_constant.py b/test/extractor/generic/test_constant.py
new file mode 100644
index 0000000..f3ab0a3
--- /dev/null
+++ b/test/extractor/generic/test_constant.py
@@ -0,0 +1,63 @@
+"""
+
+Part of the bsie test suite.
+A copy of the license is provided with the project.
+Author: Matthias Baumgartner, 2022
+"""
+# imports
+import unittest
+
+# bsie imports
+from bsie.utils import ns
+from bsie.utils.node import Node
+
+# objects to test
+from bsie.extractor.generic.constant import Constant
+
+
+## code ##
+
+class TestConstant(unittest.TestCase):
+ def test_extract(self):
+ schema = '''
+ bse:author a bsfs:Predicate ;
+ rdfs:domain bsfs:Entity ;
+ rdfs:range xsd:string ;
+ owl:maxCardinality "1"^^xsd:number .
+
+ bse:comment a bsfs:Predicate ;
+ rdfs:domain bsfs:Entity ;
+ rdfs:range xsd:string ;
+ owl:maxCardinality "INF"^^xsd:number .
+
+ '''
+ tuples = [
+ (ns.bse.author, 'Me, myself, and I'),
+ (ns.bse.comment, 'the quick brown fox jumps over the lazy dog.'),
+ ]
+ node = Node(ns.bsfs.Entity, '') # Blank node
+ predicates = (ns.bse.author, ns.bse.comment)
+ ext = Constant(schema, tuples)
+ # baseline
+ self.assertSetEqual(set(ext.extract(node, None, predicates)),
+ {(node, pred, value) for pred, value in tuples})
+ # predicates is respected
+ self.assertSetEqual(set(ext.extract(node, None, (ns.bse.author, ns.bse.foobar))),
+ {(node, ns.bse.author, 'Me, myself, and I')})
+ self.assertSetEqual(set(ext.extract(node, None, (ns.bse.comment, ns.bse.foobar))),
+ {(node, ns.bse.comment, 'the quick brown fox jumps over the lazy dog.')})
+ self.assertSetEqual(set(ext.extract(node, None, (ns.bse.foobar, ns.bse.barfoo))), set())
+
+ # FIXME: should change!
+ # for now: no schema compliance
+ ext = Constant('', tuples)
+ self.assertSetEqual(set(ext.extract(node, None, predicates)),
+ {(node, pred, value) for pred, value in tuples})
+
+
+## main ##
+
+if __name__ == '__main__':
+ unittest.main()
+
+## EOF ##