Beispiel #1
0
 def test_bytecode(self):
     g = Graph().traversal()
     bytecode = g.V().out("created").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 0 == len(bytecode.source_instructions)
     assert 2 == len(bytecode.step_instructions)
     assert "V" == bytecode.step_instructions[0][0]
     assert "out" == bytecode.step_instructions[1][0]
     assert "created" == bytecode.step_instructions[1][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 2 == len(bytecode.step_instructions[1])
     ##
     bytecode = g.withSack(1).E().groupCount().by("weight").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 1 == len(bytecode.source_instructions)
     assert "withSack" == bytecode.source_instructions[0][0]
     assert 1 == bytecode.source_instructions[0][1]
     assert 3 == len(bytecode.step_instructions)
     assert "E" == bytecode.step_instructions[0][0]
     assert "groupCount" == bytecode.step_instructions[1][0]
     assert "by" == bytecode.step_instructions[2][0]
     assert "weight" == bytecode.step_instructions[2][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 1 == len(bytecode.step_instructions[1])
     assert 2 == len(bytecode.step_instructions[2])
 def test_bytecode(self):
     g = Graph().traversal()
     bytecode = g.V().out("created").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 0 == len(bytecode.source_instructions)
     assert 2 == len(bytecode.step_instructions)
     assert "V" == bytecode.step_instructions[0][0]
     assert "out" == bytecode.step_instructions[1][0]
     assert "created" == bytecode.step_instructions[1][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 2 == len(bytecode.step_instructions[1])
     ##
     bytecode = g.withSack(1).E().groupCount().by("weight").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 1 == len(bytecode.source_instructions)
     assert "withSack" == bytecode.source_instructions[0][0]
     assert 1 == bytecode.source_instructions[0][1]
     assert 3 == len(bytecode.step_instructions)
     assert "E" == bytecode.step_instructions[0][0]
     assert "groupCount" == bytecode.step_instructions[1][0]
     assert "by" == bytecode.step_instructions[2][0]
     assert "weight" == bytecode.step_instructions[2][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 1 == len(bytecode.step_instructions[1])
     assert 2 == len(bytecode.step_instructions[2])
 def test_bytecode(self):
     g = Graph().traversal()
     bytecode = g.V().out("created").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 0 == len(bytecode.source_instructions)
     assert 2 == len(bytecode.step_instructions)
     assert "V" == bytecode.step_instructions[0][0]
     assert "out" == bytecode.step_instructions[1][0]
     assert "created" == bytecode.step_instructions[1][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 2 == len(bytecode.step_instructions[1])
     ##
     bytecode = g.withSack(1).E().groupCount().by("weight").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 1 == len(bytecode.source_instructions)
     assert "withSack" == bytecode.source_instructions[0][0]
     assert 1 == bytecode.source_instructions[0][1]
     assert 3 == len(bytecode.step_instructions)
     assert "E" == bytecode.step_instructions[0][0]
     assert "groupCount" == bytecode.step_instructions[1][0]
     assert "by" == bytecode.step_instructions[2][0]
     assert "weight" == bytecode.step_instructions[2][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 1 == len(bytecode.step_instructions[1])
     assert 2 == len(bytecode.step_instructions[2])
     ##
     bytecode = g.V(Bindings.of('a', [1,2,3])) \
         .out(Bindings.of('b','created')) \
         .where(__.in_(Bindings.of('c','created'), Bindings.of('d','knows')) \
         .count().is_(Bindings.of('e',P.gt(2)))).bytecode
     assert 5 == len(bytecode.bindings.keys())
     assert [1, 2, 3] == bytecode.bindings['a']
     assert 'created' == bytecode.bindings['b']
     assert 'created' == bytecode.bindings['c']
     assert 'knows' == bytecode.bindings['d']
     assert P.gt(2) == bytecode.bindings['e']
     assert Binding('b', 'created') == bytecode.step_instructions[1][1]
     assert 'binding[b=created]' == str(bytecode.step_instructions[1][1])
     assert isinstance(hash(bytecode.step_instructions[1][1]), int)
 def test_bytecode(self):
     g = Graph().traversal()
     bytecode = g.V().out("created").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 0 == len(bytecode.source_instructions)
     assert 2 == len(bytecode.step_instructions)
     assert "V" == bytecode.step_instructions[0][0]
     assert "out" == bytecode.step_instructions[1][0]
     assert "created" == bytecode.step_instructions[1][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 2 == len(bytecode.step_instructions[1])
     ##
     bytecode = g.withSack(1).E().groupCount().by("weight").bytecode
     assert 0 == len(bytecode.bindings.keys())
     assert 1 == len(bytecode.source_instructions)
     assert "withSack" == bytecode.source_instructions[0][0]
     assert 1 == bytecode.source_instructions[0][1]
     assert 3 == len(bytecode.step_instructions)
     assert "E" == bytecode.step_instructions[0][0]
     assert "groupCount" == bytecode.step_instructions[1][0]
     assert "by" == bytecode.step_instructions[2][0]
     assert "weight" == bytecode.step_instructions[2][1]
     assert 1 == len(bytecode.step_instructions[0])
     assert 1 == len(bytecode.step_instructions[1])
     assert 2 == len(bytecode.step_instructions[2])
     ##
     bytecode = g.V(Bindings.of('a', [1,2,3])) \
         .out(Bindings.of('b','created')) \
         .where(__.in_(Bindings.of('c','created'), Bindings.of('d','knows')) \
         .count().is_(Bindings.of('e',P.gt(2)))).bytecode
     assert 5 == len(bytecode.bindings.keys())
     assert [1,2,3] == bytecode.bindings['a']
     assert 'created' == bytecode.bindings['b']
     assert 'created' == bytecode.bindings['c']
     assert 'knows' == bytecode.bindings['d']
     assert P.gt(2) == bytecode.bindings['e']
     assert Binding('b','created') == bytecode.step_instructions[1][1]
     assert 'binding[b=created]' == str(bytecode.step_instructions[1][1])
     assert isinstance(hash(bytecode.step_instructions[1][1]),int)