You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/10/16 15:20:35 UTC
[22/47] tinkerpop git commit: TINKERPOP-1784 Added more select() tests
TINKERPOP-1784 Added more select() tests
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b582a226
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b582a226
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b582a226
Branch: refs/heads/TINKERPOP-1784
Commit: b582a22677d3facd68b56b644cf604a2eb1fa67f
Parents: 2a2a643
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Oct 5 11:49:19 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Oct 16 11:19:30 2017 -0400
----------------------------------------------------------------------
.../src/main/jython/radish/feature_steps.py | 10 +-
gremlin-test/features/map/Select.feature | 158 ++++++++++++++++++-
2 files changed, 163 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b582a226/gremlin-python/src/main/jython/radish/feature_steps.py
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/jython/radish/feature_steps.py b/gremlin-python/src/main/jython/radish/feature_steps.py
index 16120f6..a2efb67 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -21,13 +21,13 @@ import json
import re
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
-from gremlin_python.process.traversal import P, Scope, Column, Direction, T
+from gremlin_python.process.traversal import P, Scope, Column, Order, Direction, T
from radish import given, when, then
from hamcrest import *
-regex_as = re.compile(r"([(.])as\(")
-regex_in = re.compile(r"([(.])in\(")
-regex_is = re.compile(r"([(.])is\(")
+regex_as = re.compile(r"([(.,\s])as\(")
+regex_in = re.compile(r"([(.,\s])in\(")
+regex_is = re.compile(r"([(.,\s])is\(")
@given("the {graph_name:w} graph")
@@ -57,10 +57,12 @@ def translate_traversal(step):
"__": __,
"Column": Column,
"Direction": Direction,
+ "Order": Order,
"P": P,
"gt": P.gt,
"Scope": Scope,
"T": T,
+ "as_": __.as_,
"bothE": __.bothE,
"in_": __.in_,
"out": __.out,
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b582a226/gremlin-test/features/map/Select.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
index 13114d5..9df72a8 100644
--- a/gremlin-test/features/map/Select.feature
+++ b/gremlin-test/features/map/Select.feature
@@ -108,4 +108,160 @@ Feature: Step - select()
| m[{"a": "josh", "b": "josh"}] |
| m[{"a": "ripple", "b": "ripple"}] |
| m[{"a": "lop", "b": "lop"}] |
- | m[{"a": "peter", "b": "peter"}] |
\ No newline at end of file
+ | m[{"a": "peter", "b": "peter"}] |
+
+ Scenario: g_V_hasXname_gremlinX_inEXusesX_order_byXskill_incrX_asXaX_outV_asXbX_selectXa_bX_byXskillX_byXnameX
+ Given the crew graph
+ And the traversal of
+ """
+ g.V().has("name", "gremlin").inE("uses").order().by("skill", Order.incr).as("a").outV().as("b").select("a", "b").by("skill").by("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | m[{"a": 3, "b": "matthias"}] |
+ | m[{"a": 4, "b": "marko"}] |
+ | m[{"a": 5, "b": "stephen"}] |
+ | m[{"a": 5, "b": "daniel"}] |
+
+ Scenario: g_V_hasXname_isXmarkoXX_asXaX_selectXaX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().has("name", __.is("marko")).as("a").select("a")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | v[marko] |
+
+ Scenario: g_V_label_groupCount_asXxX_selectXxX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().label().groupCount().as("x").select("x")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | m[{"software": 2, "person": 4}] |
+
+ Scenario: g_V_hasLabelXpersonX_asXpX_mapXbothE_label_groupCountX_asXrX_selectXp_rX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().hasLabel("person").as("p").map(__.bothE().label().groupCount()).as("r").select("p", "r")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | m[{"p": "v[marko]", "r": {"created": 1, "knows": 2}}] |
+ | m[{"p": "v[vadas]", "r": {"knows": 1}}] |
+ | m[{"p": "v[josh]", "r": {"created": 2, "knows": 1}}] |
+ | m[{"p": "v[peter]", "r": {"created": 1}}] |
+
+ Scenario: g_V_chooseXoutE_count_isX0X__asXaX__asXbXX_chooseXselectXaX__selectXaX__selectXbXX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().choose(__.outE().count().is(0L), __.as("a"), __.as("b")).choose(__.select("a"), __.select("a"), __.select("b"))
+ """
+ When iterated to list
+ Then the result should be unordered
+ | v[marko] |
+ | v[vadas] |
+ | v[lop] |
+ | v[josh] |
+ | v[ripple] |
+ | v[peter] |
+
+ Scenario: g_VX1X_asXhereX_out_selectXhereX
+ Given the modern graph
+ And using the parameter v1Id is "v[marko].id"
+ And the traversal of
+ """
+ g.V(v1Id).as("here").out().select("here")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | v[marko] |
+ | v[marko] |
+ | v[marko] |
+
+ Scenario: g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX
+ Given the modern graph
+ And using the parameter v4Id is "v[josh].id"
+ And the traversal of
+ """
+ g.V(v4Id).as("here").out().select("here")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | v[josh] |
+ | v[josh] |
+
+ Scenario: g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX_name
+ Given the modern graph
+ And using the parameter v4Id is "v[josh].id"
+ And the traversal of
+ """
+ g.V(v4Id).out().as("here").has("lang", "java").select("here").values("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | ripple |
+ | lop |
+
+ Scenario: g_VX1X_outE_asXhereX_inV_hasXname_vadasX_selectXhereX
+ Given the modern graph
+ And using the parameter v1Id is "v[marko].id"
+ And the traversal of
+ """
+ g.V(v1Id).outE().as("here").inV().has("name", "vadas").select("here")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | e[marko-knows->vadas] |
+
+ Scenario: g_VX1X_outEXknowsX_hasXweight_1X_asXhereX_inV_hasXname_joshX_selectXhereX
+ Given the modern graph
+ And using the parameter v1Id is "v[marko].id"
+ And the traversal of
+ """
+ g.V(v1Id).outE("knows").has("weight", 1.0).as("here").inV().has("name", "josh").select("here")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | e[marko-knows->josh] |
+
+ Scenario: g_VX1X_outEXknowsX_asXhereX_hasXweight_1X_asXfakeX_inV_hasXname_joshX_selectXhereX
+ Given the modern graph
+ And using the parameter v1Id is "v[marko].id"
+ And the traversal of
+ """
+ g.V(v1Id).outE("knows").as("here").has("weight", 1.0).as("fake").inV().has("name", "josh").select("here")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | e[marko-knows->josh] |
+
+ Scenario: g_V_asXhereXout_name_selectXhereX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().as("here").out().values("name").select("here")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | v[marko] |
+ | v[marko] |
+ | v[marko] |
+ | v[josh] |
+ | v[josh] |
+ | v[peter] |
+
+ Scenario: g_V_outXcreatedX_unionXasXprojectX_inXcreatedX_hasXname_markoX_selectXprojectX__asXprojectX_inXcreatedX_inXknowsX_hasXname_markoX_selectXprojectXX_groupCount_byXnameX
+ Given the modern graph
+ And the traversal of
+ """
+ g.V().out("created").union(as("project").in("created").has("name", "marko").select("project"),as("project").in("created").in("knows").has("name", "marko").select("project")).groupCount().by("name")
+ """
+ When iterated to list
+ Then the result should be unordered
+ | m[{"ripple": 1, "lop": 6}] |
\ No newline at end of file