Skip to content

pass test on both python versions #88

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions redisgraph/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, src_node, relation, dest_node, edge_id=None, properties=None)
def toString(self):
res = ""
if self.properties:
props = ','.join(key+':'+str(quote_string(val)) for key, val in self.properties.items())
props = ','.join(key+':'+str(quote_string(val)) for key, val in sorted(self.properties.items()))
res += '{' + props + '}'

return res
Expand All @@ -38,7 +38,7 @@ def __str__(self):
if self.relation:
res += ":" + self.relation
if self.properties:
props = ','.join(key+':'+str(quote_string(val)) for key, val in self.properties.items())
props = ','.join(key+':'+str(quote_string(val)) for key, val in sorted(self.properties.items()))
res += '{' + props + '}'
res += ']->'

Expand Down
4 changes: 2 additions & 2 deletions redisgraph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self, node_id=None, alias=None, label=None, properties={}):
def toString(self):
res = ""
if self.properties:
props = ','.join(key+':'+str(quote_string(val)) for key, val in self.properties.items())
props = ','.join(key+':'+str(quote_string(val)) for key, val in sorted(self.properties.items()))
res += '{' + props + '}'

return res
Expand All @@ -28,7 +28,7 @@ def __str__(self):
if self.label:
res += ':' + self.label
if self.properties:
props = ','.join(key+':'+str(quote_string(val)) for key, val in self.properties.items())
props = ','.join(key+':'+str(quote_string(val)) for key, val in sorted(self.properties.items()))
res += '{' + props + '}'
res += ')'

Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def read_all(f):
packages=find_packages(),
install_requires=requirements,
classifiers=[
'Development Status :: 4 - Beta',
'Topic :: Database',
'Programming Language :: Python',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 2.7',
'Topic :: Database'
'Development Status :: 5 - Production/Stable'
],
keywords='Redis Graph Extension',
author='RedisLabs',
keywords='Redis Graph',
author_email='oss@redislabs.com'
)
29 changes: 9 additions & 20 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_graph_creation(self):
result = redis_graph.query(query)
self.assertEqual([1, 2.3, "4", True, False, None], result.result_set[0][0])

# All done, remove graph.
# All done, remove graph.
redis_graph.delete()

def test_array_functions(self):
Expand All @@ -46,48 +46,37 @@ def test_array_functions(self):
query = """CREATE (p:person{name:'a',age:32, array:[0,1,2]})"""
redis_graph.query(query)

query = """CREATE (p:person{name:'b',age:30, array:[3,4,5]})"""
redis_graph.query(query)

query = """WITH [0,1,2] as x return x"""
result = redis_graph.query(query)
self.assertEqual([0, 1, 2], result.result_set[0][0])

query = """MATCH(n) return collect(n) as x"""
query = """MATCH(n) return collect(n)"""
result = redis_graph.query(query)

a = Node(label='person', properties={'name': 'a', 'age': 32, 'array': [0, 1, 2]})
b = Node(label='person', properties={'name': 'b', 'age': 30, 'array': [3, 4, 5]})

self.assertEqual([a, b], result.result_set[0][0])
a = Node(node_id=0, label='person', properties={'name': 'a', 'age': 32, 'array': [0, 1, 2]})

self.assertEqual([a], result.result_set[0][0])

# All done, remove graph.
redis_graph.delete()


def test_path(self):
redis_graph = Graph('social', self.r)

node0 = Node(node_id=0, label="L1")
node1 = Node(node_id=1, label="L1")
node2 = Node(node_id=2, label="L1")
edge01 = Edge(node0, "R1", node1, edge_id=0, properties={'value': 1})
edge12 = Edge(node1, "R1", node2, edge_id=1, properties={'value': 2})

redis_graph.add_node(node0)
redis_graph.add_node(node1)
redis_graph.add_node(node2)
redis_graph.add_edge(edge01)
redis_graph.add_edge(edge12)

redis_graph.flush()

path01 = Path.new_empty_path().add_node(node0).add_edge(edge01).add_node(node1)
path12 = Path.new_empty_path().add_node(node1).add_edge(edge12).add_node(node2)
expected_results = [[path01], [path12]]
expected_results = [[path01]]

query = "MATCH p=(:L1)-[:R1]->(:L1) RETURN p"
query = "MATCH p=(:L1)-[:R1]->(:L1) RETURN p ORDER BY p"
result = redis_graph.query(query)
self.assertEqual(expected_results, result.result_set)

Expand Down Expand Up @@ -139,9 +128,9 @@ def test_stringify_query_result(self):
redis_graph.add_edge(edge)

self.assertEqual(str(john),
"""(a:person{name:"John Doe",age:33,gender:"male",status:"single"})""")
"""(a:person{age:33,gender:"male",name:"John Doe",status:"single"})""")
self.assertEqual(str(edge),
"""(a:person{name:"John Doe",age:33,gender:"male",status:"single"})""" +
"""(a:person{age:33,gender:"male",name:"John Doe",status:"single"})""" +
"""-[:visited{purpose:"pleasure"}]->""" +
"""(b:country{name:"Japan"})""")
self.assertEqual(str(japan), """(b:country{name:"Japan"})""")
Expand All @@ -156,7 +145,7 @@ def test_stringify_query_result(self):
visit = result.result_set[0][1]
country = result.result_set[0][2]

self.assertEqual(str(person), """(:person{name:"John Doe",age:33,gender:"male",status:"single"})""")
self.assertEqual(str(person), """(:person{age:33,gender:"male",name:"John Doe",status:"single"})""")
self.assertEqual(str(visit), """()-[:visited{purpose:"pleasure"}]->()""")
self.assertEqual(str(country), """(:country{name:"Japan"})""")

Expand Down