TINKERPOP-1784 Get all count() tests working

Needed to add support for cleaning up traversal strings to more properly handle 
reserved python words.


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

Branch: refs/heads/TINKERPOP-1784
Commit: b8df418bcecd4d5775c8094bf338834f03eb9f16
Parents: a0378c9
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Mon Oct 2 14:59:59 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Mon Oct 30 13:23:34 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 15 ++++---
 gremlin-test/features/map/Count.feature         | 45 +++++++++++++++++++-
 .../gremlin/process/FeatureCoverageTest.java    |  6 ++-
 3 files changed, 59 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b8df418b/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 5b11ca1..11cc86e 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -25,8 +25,9 @@ from gremlin_python.process.traversal import P, Scope, 
Column, Direction
 from radish import given, when, then
 from hamcrest import *
 
-regex_as = re.compile(r"\.as\(")
-regex_in = re.compile(r"\.in\(")
+regex_as = re.compile(r"([(.])as\(")
+regex_in = re.compile(r"([(.])in\(")
+regex_is = re.compile(r"([(.])is\(")
 
 
 @given("the {graph_name:w} graph")
@@ -57,11 +58,14 @@ def translate_traversal(step):
          "Direction": Direction,
          "P": P,
          "Scope": Scope,
-         "bothE": __.bothE}
+         "bothE": __.bothE,
+         "in_": __.in_,
+         "out": __.out}
 
     if hasattr(step.context, "traversal_params"):
         b.update(step.context.traversal_params)
 
+    print __translate(step.text)
     step.context.traversal = eval(__translate(step.text), b)
 
 
@@ -137,5 +141,6 @@ def __table_assertion(data, result, ctx, ordered):
 
 
 def __translate(traversal):
-    replaced = regex_as.sub(".as_(", traversal)
-    return regex_in.sub(".in_(", replaced)
+    replaced = regex_as.sub(r"\1as_(", traversal)
+    replaced = regex_is.sub(r"\1is_(", replaced)
+    return regex_in.sub(r"\1in_(", replaced)

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b8df418b/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature 
b/gremlin-test/features/map/Count.feature
index b7f5c66..5faa975 100644
--- a/gremlin-test/features/map/Count.feature
+++ b/gremlin-test/features/map/Count.feature
@@ -65,4 +65,47 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | d[0] |
\ No newline at end of file
+      | d[0] |
+
+  Scenario: g_V_whereXinXkknowsX_outXcreatedX_count_is_0XX_name
+    Given the modern graph
+    And the traversal of
+      """
+      g.V().where(in("knows").out("created").count().is(0)).values("name")
+      """
+    When iterated to list
+    Then the result should be unordered
+      | marko |
+      | lop  |
+      | ripple |
+      | peter |
+
+  Scenario: g_V_repeatXoutX_timesX8X_count
+    Given the grateful graph
+    And the traversal of
+      """
+      g.V().repeat(out()).times(8).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | d[2505037961767380] |
+
+  Scenario: 
g_V_repeatXoutX_timesX5X_asXaX_outXwrittenByX_asXbX_selectXa_bX_count
+    Given the grateful graph
+    And the traversal of
+      """
+      
g.V().repeat(out()).times(5).as("a").out("writtenBy").as("b").select("a", 
"b").count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | d[24309134024] |
+
+  Scenario: g_V_repeatXoutX_timesX3X_count
+    Given the grateful graph
+    And the traversal of
+      """
+      g.V().repeat(out()).times(3).count()
+      """
+    When iterated to list
+    Then the result should be ordered
+      | d[14465066] |

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/b8df418b/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 d3212a4..00975be 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
@@ -19,6 +19,7 @@
 package org.apache.tinkerpop.gremlin.process;
 
 import org.apache.tinkerpop.gremlin.process.traversal.step.filter.CoinTest;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.CountTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexTest;
 import org.junit.Test;
 
@@ -53,7 +54,10 @@ public class FeatureCoverageTest {
     public void shouldImplementAllProcessTestsAsFeatures() throws Exception {
 
         // TEMPORARY while test framework is under development - all tests 
should ultimately be included
-        final List<Class<?>> temp = Arrays.asList(CoinTest.class, 
VertexTest.class);
+        final List<Class<?>> temp = Arrays.asList(
+                CoinTest.class,
+                CountTest.class,
+                VertexTest.class);
 
         final Field field = 
ProcessStandardSuite.class.getDeclaredField("testsToEnforce");
         field.setAccessible(true);

Reply via email to