Mercurial > code > home > repos > homeauto
diff service/mqtt_to_rdf/stmt_chunk_test.py @ 1670:6fa7ddee9ba8
update stmt_chunk_test
author | drewp@bigasterisk.com |
---|---|
date | Tue, 21 Sep 2021 23:20:41 -0700 |
parents | 00a5624d1d14 |
children | e6d28e6d47b2 |
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))) ])