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/12 16:33:08 UTC
[40/50] [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/3d793ac5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3d793ac5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3d793ac5
Branch: refs/heads/TINKERPOP-1427
Commit: 3d793ac50911cece1abc6a72b0f6661717cb7d4f
Parents: ff89b2a
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Jul 7 14:52:30 2017 -0600
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Jul 12 12:31:56 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/3d793ac5/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)