Skip to content

Commit

Permalink
All conformance tests working
Browse files Browse the repository at this point in the history
  • Loading branch information
kellrott committed Feb 25, 2020
1 parent db0c2d9 commit 0e3e97b
Showing 4 changed files with 44 additions and 90 deletions.
2 changes: 1 addition & 1 deletion conformance/graphs/graph1.edges
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
{ "from" : "02", "to" : "03", "label" : "friend", "data" : {"weight": 1.0, "count": 32}}
{ "gid" : "edge02-05", "from" : "02", "to" : "05", "label" : "parent", "data" : {"weight": 1.0, "count": 20}}
{ "from" : "02", "to" : "06", "label" : "knows", "data" : {"weight": 1.0, "count": 75}}
{ "gid" : "edge01-03", "from" : "01", "to" : "03", "label" : "created", "data" : {"weight": 0.4, "count": 31}}
{ "gid" : "edge01-03", "from" : "01", "to" : "03", "label" : "friend", "data" : {"weight": 0.4, "count": 31}}
{ "from" : "04", "to" : "40", "label" : "likes", "data" : {"weight": 0.4, "count": 90}}
{ "from" : "06", "to" : "41", "label" : "likes", "data" : {"weight": 0.2, "count": 75}}
{ "gid" : "edge05-42", "from" : "05", "to" : "42", "label" : "likes", "data" : {"weight": 1.0, "count": 35}}
2 changes: 1 addition & 1 deletion conformance/tests/ot_basic.py
Original file line number Diff line number Diff line change
@@ -268,7 +268,7 @@ def test_incoming_edge(O, man):
if i['gid'] not in ["edge01-04", "edge05-04"]:
errors.append("Wrong incoming vertex %s" % (i['gid']))

if list(O.query().V("03").inE("friend").count())[0]["count"] != 1:
if list(O.query().V("03").inE("friend").count())[0]["count"] != 2:
errors.append("labeled incoming doesn't work")

return errors
61 changes: 23 additions & 38 deletions conformance/tests/ot_mark.py
Original file line number Diff line number Diff line change
@@ -1,91 +1,76 @@
def setupGraph(O):
O.addVertex("vertex1", "person", {"field1": "value1", "field2": "value2"})
O.addVertex("vertex2", "person")
O.addVertex("vertex3", "person", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex4", "person")

O.addEdge("vertex1", "vertex2", "friend", gid="edge1")
O.addEdge("vertex2", "vertex3", "friend", gid="edge2")
O.addEdge("vertex2", "vertex4", "parent", gid="edge3")


def test_mark_select_label_filter(O, man):
errors = []

man.writeTest()
man.setGraph("graph1")

count = 0
for row in O.query().V("vertex2").as_("a").\
both("friend").\
for row in O.query().V("02").as_("a").\
both("parent").\
as_("b").\
select(["a", "b"]):
count += 1
if len(row) != 2:
errors.append("Incorrect number of marks returned")
if row["a"]["gid"] != "vertex2":
if row["a"]["gid"] != "02":
errors.append("Incorrect vertex returned for 'a': %s" % row["a"])
if row["b"]["gid"] not in ["vertex1", "vertex3"]:
if row["b"]["gid"] not in ["05"]:
errors.append("Incorrect vertex returned for 'b': %s" % row["b"])
if row["b"]["gid"] == "vertex1":
if row["b"]["data"] != {"field1": "value1", "field2": "value2"}:
errors.append("Missing data for 'b': %s")
if row["b"]["gid"] == "vertex3":
if row["b"]["data"] != {"field1": "value3", "field2": "value4"}:
errors.append("Missing data for 'b'")

if count != 2:

if count != 1:
errors.append("unexpected number of rows returned. %d != %d" %
(count, 2))
(count, 1))

return errors


def test_mark_select(O, man):
errors = []

man.writeTest()
man.setGraph("graph1")

count = 0
for row in O.query().V("vertex1").as_("a").out().as_(
for row in O.query().V("01").as_("a").out().as_(
"b").out().as_("c").select(["a", "b", "c"]):
count += 1
if len(row) != 3:
errors.append("Incorrect number of marks returned")
if row["a"]["gid"] != "vertex1":
if row["a"]["gid"] != "01":
errors.append("Incorrect vertex returned for 'a': %s" % row["a"])
if row["a"]["data"] != {"field1": "value1", "field2": "value2"}:
if row["a"]["data"] != {"age": 29, "name": "marko"}:
errors.append("Missing data for 'a'")
if row["b"]["gid"] != "vertex2":
if row["b"]["gid"] not in ["02", "03", "04", "05", "06", "08"]:
errors.append("Incorrect vertex returned for 'b': %s" % row["b"])
if row["c"]["gid"] not in ["vertex3", "vertex4"]:
if row["c"]["gid"] not in ["01", "03", "05", "06", "08", "09", "40", "50"]:
errors.append("Incorrect vertex returned for 'c': %s" % row["c"])
if row["c"]["gid"] == "vertex3":
if row["c"]["data"] != {"field1": "value3", "field2": "value4"}:
else:
if "name" not in row["c"]["data"]:
errors.append("Missing data for 'c'")

if count != 2:
if count != 7:
errors.append("unexpected number of rows returned. %d != %d" %
(count, 2))
(count, 7))

return errors


def test_mark_edge_select(O, man):
errors = []

man.writeTest()
man.setGraph("graph1")

