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:52 UTC

[37/50] [abbrv] tinkerpop git commit: more test cases. this time around Graph objects. Found lots of bugs. So glad we hooked up python unit testing.

more test cases. this time around Graph objects. Found lots of bugs. So glad we hooked up python unit testing.


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

Branch: refs/heads/master
Commit: 078f76064f0c693c67731b1ff7df6bf10614f04b
Parents: 1652bd6
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Aug 26 11:59:06 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Aug 26 11:59:06 2016 -0600

----------------------------------------------------------------------
 .../jython/gremlin_python/driver/__init__.py    |  5 --
 .../jython/gremlin_python/structure/graph.py    |  7 +++
 .../jython/tests/structure/io/test_graphson.py  |  2 +-
 .../main/jython/tests/structure/test_graph.py   | 56 ++++++++++++++++++++
 .../src/main/jython/tests/test_statics.py       |  4 +-
 5 files changed, 66 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/078f7606/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 8266cd2..1371364 100644
--- a/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py
+++ b/gremlin-python/src/main/jython/gremlin_python/driver/__init__.py
@@ -21,9 +21,4 @@ from .remote_connection import RemoteStrategy
 from .remote_connection import RemoteTraversal
 from .remote_connection import RemoteTraversalSideEffects
 
-try:
-    from .driver_remote_connection import DriverRemoteConnection
-except ImportError:
-    pass
-
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/078f7606/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/graph.py b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
index 7a50418..e07aaf2 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/graph.py
@@ -40,6 +40,9 @@ class Element(object):
         self.id = id
         self.label = label
 
+    def __eq__(self, other):
+        return isinstance(other, self.__class__) and self.id == other.id
+
 
 class Vertex(Element):
     def __init__(self, id, label="vertex"):
@@ -63,6 +66,7 @@ class VertexProperty(Element):
     def __init__(self, id, label, value):
         Element.__init__(self, id, label)
         self.value = value
+        self.key = self.label
 
     def __repr__(self):
         return "vp[" + str(self.label) + "->" + str(self.value)[0:20] + "]"
@@ -75,3 +79,6 @@ class Property(object):
 
     def __repr__(self):
         return "p[" + str(self.key) + "->" + str(self.value)[0:20] + "]"
+
+        def __eq__(self, other):
+            return isinstance(other, self.__class__) and self.key == other.key and self.value == other.value

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/078f7606/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
index 6f38f82..f8a64f8 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
@@ -19,8 +19,8 @@ under the License.
 
 __author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
 
-import unittest
 import json
+import unittest
 from unittest import TestCase
 
 from gremlin_python.structure.io.graphson import GraphSONReader

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/078f7606/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
new file mode 100644
index 0000000..9ba32c9
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/structure/test_graph.py
@@ -0,0 +1,56 @@
+'''
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+'''
+
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+import unittest
+from unittest import TestCase
+
+from gremlin_python.structure import Edge
+from gremlin_python.structure import Vertex
+from gremlin_python.structure import VertexProperty
+
+
+class TestGraph(TestCase):
+    def testGraphObjects(self):
+        vertex = Vertex(1)
+        assert "v[1]" == str(vertex)
+        assert "vertex" == vertex.label
+        assert "person" == Vertex(1, "person").label
+        assert vertex == Vertex(1)
+        #
+        edge = Edge(2, Vertex(1), "said", Vertex("hello", "phrase"))
+        assert "e[2][1-said->hello]" == str(edge)
+        assert Vertex(1) == edge.outV
+        assert Vertex("hello") == edge.inV
+        assert "said" == edge.label
+        assert "phrase" == edge.inV.label
+        #
+        vp = VertexProperty(24L, "name", "marko")
+        assert "vp[name->marko]" == str(vp)
+        assert "name" == vp.label
+        assert "name" == vp.key
+        assert "marko" == vp.value
+        assert 24L == vp.id
+        assert isinstance(vp.id, long)
+        assert vp == VertexProperty(24L, "name", "marko")
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/078f7606/gremlin-python/src/main/jython/tests/test_statics.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/test_statics.py b/gremlin-python/src/main/jython/tests/test_statics.py
index 6893b6a..246101f 100644
--- a/gremlin-python/src/main/jython/tests/test_statics.py
+++ b/gremlin-python/src/main/jython/tests/test_statics.py
@@ -30,6 +30,7 @@ from gremlin_python.process.traversal import Pop
 
 class TestStatics(TestCase):
     def test_enums(self):
+        statics.load_statics(globals())
         assert isinstance(_list, Cardinality)
         assert _list is Cardinality._list
         #
@@ -38,9 +39,8 @@ class TestStatics(TestCase):
         #
         assert isinstance(first, Pop)
         assert first == Pop.first
+        statics.unload_statics(globals())
 
 
 if __name__ == '__main__':
-    statics.load_statics(globals())
     unittest.main()
-    statics.unload_statics(globals())