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/12/07 20:02:44 UTC

[21/50] tinkerpop git commit: check for long type in Int32 serializer

check for long type in Int32 serializer


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

Branch: refs/heads/TINKERPOP-1490
Commit: 8ab88820b263fa3d800fbf38bebf2a4232a01607
Parents: b84d653
Author: davebshow <da...@gmail.com>
Authored: Sat Nov 26 14:43:54 2016 -0500
Committer: davebshow <da...@gmail.com>
Committed: Sat Nov 26 14:43:54 2016 -0500

----------------------------------------------------------------------
 .../main/jython/gremlin_python/structure/io/graphson.py   | 10 ++++++++++
 .../src/main/jython/tests/structure/io/test_graphson.py   | 10 ++++++++++
 2 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ab88820/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 d516058..85e161d 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
@@ -285,6 +285,16 @@ class Int32IO(_NumberIO):
     graphson_type = "g:Int32"
     graphson_base_type = "Int32"
 
+    @classmethod
+    def dictify(cls, n, writer):
+        if isinstance(n, bool):
+            return n
+        if isinstance(n, LongType):
+            graphson_base_type = Int64IO.graphson_base_type
+        else:
+            graphson_base_type = cls.graphson_base_type
+        return GraphSONUtil.typedValue(graphson_base_type, n)
+
 
 class VertexDeserializer(_GraphSONTypeIO):
     graphson_type = "g:Vertex"

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/8ab88820/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 f0e8130..2437cfd 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
@@ -179,6 +179,16 @@ class TestGraphSONWriter(TestCase):
         serdes.dictify.assert_called_once_with(value, writer)
         assert d is serdes.dictify()
 
+    def test_write_long(self):
+
+        mapping = self.graphson_writer.toDict(1)
+        assert mapping['@type'] == 'g:Int32'
+        assert mapping['@value'] == 1
+
+        mapping = self.graphson_writer.toDict(long(1))
+        assert mapping['@type'] == 'g:Int64'
+        assert mapping['@value'] == 1
+
 
 if __name__ == '__main__':
     unittest.main()