count = 0
for row in O.query().V("vertex1").as_("a").outE().as_(
for row in O.query().V("08").as_("a").outE().as_(
"b").out().as_("c").select(["a", "b", "c"]):
count += 1
if len(row) != 3:
errors.append("Incorrect number of marks returned")
if row["a"]["gid"] != "vertex1":
if row["a"]["gid"] != "08":
errors.append("Incorrect as selection")
if row["b"]["gid"] != "edge1":
if row["b"]["gid"] != "edge08-01":
errors.append("Incorrect as edge selection: %s" % row["b"])
if row["c"]["gid"] != "vertex2":
if row["c"]["gid"] != "01":
errors.append("Incorrect as selection")

if count != 1:
69 changes: 19 additions & 50 deletions conformance/tests/ot_path.py
Original file line number Diff line number Diff line change
@@ -6,83 +6,52 @@
was applied, but does verify that the results seem correct
"""


def setupGraph(O):
O.addVertex("vertex1_1", "step1", {"field1": "value1", "field2": "value2"})
O.addVertex("vertex1_2", "step1")
O.addVertex("vertex1_3", "step1", {"field1": "value3", "field2": "value4"})

O.addVertex("vertex2_1", "step2", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex2_2", "step2", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex2_3", "step2", {"field1": "value3", "field2": "value4"})

O.addVertex("vertex3_1", "step3", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex3_2", "step3", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex3_3", "step3", {"field1": "value3", "field2": "value4"})

O.addVertex("vertex4_1", "step4", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex4_2", "step4", {"field1": "value3", "field2": "value4"})
O.addVertex("vertex4_3", "step4", {"field1": "value3", "field2": "value4"})

O.addEdge("vertex1_1", "vertex2_1", "step", gid="edge1")
O.addEdge("vertex1_2", "vertex2_2", "step", gid="edge2")
O.addEdge("vertex1_3", "vertex2_3", "step")

O.addEdge("vertex2_1", "vertex3_1", "step", gid="edge3")
O.addEdge("vertex2_2", "vertex3_2", "step", gid="edge4")
O.addEdge("vertex2_3", "vertex3_3", "step")

O.addEdge("vertex3_1", "vertex4_1", "step", gid="edge5")
O.addEdge("vertex3_2", "vertex4_2", "step", gid="edge6")
O.addEdge("vertex3_3", "vertex4_3", "step")


def test_path_1(O, man):
errors = []

man.setGraph("graph1")

count = 0
for res in O.query().V().out().out().out():
if not res.gid.startswith("vertex4"):
if not res.gid in ["01", "02", "03", "04", "05", "06", "08", "09", "40", "41", "42", "50"]:
errors.append("Wrong vertex found at end of path: %s" % (res.gid))
if not res.label == "step4":
if not res.label in ["Person", "Movie", "Book"]:
errors.append("Wrong label found at end of path: %s" % (res.label))
count += 1
if count != 3:
errors.append("out-out-out Incorrect vertex count returned: %d != %d" % (count, 3))
if count != 14:
errors.append("out-out-out Incorrect vertex count returned: %d != %d" % (count, 14))

count = 0
for res in O.query().V().in_().in_().in_():
if not res.gid.startswith("vertex1"):
if not res.gid in ["01", "08"]:
errors.append("Wrong vertex found at end of path: %s" % (res.gid))
if not res.label == "step1":
if not res.label == "Person":
errors.append("Wrong label found at end of path: %s" % (res.label))
count += 1
if count != 3:
errors.append("in-in-in Incorrect vertex count returned: %d != %d" % (count, 3))
if count != 14:
errors.append("in-in-in Incorrect vertex count returned: %d != %d" % (count, 14))

count = 0
for res in O.query().V().out().out().outE():
if not res['from'].startswith("vertex3"):
if not res['from'] in ["01", "02", "04", "05", "06", "08"]:
errors.append("Wrong 'from' vertex found at end of outE path: %s" % (res['from']))
if not res['to'].startswith("vertex4"):
if not res['to'] in ["01", "02", "03", "04", "05", "06", "08", "09", "40", "41", "42", "50"]:
errors.append("Wrong 'to' vertex found at end of ourE path: %s" % (res['to']))
if not res.label == "step":
if not res.label in ["likes", "knows", "friend", "parent", "enemy"]:
errors.append("Wrong label found at end of path: %s" % (res.label))
count += 1
if count != 3:
errors.append("out-out-outE Incorrect vertex count returned: %d != %d" % (count, 3))
if count != 14:
errors.append("out-out-outE Incorrect vertex count returned: %d != %d" % (count, 14))

count = 0
for res in O.query().V().out().out().outE().out():
if not res.gid.startswith("vertex4"):
if not res.gid in ["42", "41", "02", "03", "04", "08", "09", "05", "50", "40", "06", "01"]:
errors.append("Wrong vertex found at end of outE to out path: %s" % (res.gid))
if not res.label == "step4":
if not res.label in ["Movie", "Person", "Book"]:
errors.append("Wrong label found at end of outE to out path: %s" % (res.label))
count += 1
if count != 3:
errors.append("out-out-outE-out Incorrect vertex count returned: %d != %d" % (count, 3))
if count != 14:
errors.append("out-out-outE-out Incorrect vertex count returned: %d != %d" % (count, 14))

return errors

@@ -94,10 +63,10 @@ def test_path_2(O, man):

count = 0
for res in O.query().V().out().hasLabel("Person").out().out():
if not res.gid.startswith("vertex4"):
if not res.gid in ["01", "02", "03", "04", "05", "06", "08", "09", "40", "41", "42", "50"]:
errors.append("Wrong vertex found at end of hasLabel path: %s" % (res.gid))
count += 1
if count != 3:
if count != 14:
errors.append("out-hasLabel-out-out Incorrect vertex count returned: %d != %d" % (count, 3))

return errors

0 comments on commit 0e3e97b

Please sign in to comment.