You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/08/27 00:54:56 UTC

[41/50] [abbrv] tinkerpop git commit: fixed some import errors in test files that didn't show up cause of pyc caching. Added test_driver_remote_connection.py and its smart about not executing the test if Gremlin Server is NOT running.

fixed some import errors in test files that didn't show up cause of pyc caching. Added test_driver_remote_connection.py and its smart about not executing the test if Gremlin Server is NOT running.


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

Branch: refs/heads/master
Commit: 581505f1ad3da6612645b54059f1cb694ce181b9
Parents: 3c8f498
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Aug 26 13:47:16 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Aug 26 13:47:16 2016 -0600

----------------------------------------------------------------------
 .../python/TraversalSourceGenerator.groovy      |  4 +-
 .../src/main/jython/gremlin_python/__init__.py  |  1 -
 .../jython/gremlin_python/driver/__init__.py    |  4 --
 .../driver/driver_remote_connection.py          |  2 +-
 .../gremlin_python/driver/remote_connection.py  |  3 ++
 .../jython/gremlin_python/process/__init__.py   | 17 --------
 .../jython/gremlin_python/process/traversal.py  |  4 +-
 .../jython/gremlin_python/structure/__init__.py |  5 ---
 .../gremlin_python/structure/io/__init__.py     |  5 ---
 .../driver/test_driver_remote_connection.py     | 46 +++++++++++++++++++-
 .../main/jython/tests/process/test_traversal.py |  2 +-
 .../main/jython/tests/structure/test_graph.py   |  8 ++--
 12 files changed, 60 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
index db399f0..79a1a4e 100644
--- a/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
+++ b/gremlin-python/src/main/groovy/org/apache/tinkerpop/gremlin/python/TraversalSourceGenerator.groovy
@@ -182,11 +182,13 @@ TRAVERSER
 '''
 
 class Traverser(object):
-    def __init__(self, object, bulk):
+    def __init__(self, object, bulk=1L):
         self.object = object
         self.bulk = bulk
     def __repr__(self):
         return str(self.object)
+    def __eq__(self, other):
+        return isinstance(other, self.__class__) and self.object == other.object
 
 '''
 TRAVERSAL SIDE-EFFECTS

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/__init__.py b/gremlin-python/src/main/jython/gremlin_python/__init__.py
index 518d8e0..7626550 100644
--- a/gremlin-python/src/main/jython/gremlin_python/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/__init__.py
@@ -16,6 +16,5 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-from . import statics
 
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py b/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py
index 1371364..7626550 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py
@@ -16,9 +16,5 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-from .remote_connection import RemoteConnection
-from .remote_connection import RemoteStrategy
-from .remote_connection import RemoteTraversal
-from .remote_connection import RemoteTraversalSideEffects
 
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
index c67af67..3273ad4 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/driver_remote_connection.py
@@ -37,6 +37,7 @@ class GremlinServerError(Exception):
 class DriverRemoteConnection(RemoteConnection):
     def __init__(self, url, traversal_source, username="", password="", loop=None):
         super(DriverRemoteConnection, self).__init__(url, traversal_source)
+        self._url = url
         self._username = username
         self._password = password
         if loop is None: self._loop = ioloop.IOLoop.current()
@@ -159,7 +160,6 @@ class DriverRemoteConnection(RemoteConnection):
     def close(self):
         self._websocket.close()
 
-
 class Response:
     def __init__(self, websocket, username, password):
         self._websocket = websocket

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
index dbb0e83..491fffd 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/remote_connection.py
@@ -45,6 +45,9 @@ class RemoteConnection(object):
         print "sending " + bytecode + " to GremlinServer..."
         return RemoteTraversal(iter([]), TraversalSideEffects())
 
+    def __repr__(self):
+        return "remoteconnection[" + self._url + "," + self._traversal_source + "]"
+
 
 class RemoteTraversal(Traversal):
     def __init__(self, traversers, side_effects):

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/__init__.py b/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
index 31af92d..7626550 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/__init__.py
@@ -17,21 +17,4 @@ specific language governing permissions and limitations
 under the License.
 '''
 
-from .graph_traversal import GraphTraversal
-from .graph_traversal import GraphTraversalSource
-from .graph_traversal import __
-from .traversal import Barrier
-from .traversal import Bindings
-from .traversal import Bytecode
-from .traversal import Cardinality
-from .traversal import Column
-from .traversal import Direction
-from .traversal import Operator
-from .traversal import Order
-from .traversal import P
-from .traversal import Pop
-from .traversal import Scope
-from .traversal import T
-from .traversal import Traversal
-
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
index 17efa52..2dc929a 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -240,11 +240,13 @@ TRAVERSER
 '''
 
 class Traverser(object):
