-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command line args to server func
- Loading branch information
1 parent
928a38d
commit 66465ea
Showing
7 changed files
with
462 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,42 @@ | ||
|
||
attr_len_func = """ | ||
function attr_len(x) { | ||
x["skin_colors_len"] = x["skin_colors"].length; | ||
x["hair_colors_len"] = x["hair_colors"].length; | ||
x["eye_colors_len"] = x["eye_colors"].length; | ||
return [x] | ||
} | ||
""" | ||
|
||
def test_flatmap(man): | ||
attr_len_func = """ | ||
function attr_len(x, args) { | ||
x["skin_colors_len"] = x["skin_colors"].length; | ||
x["hair_colors_len"] = x["hair_colors"].length; | ||
x["eye_colors_len"] = x["eye_colors"].length; | ||
return [x] | ||
} | ||
""" | ||
|
||
errors = [] | ||
|
||
G = man.setGraph("swapi") | ||
|
||
count = 0 | ||
q = G.query().V().hasLabel("Species").flatMap("attr_len", attr_len_func) | ||
q = G.query().V().hasLabel("Species").flatMap("attr_len", attr_len_func, {}) | ||
for row in q: | ||
count += 1 | ||
if row["data"]["skin_colors_len"] != len(row["data"]["skin_colors"]): | ||
errors.append("count function not correct") | ||
if count != 5: | ||
errors.append("Incorrect row count returned: %d != 5" % (count)) | ||
return errors | ||
return errors | ||
|
||
|
||
def test_command_line_args(man): | ||
func = """ | ||
function AddObj(x, args) { | ||
for (var k in args){ | ||
x[k]= args[k] | ||
} | ||
return [x] | ||
} | ||
""" | ||
|
||
errors = [] | ||
G = man.setGraph("swapi") | ||
q = G.query().V().hasLabel("Species").flatMap("AddObj", func, {"OtherSpecies":["Sullustan", "RathStar", "Bith"]}) | ||
for row in q: | ||
if "OtherSpecies" not in row['data'] or not all(species in row['data']["OtherSpecies"] for species in ["Sullustan", "RathStar", "Bith"]): | ||
errors.append("Appended items '{'OtherSpecies':['Sullustan', 'RathStar', 'Bith']}' Not Present in row") | ||
return errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters