changeset 1670:6fa7ddee9ba8

update stmt_chunk_test
author drewp@bigasterisk.com
date Tue, 21 Sep 2021 23:20:41 -0700
parents 9d00adef0b22
children 2b905c07e82b
files service/mqtt_to_rdf/stmt_chunk_test.py
diffstat 1 files changed, 12 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/service/mqtt_to_rdf/stmt_chunk_test.py	Tue Sep 21 23:20:16 2021 -0700
+++ b/service/mqtt_to_rdf/stmt_chunk_test.py	Tue Sep 21 23:20:41 2021 -0700
@@ -1,18 +1,14 @@
-from time import clock_gettime
 import unittest
 
-from rdflib.term import Variable
+from rdflib import Namespace, Variable
 
+from candidate_binding import CandidateBinding
 from inference_test import N3
-from rdflib import ConjunctiveGraph, Graph, Literal, Namespace, Variable
-
-from stmt_chunk import ChunkedGraph, Chunk, applyChunky
+from lhs_evaluation import functionsFor
+from stmt_chunk import AlignedRuleChunk, Chunk, ChunkedGraph, applyChunky
 
 ROOM = Namespace('http://projects.bigasterisk.com/room/')
 
-from lhs_evaluation import functionsFor
-from candidate_binding import CandidateBinding
-
 
 class TestChunkedGraph(unittest.TestCase):
 
@@ -77,23 +73,17 @@
 class TestApplyChunky(unittest.TestCase):
     binding = CandidateBinding({Variable('x'): ROOM.xval})
 
-    def testBoundStatementsOnly(self):
+    def testAllStatements(self):
+        rule0 = Chunk((ROOM.a, Variable('pred'), Variable('x')))
+        rule1 = Chunk((ROOM.a, Variable('pred'), Variable('x')))
         ret = list(
             applyChunky(self.binding,
-                        g=[Chunk((ROOM.a, ROOM.b, Variable('x'))),
-                           Chunk((ROOM.ay, ROOM.by, Variable('y')))],
-                        returnBoundStatementsOnly=True))
-        self.assertEqual(ret, [Chunk((ROOM.a, ROOM.b, ROOM.xval))])
-
-    def testAllStatements(self):
-        ret = list(
-            applyChunky(self.binding,
-                        g=[Chunk((ROOM.a, ROOM.b, Variable('x'))),
-                           Chunk((ROOM.ay, ROOM.by, Variable('y')))],
-                        returnBoundStatementsOnly=False))
+                        g=[
+                           AlignedRuleChunk(ruleChunk=rule0, workingSetChunk=Chunk((ROOM.a, ROOM.b, ROOM.xval))),
+                           AlignedRuleChunk(ruleChunk=rule1, workingSetChunk=Chunk((ROOM.a, ROOM.b, ROOM.yval))),
+                        ]))
         self.assertCountEqual(
             ret,
             [
-                Chunk((ROOM.a, ROOM.b, ROOM.xval)),  #
-                Chunk((ROOM.ay, ROOM.by, Variable('y')))
+                AlignedRuleChunk(ruleChunk=Chunk((ROOM.a, Variable('pred'), ROOM.xval)), workingSetChunk=Chunk((ROOM.a, ROOM.b, ROOM.xval)))
             ])