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 2017/07/13 17:47:53 UTC

[05/52] [abbrv] tinkerpop git commit: added GraphSONReader tests for set/list/map to test_graphsonV3d0.py. Already tested in the Jython infrastruture, but why not have it also localized in the pure Python tests.

added GraphSONReader tests for set/list/map to test_graphsonV3d0.py. Already tested in the Jython infrastruture, but why not have it also localized in the pure Python tests.


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

Branch: refs/heads/TINKERPOP-1552-master
Commit: 7fd0e802b375d8af3614b3837c135b38e310e36f
Parents: 8c29987
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Jul 7 14:52:30 2017 -0600
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 13 13:01:35 2017 -0400

----------------------------------------------------------------------
 .../tests/structure/io/test_graphsonV3d0.py     | 31 ++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/7fd0e802/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
index 19897dc..78798b3 100644
--- a/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
+++ b/gremlin-python/src/main/jython/tests/structure/io/test_graphsonV3d0.py
@@ -33,9 +33,35 @@ from gremlin_python.process.traversal import P
 from gremlin_python.process.strategies import SubgraphStrategy
 from gremlin_python.process.graph_traversal import __
 
+
 class TestGraphSONReader(object):
     graphson_reader = GraphSONReader()
 
+    def test_collections(self):
+        x = self.graphson_reader.readObject(
+            json.dumps({"@type": "g:List", "@value": [{"@type": "g:Int32", "@value": 1},
+                                                      {"@type": "g:Int32", "@value": 2},
+                                                      "3"]}))
+        assert isinstance(x, list)
+        assert x[0] == 1
+        assert x[1] == 2
+        assert x[2] == "3"
+        ##
+        x = self.graphson_reader.readObject(
+            json.dumps({"@type": "g:Set", "@value": [{"@type": "g:Int32", "@value": 1},
+                                                     {"@type": "g:Int32", "@value": 2},
+                                                     "3"]}))
+        assert isinstance(x, set)
+        assert x == set([1, 2, "3"])
+        ##
+        x = self.graphson_reader.readObject(
+            json.dumps({"@type": "g:Map",
+                        "@value": ['a', {"@type": "g:Int32", "@value": 1}, 'b', "marko"]}))
+        assert isinstance(x, dict)
+        assert x['a'] == 1
+        assert x['b'] == "marko"
+        assert len(x) == 2
+
     def test_number_input(self):
         x = self.graphson_reader.readObject(json.dumps({
             "@type": "g:Int32",
@@ -212,8 +238,9 @@ class TestGraphSONWriter(object):
         assert result == json.loads(
             self.graphson_writer.writeObject(P.lt("b").or_(P.gt("c")).and_(P.neq("d"))))
 
-        result = {'@type': 'g:P', '@value': {'predicate':'within','value': {'@type': 'g:List', '@value':[{"@type": "g:Int32", "@value": 1},{"@type": "g:Int32", "@value": 2}]}}}
-        assert result == json.loads(self.graphson_writer.writeObject(P.within([1,2])))
+        result = {'@type': 'g:P', '@value': {'predicate': 'within', 'value': {'@type': 'g:List', '@value': [
+            {"@type": "g:Int32", "@value": 1}, {"@type": "g:Int32", "@value": 2}]}}}
+        assert result == json.loads(self.graphson_writer.writeObject(P.within([1, 2])))
 
     def test_strategies(self):
         # we have a proxy model for now given that we don't want to have to have g:XXX all registered on the Gremlin traversal machine (yet)