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/11/02 17:38:19 UTC
[22/50] tinkerpop git commit: TINKERPOP-1784 Added test for drop()
and graph init language
TINKERPOP-1784 Added test for drop() and graph init language
Graph init language provides a way to add data to an empty graph as part of a scenario.
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/5b6409b2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/5b6409b2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/5b6409b2
Branch: refs/heads/TINKERPOP-1784
Commit: 5b6409b2f08fd2cabce79e8cc2beb633f12e85e5
Parents: d4249d8
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Oct 17 15:20:28 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Nov 2 13:37:23 2017 -0400
----------------------------------------------------------------------
.../src/main/jython/radish/feature_steps.py | 53 ++++++++++------
gremlin-test/features/filter/Drop.feature | 63 ++++++++++++++++++++
.../gremlin/process/FeatureCoverageTest.java | 2 +
3 files changed, 101 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5b6409b2/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 5040896..a0fcd9b 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -36,10 +36,19 @@ regex_or = re.compile(r"([(.,\s])or\(")
@given("the {graph_name:w} graph")
def choose_graph(step, graph_name):
- # only have modern atm but graphName would be used to select the right one
step.context.g = Graph().traversal().withRemote(step.context.remote_conn[graph_name])
+@given("the graph initializer of")
+def initialize_graph(step):
+ traversal = _make_traversal(step.context.g, step.text, {})
+
+ # just be sure that the traversal returns something to prove that it worked to some degree. probably
+ # is overkill to try to assert the complete success of this init operation. presumably the test
+ # suite would fail elsewhere if this didn't work which would help identify a problem.
+ assert len(traversal.toList()) > 0
+
+
@given("an unsupported test")
def unsupported_scenario(step):
# this is a do nothing step as the test can't be supported for whatever reason
@@ -56,22 +65,9 @@ def add_parameter(step, param_name, param):
@given("the traversal of")
def translate_traversal(step):
- g = step.context.g
- b = {"g": g,
- "__": __,
- "Column": Column,
- "Direction": Direction,
- "Order": Order,
- "P": P,
- "Pick": Pick,
- "Scope": Scope,
- "T": T}
-
- if hasattr(step.context, "traversal_params"):
- b.update(step.context.traversal_params)
-
- # print _translate(step.text + " - " + str(b))
- step.context.traversal = eval(_translate(step.text), b)
+ step.context.traversal = _make_traversal(
+ step.context.g, step.text,
+ step.context.traversal_params if hasattr(step.context, "traversal_params") else {})
@when("iterated to list")
@@ -96,6 +92,12 @@ def assert_result(step, characterized_as):
raise ValueError("unknown data characterization of " + characterized_as)
+@then("the graph should return {count:d} for count of {traversal_string:QuotedString}")
+def assert_side_effects(step, count, traversal_string):
+ t = _make_traversal(step.context.g, traversal_string, {})
+ assert_that(count, equal_to(t.count().next()))
+
+
@then("nothing should happen because")
def nothing_happening(step):
return
@@ -177,3 +179,20 @@ def _translate(traversal):
replaced = regex_not.sub(r"\1not_(", replaced)
replaced = regex_or.sub(r"\1or_(", replaced)
return regex_in.sub(r"\1in_(", replaced)
+
+
+def _make_traversal(g, traversal_string, params):
+ b = {"g": g,
+ "__": __,
+ "Column": Column,
+ "Direction": Direction,
+ "Order": Order,
+ "P": P,
+ "Pick": Pick,
+ "Scope": Scope,
+ "T": T}
+
+ b.update(params)
+
+ # print _translate(step.text + " - " + str(b))
+ return eval(_translate(traversal_string), b)
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5b6409b2/gremlin-test/features/filter/Drop.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Drop.feature b/gremlin-test/features/filter/Drop.feature
new file mode 100644
index 0000000..753b377
--- /dev/null
+++ b/gremlin-test/features/filter/Drop.feature
@@ -0,0 +1,63 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+Feature: Step - drop()
+
+ Scenario: g_V_drop
+ Given the empty graph
+ And the graph initializer of
+ """
+ g.addV().as("a").addV().as("b").addE("knows").to("a")
+ """
+ And the traversal of
+ """
+ g.V().drop()
+ """
+ When iterated to list
+ Then the result should be empty
+ And the graph should return 0 for count of "g.V()"
+ And the graph should return 0 for count of "g.E()"
+
+ Scenario: g_V_outE_drop
+ Given the empty graph
+ And the graph initializer of
+ """
+ g.addV().as("a").addV().as("b").addE("knows").to("a")
+ """
+ And the traversal of
+ """
+ g.V().outE().drop()
+ """
+ When iterated to list
+ Then the result should be empty
+ And the graph should return 2 for count of "g.V()"
+ And the graph should return 0 for count of "g.E()"
+
+ Scenario: g_V_properties_drop
+ Given the empty graph
+ And the graph initializer of
+ """
+ g.addV().property("name","bob").addV().property("name","alice")
+ """
+ And the traversal of
+ """
+ g.V().properties().drop()
+ """
+ When iterated to list
+ Then the result should be empty
+ And the graph should return 2 for count of "g.V()"
+ And the graph should return 0 for count of "g.V().properties()"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/5b6409b2/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
index 7c53cb9..1f52581 100644
--- a/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
+++ b/gremlin-test/src/test/java/org/apache/tinkerpop/gremlin/process/FeatureCoverageTest.java
@@ -22,6 +22,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.branch.BranchTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.ChooseTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.branch.OptionalTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.DropTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PathTest;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
@@ -67,6 +68,7 @@ public class FeatureCoverageTest {
OptionalTest.class,
// filter
CoinTest.class,
+ DropTest.class,
// map
CountTest.class,
PathTest.class,