-    def __init__(self, object, bulk):
+    def __init__(self, object, bulk=1L):
         self.object = object
         self.bulk = bulk
     def __repr__(self):
         return str(self.object)
+    def __eq__(self, other):
+        return isinstance(other, self.__class__) and self.object == other.object
 
 '''
 TRAVERSAL SIDE-EFFECTS

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py b/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py
index 99273c7..7626550 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/__init__.py
@@ -16,10 +16,5 @@ KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 '''
-from .graph import Graph
-from .graph import Vertex
-from .graph import Edge
-from .graph import VertexProperty
-from .graph import Property
 
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/gremlin_python/structure/io/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/__init__.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/__init__.py
index e9e5f01..7626550 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/__init__.py
@@ -17,9 +17,4 @@ specific language governing permissions and limitations
 under the License.
 '''
 
-from .graphson import GraphSONReader
-from .graphson import GraphSONWriter
-from .graphson import deserializers
-from .graphson import serializers
-
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
index 6df1100..b47eff9 100644
--- a/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -17,4 +17,48 @@ specific language governing permissions and limitations
 under the License.
 '''
 
-__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
\ No newline at end of file
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+import unittest
+from unittest import TestCase
+
+from gremlin_python import statics
+from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
+from gremlin_python.process.traversal import Traverser
+from gremlin_python.structure.graph import Graph
+from gremlin_python.structure.graph import Vertex
+
+
+class TestDriverRemoteConnection(TestCase):
+    def test_traversals(self):
+        statics.load_statics(globals())
+        connection = DriverRemoteConnection('ws://localhost:8182', 'g')
+        assert "remoteconnection[ws://localhost:8182,g]" == str(connection)
+        #
+        g = Graph().traversal().withRemote(connection)
+        #
+        assert Vertex(1) == g.V(1).next()
+        assert 1 == g.V(1).id().next()
+        assert Traverser(Vertex(1)) == g.V(1).nextTraverser()
+        assert 1 == len(g.V(1).toList())
+        assert isinstance(g.V(1).toList(), list)
+        #
+        results = g.V().repeat(out()).times(2).name.toList()
+        assert 2 == len(results)
+        assert "lop" in results
+        assert "ripple" in results
+        #
+        connection.close()
+
+
+if __name__ == '__main__':
+    test = False
+    try:
+        connection = DriverRemoteConnection('ws://localhost:8182', 'g')
+        test = True
+        connection.close()
+    except:
+        print "GremlinServer is not running and this test case will not execute: " + __file__
+
+    if test:
+        unittest.main()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/tests/process/test_traversal.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/process/test_traversal.py b/gremlin-python/src/main/jython/tests/process/test_traversal.py
index 1dfd78b..fe72ac1 100644
--- a/gremlin-python/src/main/jython/tests/process/test_traversal.py
+++ b/gremlin-python/src/main/jython/tests/process/test_traversal.py
@@ -22,7 +22,7 @@ __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
 import unittest
 from unittest import TestCase
 
-from gremlin_python.structure import Graph
+from gremlin_python.structure.graph import Graph
 
 
 class TestTraversal(TestCase):

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/581505f1/gremlin-python/src/main/jython/tests/structure/test_graph.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/test_graph.py b/gremlin-python/src/main/jython/tests/structure/test_graph.py
index 888f587..5f62464 100644
--- a/gremlin-python/src/main/jython/tests/structure/test_graph.py
+++ b/gremlin-python/src/main/jython/tests/structure/test_graph.py
@@ -22,10 +22,10 @@ __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
 import unittest
 from unittest import TestCase
 
-from gremlin_python.structure import Edge
-from gremlin_python.structure import Property
-from gremlin_python.structure import Vertex
-from gremlin_python.structure import VertexProperty
+from gremlin_python.structure.graph import Edge
+from gremlin_python.structure.graph import Property
+from gremlin_python.structure.graph import Vertex
+from gremlin_python.structure.graph import VertexProperty
 
 
 class TestGraph(TestCase):