tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [33/38] tinkerpop git commit: TINKERPOP-786 Made python DSL example like the java example
Date Fri, 26 May 2017 12:24:46 GMT
TINKERPOP-786 Made python DSL example like the java example


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5e09caf1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5e09caf1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5e09caf1

Branch: refs/heads/tp32
Commit: 5e09caf175e8c89695718a4987bff8fd241f8147
Parents: a3d42d5
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Thu May 11 08:55:51 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Tue May 16 11:02:31 2017 -0400

----------------------------------------------------------------------
 gremlin-python/src/main/jython/tests/process/test_dsl.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5e09caf1/gremlin-python/src/main/jython/tests/process/test_dsl.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_dsl.py b/gremlin-python/src/main/jython/tests/process/test_dsl.py
index 92196fe..04313ab 100644
--- a/gremlin-python/src/main/jython/tests/process/test_dsl.py
+++ b/gremlin-python/src/main/jython/tests/process/test_dsl.py
@@ -57,16 +57,21 @@ class SocialTraversalSource(GraphTraversalSource):
         super(SocialTraversalSource, self).__init__(*args, **kwargs)
         self.graph_traversal = SocialTraversal
 
-    def persons(self):
+    def persons(self, *args):
         traversal = self.get_graph_traversal()
         traversal.bytecode.add_step("V")
         traversal.bytecode.add_step("hasLabel", "person")
+
+        if len(args) > 0:
+            traversal.bytecode.add_step("has", "name", P.within(args))
+
         return traversal
 
 
 def test_dsl(remote_connection):
     social = Graph().traversal(SocialTraversalSource).withRemote(remote_connection)
-    assert social.V().has("name", "marko").knows("josh").next()
-    assert social.V().has("name", "marko").youngestFriendsAge().next() == 27
+    assert social.persons("marko").knows("josh").next()
+    assert social.persons("marko").youngestFriendsAge().next() == 27
     assert social.persons().count().next() == 4
+    assert social.persons("marko", "josh").count().next() == 2
     assert social.persons().filter(___.createdAtLeast(2)).count().next() == 1


Mime
View raw message