Skip to content

Commit

Permalink
Fixing ot_distinct unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
kellrott committed Mar 19, 2020
1 parent 44ff839 commit edeb5ea
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions conformance/tests/ot_distinct.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@ def test_distinct(O, man):
count = 0
for i in O.query().V().distinct():
count += 1
if count != 25:
errors.append("Distinct %s != %s" % (count, 25))
if count != 39:
errors.append("Distinct %s != %s" % (count, 39))

count = 0
for i in O.query().V().distinct("_gid"):
count += 1
if count != 25:
errors.append("Distinct %s != %s" % (count, 25))
if count != 39:
errors.append("Distinct %s != %s" % (count, 39))

count = 0
for i in O.query().V().distinct("name"):
for i in O.query().V().distinct("eye_color"):
count += 1
if count != 23:
errors.append("Distinct %s != %s" % (count, 23))
if count != 8:
errors.append("Distinct %s != %s" % (count, 8))

count = 0
for i in O.query().V().distinct("lang"):
for i in O.query().V().distinct("gender"):
count += 1
if count != 3:
errors.append("Distinct %s != %s" % (count, 3))
if count != 4:
errors.append("Distinct %s != %s" % (count, 4))

count = 0
for i in O.query().V().distinct("non-existent-field"):
Expand All @@ -34,10 +34,16 @@ def test_distinct(O, man):
errors.append("Distinct %s != %s" % (count, 0))

count = 0
for i in O.query().V().hasLabel("Person").as_("person").out().distinct("$person.name"):
for i in O.query().V().hasLabel("Character").as_("person").out().distinct("$person.name"):
count += 1
if count != 5:
errors.append("Distinct O.query().V().hasLabel(\"Person\").as_(\"person\").out().distinct(\"$person.name\") %s != %s" % (count, 5))
if count != 18:
errors.append("Distinct O.query().V().hasLabel(\"Person\").as_(\"person\").out().distinct(\"$person.name\") %s != %s" % (count, 18))

count = 0
for i in O.query().V().hasLabel("Character").as_("person").out().distinct("$person.eye_color"):
count += 1
if count != 8:
errors.append("Distinct O.query().V().hasLabel(\"Person\").as_(\"person\").out().distinct(\"$person.eye_color\") %s != %s" % (count, 8))

return errors

Expand All @@ -48,9 +54,12 @@ def test_distinct_multi(O, man):
man.setGraph("swapi")

count = 0
for i in O.query().V().as_("a").out().distinct(["$a.name", "_gid"]).render(["$a.name", "_gid"]):
o = {}
for i in O.query().V().as_("a").out().distinct(["$a.eye_color", "_gid"]).render(["$a.eye_color", "_gid"]):
if i[0] in o and o[i[0]] != i[1]:
errors.append("Non-unique pair returned: %s" % (i))
count += 1
if count != 14:
errors.append("Distinct multi %s != %s" % (count, 14))
if count != 68:
errors.append("Distinct multi %s != %s" % (count, 68))

return errors

0 comments on commit edeb5ea

Please sign in to comment.