Commit 05c3ba9d authored by davebshow's avatar davebshow
Browse files

made 3.2.6 release

parent 7d590e72
......@@ -4,7 +4,7 @@ from setuptools import setup
setup(
name='aiogremlin',
version='3.2.6rc2',
version='3.2.6',
url='',
license='Apache Software License',
author='davebshow',
......@@ -18,10 +18,10 @@ setup(
'aiogremlin.structure',
'aiogremlin.remote'],
install_requires=[
'aenum==1.4.5', # required gremlinpython dep
'aiohttp==2.2.5',
'PyYAML==3.12',
'six==1.10.0' # required gremlinpython dep
'aenum>=1.4.5', # required gremlinpython dep
'aiohttp>=2.2.5',
'PyYAML>=3.12',
'six>=1.10.0' # required gremlinpython dep
],
test_suite='tests',
setup_requires=['pytest-runner'],
......
'''
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
'''
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
'''
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
'''
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.
'''
'''THIS FILE HAS BEEN MODIFIED BY DAVID M. BROWN TO SUPPORT PEP 492'''
__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
import json
from mock import Mock
import unittest
from unittest import TestCase
from gremlin_python.statics import *
from gremlin_python.structure.graph import Vertex
from gremlin_python.structure.graph import Path
from gremlin_python.structure.io.graphson import GraphSONWriter, GraphSONReader, GraphSONUtil
import gremlin_python.structure.io.graphson
from gremlin_python.process.traversal import P
from gremlin_python.process.strategies import SubgraphStrategy
from gremlin_python.process.graph_traversal import __
class TestGraphSONReader(TestCase):
graphson_reader = GraphSONReader()
def test_number_input(self):
x = self.graphson_reader.readObject(json.dumps({
"@type": "g:Int32",
"@value": 31
}))
assert isinstance(x, int)
assert 31 == x
##
x = self.graphson_reader.readObject(json.dumps({
"@type": "g:Int64",
"@value": 31
}))
assert isinstance(x, long)
assert long(31) == x
##
x = self.graphson_reader.readObject(json.dumps({
"@type": "g:Float",
"@value": 31.3
}))
assert isinstance(x, float)
assert 31.3 == x
##
x = self.graphson_reader.readObject(json.dumps({
"@type": "g:Double",
"@value": 31.2
}))
assert isinstance(x, float)
assert 31.2 == x
def test_graph(self):
vertex = self.graphson_reader.readObject(
"""{"@type":"g:Vertex", "@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","outE":{"created":[{"id":{"@type":"g:Int32","@value":9},"inV":{"@type":"g:Int32","@value":3},"properties":{"weight":{"@type":"g:Double","@value":0.4}}}],"knows":[{"id":{"@type":"g:Int32","@value":7},"inV":{"@type":"g:Int32","@value":2},"properties":{"weight":{"@type":"g:Double","@value":0.5}}},{"id":{"@type":"g:Int32","@value":8},"inV":{"@type":"g:Int32","@value":4},"properties":{"weight":{"@type":"g:Double","@value":1.0}}}]},"properties":{"name":[{"id":{"@type":"g:Int64","@value":0},"value":"marko"}],"age":[{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29}}]}}}""")
assert isinstance(vertex, Vertex)
assert "person" == vertex.label
assert 1 == vertex.id
assert isinstance(vertex.id, int)
assert vertex == Vertex(1)
def test_path(self):
path = self.graphson_reader.readObject(
"""{"@type":"g:Path","@value":{"labels":[["a"],["b","c"],[]],"objects":[{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":1},"label":"person","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":0},"value":"marko","label":"name"}}],"age":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":1},"value":{"@type":"g:Int32","@value":29},"label":"age"}}]}}},{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int32","@value":3},"label":"software","properties":{"name":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":4},"value":"lop","label":"name"}}],"lang":[{"@type":"g:VertexProperty","@value":{"id":{"@type":"g:Int64","@value":5},"value":"java","label":"lang"}}]}}},"lop"]}}"""
)
assert isinstance(path, Path)
assert "[v[1], v[3], 'lop']" == str(path)
assert Vertex(1) == path[0]
assert Vertex(1) == path["a"]
assert "lop" == path[2]
assert 3 == len(path)
def test_custom_mapping(self):
# extended mapping
class X(object):
pass
type_string = "test:Xtype"
override_string = "g:Int64"
serdes = Mock()
reader = GraphSONReader(deserializer_map={type_string: serdes})
assert type_string in reader.deserializers
# base dicts are not modified
assert type_string not in gremlin_python.structure.io.graphson._deserializers
x = X()
o = reader.toObject({GraphSONUtil.TYPE_KEY: type_string, GraphSONUtil.VALUE_KEY: x})
serdes.objectify.assert_called_once_with(x, reader)
assert o is serdes.objectify()
# overridden mapping
type_string = "g:Int64"
serdes = Mock()
reader = GraphSONReader(deserializer_map={type_string: serdes, override_string: serdes})
assert gremlin_python.structure.io.graphson._deserializers[type_string] is not reader.deserializers[type_string]
value = 3
o = reader.toObject({GraphSONUtil.TYPE_KEY: type_string, GraphSONUtil.VALUE_KEY: value})
serdes.objectify.assert_called_once_with(value, reader)
assert o is serdes.objectify()
class TestGraphSONWriter(TestCase):
graphson_writer = GraphSONWriter()
def test_number_output(self):
assert {"@type":"g:Int64","@value":2} == json.loads(self.graphson_writer.writeObject(long(2)))
assert {"@type":"g:Int32","@value":1} == json.loads(self.graphson_writer.writeObject(1))
assert {"@type":"g:Double","@value":3.2} == json.loads(self.graphson_writer.writeObject(3.2))
assert """true""" == self.graphson_writer.writeObject(True)
def test_numbers(self):
assert {"@type": "g:Int64", "@value": 2} == json.loads(self.graphson_writer.writeObject(long(2)))
assert {"@type": "g:Int32", "@value": 1} == json.loads(self.graphson_writer.writeObject(1))
assert {"@type": "g:Double", "@value": 3.2} == json.loads(self.graphson_writer.writeObject(3.2))
assert """true""" == self.graphson_writer.writeObject(True)
def test_P(self):
result = {'@type': 'g:P',
'@value': {
'predicate': 'and',
'value': [{
'@type': 'g:P',
'@value': {
'predicate': 'or',
'value': [{
'@type': 'g:P',
'@value': {'predicate': 'lt', 'value': 'b'}
},
{'@type': 'g:P', '@value': {'predicate': 'gt', 'value': 'c'}}
]
}
},
{'@type': 'g:P', '@value': {'predicate': 'neq', 'value': 'd'}}]}}
assert result == json.loads(
self.graphson_writer.writeObject(P.lt("b").or_(P.gt("c")).and_(P.neq("d"))))
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)
assert {"@type": "g:SubgraphStrategy", "@value": {}} == json.loads(self.graphson_writer.writeObject(SubgraphStrategy))
assert {"@type": "g:SubgraphStrategy", "@value": {
"vertices": {"@type": "g:Bytecode", "@value": {"step": [["has", "name", "marko"]]}}}} == json.loads(
self.graphson_writer.writeObject(SubgraphStrategy(vertices=__.has("name", "marko"))))
def test_custom_mapping(self):
# extended mapping
class X(object):
pass
serdes = Mock()
writer = GraphSONWriter(serializer_map={X: serdes})
assert X in writer.serializers
# base dicts are not modified
assert X not in gremlin_python.structure.io.graphson._serializers
obj = X()
d = writer.toDict(obj)
serdes.dictify.assert_called_once_with(obj, writer)
assert d is serdes.dictify()
# overridden mapping
serdes = Mock()
writer = GraphSONWriter(serializer_map={int: serdes})
assert gremlin_python.structure.io.graphson._serializers[int] is not writer.serializers[int]
value = 3
d = writer.toDict(value)
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()
'''
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.
'''
'''THIS FILE HAS BEEN MODIFIED BY DAVID M. BROWN TO SUPPORT PEP 492'''
__author__ = 'Marko A. Rodriguez (http://markorodriguez.com)'
import unittest
from unittest import TestCase
from gremlin_python.statics import long
from gremlin_python.structure.graph import Edge
from gremlin_python.structure.graph import Property
from gremlin_python.structure.graph import Vertex
from gremlin_python.structure.graph import VertexProperty
from gremlin_python.structure.graph import Path
class TestGraph(TestCase):
def test_graph_objects(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
assert edge.inV != edge.outV
#
vertex_property = VertexProperty(long(24), "name", "marko")
assert "vp[name->marko]" == str(vertex_property)
assert "name" == vertex_property.label
assert "name" == vertex_property.key
assert "marko" == vertex_property.value
assert long(24) == vertex_property.id
assert isinstance(vertex_property.id, long)
assert vertex_property == VertexProperty(long(24), "name", "marko")
#
property = Property("age", 29)
assert "p[age->29]" == str(property)
assert "age" == property.key
assert 29 == property.value
assert isinstance(property.value, int)
assert property == Property("age", 29)
#
for i in [vertex, edge, vertex_property, property]:
for j in [vertex, edge, vertex_property, property]:
if type(i) != type(j):
assert i != j
else:
assert i == j
assert i.__hash__() == hash(i)
def test_path(self):
path = Path([set(["a", "b"]), set(["c", "b"]), set([])], [1, Vertex(1), "hello"])
assert "[1, v[1], 'hello']" == str(path)
assert 1 == path["a"]
assert Vertex(1) == path["c"]
assert [1, Vertex(1)] == path["b"]
assert path[0] == 1
assert path[1] == Vertex(1)
assert path[2] == "hello"
assert 3 == len(path)
assert "hello" in path
assert "goodbye" not in path
assert Vertex(1) in path
assert Vertex(123) not in path
#
try:
temp = path[3]
raise Exception("Accessing beyond the list index should throw an index error")
except IndexError:
pass
#
try:
temp = path["zz"]
raise Exception("Accessing nothing should throw a key error")
except KeyError:
pass
#
try:
temp = path[1:2]
raise Exception("Accessing using slices should throw a type error")
except TypeError:
pass
#
assert path == path
assert hash(path) == hash(path)
path2 = Path([set(["a", "b"]), set(["c", "b"]), set([])], [1, Vertex(1), "hello"])
assert path == path2
assert hash(path) == hash(path2)
assert path != Path([set(["a"]), set(["c", "b"]), set([])], [1, Vertex(1), "hello"])
assert path != Path([set(["a", "b"]), set(["c", "b"]), set([])], [3, Vertex(1), "hello"])
if __name__ == '__main__':
unittest.main()
'''
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.
'''
'''THIS FILE HAS BEEN MODIFIED BY DAVID M. BROWN TO SUPPORT PEP 492'''
__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):
statics.load_statics(globals())
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
statics.unload_statics(globals())
if __name__ == '__main__':
unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment