tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [34/50] tinkerpop git commit: TINKERPOP-1784 Added tests for store()
Date Thu, 26 Oct 2017 17:15:26 GMT
TINKERPOP-1784 Added tests for store()

Needed to account for floats vs longs with d[x]


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/b6b9cea5
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/b6b9cea5
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/b6b9cea5

Branch: refs/heads/TINKERPOP-1784
Commit: b6b9cea57bd8b8604474d4aeb969b08bf286562d
Parents: 74951c3
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Wed Oct 18 15:30:16 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Thu Oct 26 13:14:37 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     |  4 +-
 gremlin-test/features/sideEffect/Store.feature  | 84 ++++++++++++++++++++
 .../gremlin/process/FeatureCoverageTest.java    |  4 +-
 3 files changed, 90 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6b9cea5/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 f348ccb..0d71f78 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -124,8 +124,10 @@ def _convert(val, ctx):
         return _convert(val.encode('utf-8'), ctx)
     elif isinstance(val, str) and re.match("^l\[.*\]$", val):         # parse list
         return list(map((lambda x: _convert(x, ctx)), val[2:-1].split(",")))
+    elif isinstance(val, str) and re.match("^s\[.*\]$", val):         # parse set
+        return set(map((lambda x: _convert(x, ctx)), val[2:-1].split(",")))
     elif isinstance(val, str) and re.match("^d\[.*\]$", val):         # parse numeric
-        return long(val[2:-1])
+        return float(val[2:-1]) if val[2:-1].__contains__(".") else long(val[2:-1])
     elif isinstance(val, str) and re.match("^v\[.*\]\.id$", val):     # parse vertex id
         return ctx.lookup_v["modern"][val[2:-4]].id
     elif isinstance(val, str) and re.match("^v\[.*\]\.sid$", val):    # parse vertex id as
string

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6b9cea5/gremlin-test/features/sideEffect/Store.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/Store.feature b/gremlin-test/features/sideEffect/Store.feature
new file mode 100644
index 0000000..ef66c5e
--- /dev/null
+++ b/gremlin-test/features/sideEffect/Store.feature
@@ -0,0 +1,84 @@
+# 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 - store()
+
+  Scenario: g_V_storeXa_nameX_out_capXaX
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().store("a").by("name").out().cap("a")      
+      """
+    When iterated next
+    Then the result should be unordered
+      | marko |
+      | vadas |
+      | lop |
+      | josh |
+      | ripple |
+      | peter  |
+
+  Scenario: g_VX1X_storeXaX_byXnameX_out_storeXaX_byXnameX_name_capXaX
+    Given the modern graph
+    And using the parameter v1Id defined as "v[marko].id"
+    And the traversal of
+      """
+      g.V(v1Id).store("a").by("name").out().store("a").by("name").values("name").cap("a")
+      """
+    When iterated next
+    Then the result should be unordered
+      | marko |
+      | vadas |
+      | lop |
+      | josh |
+
+  Scenario: g_withSideEffectXa_setX_V_both_name_storeXaX_capXaX
+    Given the modern graph
+    And using the parameter v1Id defined as "v[marko].id"
+    And using the parameter initial defined as "s[]"
+    And the traversal of
+      """
+      g.withSideEffect("a", initial).V().both().values("name").store("a").cap("a")
+      """
+    When iterated next
+    Then nothing should happen because
+      """
+      The result returned is not supported under GraphSON 2.x and therefore cannot be properly
asserted. More
+      specifically it requires specification of a Set as a parameter which only becomes available
in
+      GraphSON 3.0.
+      """
+
+  Scenario: g_V_storeXaX_byXoutEXcreatedX_countX_out_out_storeXaX_byXinEXcreatedX_weight_sumX
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().store("a").
+             by(__.outE("created").count()).
+        out().out().store("a").
+                      by(__.inE("created").values("weight").sum()).
+        cap("a")
+      """
+    When iterated next
+    Then the result should be unordered
+      | d[1] |
+      | d[1] |
+      | d[0] |
+      | d[0] |
+      | d[0] |
+      | d[2] |
+      | d[1.0] |
+      | d[1.0] |
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b6b9cea5/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 d8ffc53..09344b4 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
@@ -30,6 +30,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.AggregateTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.GroupCountTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.InjectTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.StoreTest;
 import org.junit.Test;
 
 import java.io.BufferedReader;
@@ -79,7 +80,8 @@ public class FeatureCoverageTest {
                 // sideEffect
                 AggregateTest.class,
                 GroupCountTest.class,
-                InjectTest.class);
+                InjectTest.class,
+                StoreTest.class);
 
         final Field field = ProcessStandardSuite.class.getDeclaredField("testsToEnforce");
         field.setAccessible(true);


Mime
View raw message