You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/08/26 17:40:03 UTC

tinkerpop git commit: flushed out the gremlin-python Python test structure.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 5c9cbf657 -> 1652bd655


flushed out the gremlin-python Python test structure.


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

Branch: refs/heads/TINKERPOP-1278
Commit: 1652bd65572273cbae164cba535729d0e2eb31bb
Parents: 5c9cbf6
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Aug 26 11:39:56 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Aug 26 11:39:56 2016 -0600

----------------------------------------------------------------------
 .../python/TraversalSourceGenerator.groovy      |  2 +
 .../jython/gremlin_python/process/traversal.py  |  2 +
 .../gremlin_python/structure/io/graphson.py     |  3 +
 gremlin-python/src/main/jython/setup.py         |  2 +-
 .../src/main/jython/tests/__init__.py           | 20 +++++++
 .../src/main/jython/tests/driver/__init__.py    | 20 +++++++
 .../driver/test_driver_remote_connection.py     | 20 +++++++
 .../src/main/jython/tests/structure/__init__.py | 20 +++++++
 .../main/jython/tests/structure/io/__init__.py  | 20 +++++++
 .../jython/tests/structure/io/test_graphson.py  | 61 ++++++++++++++++++++
 .../src/main/jython/tests/test_sample.py        | 25 --------
 .../src/main/jython/tests/test_statics.py       | 46 +++++++++++++++
 12 files changed, 215 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/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 a27fd40..db399f0 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
@@ -156,6 +156,8 @@ class Traversal(object):
       return P("and", arg, self)
    def _or(self, arg):
       return P("or", arg, self)
+   def __eq__(self, other):
+        return isinstance(other, self.__class__) and self.operator == other.operator and self.value == other.value and self.other == other.other
    def __repr__(self):
       return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")"
 """)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/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 b39ec35..17efa52 100644
--- a/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
+++ b/gremlin-python/src/main/jython/gremlin_python/process/traversal.py
@@ -176,6 +176,8 @@ class P(object):
       return P("and", arg, self)
    def _or(self, arg):
       return P("or", arg, self)
+   def __eq__(self, other):
+        return isinstance(other, self.__class__) and self.operator == other.operator and self.value == other.value and self.other == other.other
    def __repr__(self):
       return self.operator + "(" + str(self.value) + ")" if self.other is None else self.operator + "(" + str(self.value) + "," + str(self.other) + ")"
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
index b8305ac..2e3f9a5 100644
--- a/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
+++ b/gremlin-python/src/main/jython/gremlin_python/structure/io/graphson.py
@@ -17,6 +17,9 @@ specific language governing permissions and limitations
 under the License.
 '''
 
+__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
+
+
 import json
 from abc import abstractmethod
 from aenum import Enum

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/setup.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/setup.py b/gremlin-python/src/main/jython/setup.py
index 528e69b..3335c70 100644
--- a/gremlin-python/src/main/jython/setup.py
+++ b/gremlin-python/src/main/jython/setup.py
@@ -67,6 +67,6 @@ setup(
     install_requires=[
         'aenum',
         'requests',
-        'tornado'
+        'tornado',
     ]
 )

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/tests/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/__init__.py b/gremlin-python/src/main/jython/tests/__init__.py
new file mode 100644
index 0000000..6df1100
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/__init__.py
@@ -0,0 +1,20 @@
+'''
+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)'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/tests/driver/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/driver/__init__.py b/gremlin-python/src/main/jython/tests/driver/__init__.py
new file mode 100644
index 0000000..6df1100
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/driver/__init__.py
@@ -0,0 +1,20 @@
+'''
+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)'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/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
new file mode 100644
index 0000000..6df1100
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/driver/test_driver_remote_connection.py
@@ -0,0 +1,20 @@
+'''
+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)'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/tests/structure/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/__init__.py b/gremlin-python/src/main/jython/tests/structure/__init__.py
new file mode 100644
index 0000000..6df1100
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/structure/__init__.py
@@ -0,0 +1,20 @@
+'''
+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)'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/tests/structure/io/__init__.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/io/__init__.py b/gremlin-python/src/main/jython/tests/structure/io/__init__.py
new file mode 100644
index 0000000..6df1100
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/structure/io/__init__.py
@@ -0,0 +1,20 @@
+'''
+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)'
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/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
new file mode 100644
index 0000000..6f38f82
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphson.py
@@ -0,0 +1,61 @@
+'''
+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
+import json
+from unittest import TestCase
+
+from gremlin_python.structure.io.graphson import GraphSONReader
+
+
+class TestGraphSON(TestCase):
+    def test_numbers(self):
+        x = GraphSONReader.readObject(json.dumps({
+            "@type": "g:Int32",
+            "@value": 31
+        }))
+        assert isinstance(x, int)
+        assert 31 == x
+        ##
+        x = GraphSONReader.readObject(json.dumps({
+            "@type": "g:Int64",
+            "@value": 31
+        }))
+        assert isinstance(x, long)
+        assert 31L == x
+        ##
+        x = GraphSONReader.readObject(json.dumps({
+            "@type": "g:Float",
+            "@value": 31.3
+        }))
+        assert isinstance(x, float)
+        assert 31.3 == x
+        ##
+        x = GraphSONReader.readObject(json.dumps({
+            "@type": "g:Double",
+            "@value": 31.2
+        }))
+        assert isinstance(x, float)
+        assert 31.2 == x
+
+
+if __name__ == '__main__':
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/gremlin-python/src/main/jython/tests/test_sample.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/test_sample.py b/gremlin-python/src/main/jython/tests/test_sample.py
deleted file mode 100644
index f362317..0000000
--- a/gremlin-python/src/main/jython/tests/test_sample.py
+++ /dev/null
@@ -1,25 +0,0 @@
-'''
-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.
-'''
-import unittest
-
-def fun(x):
-    return x + 1
-
-def test_answer():
-    assert fun(3) == 4
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/1652bd65/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
new file mode 100644
index 0000000..6893b6a
--- /dev/null
+++ b/gremlin-python/src/main/jython/tests/test_statics.py
@@ -0,0 +1,46 @@
+'''
+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 import statics
+from gremlin_python.process.traversal import Cardinality
+from gremlin_python.process.traversal import P
+from gremlin_python.process.traversal import Pop
+
+
+class TestStatics(TestCase):
+    def test_enums(self):
+        assert isinstance(_list, Cardinality)
+        assert _list is Cardinality._list
+        #
+        assert isinstance(eq(2), P)
+        assert eq(2) == P.eq(2)
+        #
+        assert isinstance(first, Pop)
+        assert first == Pop.first
+
+
+if __name__ == '__main__':
+    statics.load_statics(globals())
+    unittest.main()
+    statics.unload_statics(globals())