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/03 18:21:03 UTC

[18/26] tinkerpop git commit: TINKERPOP-1784 Changed assertion logic and table formats in feature files

TINKERPOP-1784 Changed assertion logic and table formats in feature files


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

Branch: refs/heads/TINKERPOP-1784
Commit: 01a6d777fa0823f7720ee94dd3fc77dd53566602
Parents: 97f6ae6
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Sep 28 14:54:40 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Oct 3 14:19:52 2017 -0400

----------------------------------------------------------------------
 .../src/main/jython/radish/feature_steps.py     | 61 +++++------------
 gremlin-test/features/filter/Coin.feature       | 12 ++--
 gremlin-test/features/filter/Has.feature        | 10 +--
 gremlin-test/features/map/Count.feature         | 10 +--
 gremlin-test/features/map/Select.feature        |  4 +-
 gremlin-test/features/map/Vertex.feature        | 70 ++++++++++----------
 .../features/sideEffect/GroupCount.feature      | 41 ++++++------
 7 files changed, 89 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/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 2154536..7a4a30a 100644
--- a/gremlin-python/src/main/jython/radish/feature_steps.py
+++ b/gremlin-python/src/main/jython/radish/feature_steps.py
@@ -81,22 +81,24 @@ def __convert(val, ctx):
         for key, value in val.items():
             n[__convert(key, ctx)] = __convert(value, ctx)
         return n
-    elif isinstance(val, (str, unicode)) and re.match("^l\[.*\]$", val):         # parse list
+    elif isinstance(val, unicode):
+        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, unicode)) and re.match("^d\[.*\]$", val):         # parse numeric
+    elif isinstance(val, str) and re.match("^d\[.*\]$", val):         # parse numeric
         return long(val[2:-1])
-    elif isinstance(val, (str, unicode)) and re.match("^v\[.*\]\.id$", val):     # parse vertex id
+    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, unicode)) and re.match("^v\[.*\]$", val):         # parse vertex
+    elif isinstance(val, str) and re.match("^v\[.*\]$", val):         # parse vertex
         return ctx.lookup_v["modern"][val[2:-1]]
-    elif isinstance(val, (str, unicode)) and re.match("^e\[.*\]\.id$", val):     # parse edge id
+    elif isinstance(val, str) and re.match("^e\[.*\]\.id$", val):     # parse edge id
         return ctx.lookup_e["modern"][val[2:-4]].id
-    elif isinstance(val, (str, unicode)) and re.match("^e\[.*\]$", val):         # parse edge
+    elif isinstance(val, str) and re.match("^e\[.*\]$", val):         # parse edge
         return ctx.lookup_e["modern"][val[2:-1]]
-    elif isinstance(val, unicode):
-        return val.encode('utf-8')
+    elif isinstance(val, str) and re.match("^m\[.*\]$", val):         # parse json as a map
+        return __convert(json.loads(val[2:-1]), ctx)
     else:
-        return str(val)
+        return val
 
 
 def __ordered_assertion(step):
@@ -109,19 +111,7 @@ def __ordered_assertion(step):
     # the data to assert. the contents of the second column will be dependent on the type specified
     # in the first column
     for ix, line in enumerate(data):
-        if line[0] == "numeric":
-            assert_that(long(step.context.result[ix]), equal_to(long(line[1])))
-        elif line[0] == "string":
-            assert_that(str(step.context.result[ix]), equal_to(str(line[1])))
-        elif line[0] == "vertex":
-            assert_that(step.context.result[ix].label, equal_to(line[1]))
-        elif line[0] == "edge":
-            assert_that(step.context.result[ix].label, equal_to(line[1]))
-        elif line[0] == "map":
-            assert_that(__convert(step.context.result[ix], step.context), json.loads(line[1]))
-        else:
-            raise ValueError("unknown type of " + line[0])
-
+        assert_that(step.context.result[ix], equal_to(__convert(line[0], step.context)))
 
 def __unordered_assertion(step):
     data = step.table
@@ -134,30 +124,9 @@ def __unordered_assertion(step):
     # finds a match in the results for each line of data to assert and then removes that item
     # from the list - in the end there should be no items left over and each will have been asserted
     for line in data:
-        if line[0] == "numeric":
-            val = long(line[1])
-            assert_that(val, is_in(list(map(long, results_to_test))))
-            results_to_test.remove(val)
-        elif line[0] == "string":
-            val = str(line[1])
-            assert_that(val, is_in(list(map(str, results_to_test))))
-            results_to_test.remove(val)
-        elif line[0] == "vertex":
-            val = str(line[1])
-            v = step.context.lookup_v["modern"][val]
-            assert_that(v, is_in(results_to_test))
-            results_to_test.remove(v)
-        elif line[0] == "edge":
-            val = str(line[1])
-            e = step.context.lookup_e["modern"][val]
-            assert_that(e, is_in(results_to_test))
-            results_to_test.remove(e)
-        elif line[0] == "map":
-            val = __convert(json.loads(line[1]), step.context)
-            assert_that(val, is_in(results_to_test))
-            results_to_test.remove(val)
-        else:
-            raise ValueError("unknown type of " + line[0])
+        val = __convert(line[0], step.context)
+        assert_that(val, is_in(results_to_test))
+        results_to_test.remove(val)
 
     assert_that(len(results_to_test), is_(0))
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/filter/Coin.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Coin.feature b/gremlin-test/features/filter/Coin.feature
index 802ebdc..d1acc46 100644
--- a/gremlin-test/features/filter/Coin.feature
+++ b/gremlin-test/features/filter/Coin.feature
@@ -25,12 +25,12 @@ Feature: Step - coin()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko  |
-      | vertex | vadas  |
-      | vertex | lop    |
-      | vertex | josh   |
-      | vertex | ripple |
-      | vertex | peter  |
+      | v[marko] |
+      | v[vadas] |
+      | v[lop] |
+      | v[josh] |
+      | v[ripple] |
+      | v[peter]  |
 
 
   Scenario: g_V_coinX0X

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/filter/Has.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/filter/Has.feature b/gremlin-test/features/filter/Has.feature
index 4a2e085..8ff3a2b 100644
--- a/gremlin-test/features/filter/Has.feature
+++ b/gremlin-test/features/filter/Has.feature
@@ -25,8 +25,8 @@ Feature: Step - has()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | josh   |
-      | vertex | peter  |
+      | v[josh] |
+      | v[peter] |
 
   Scenario: Use hasId() with P
     Given the modern graph
@@ -37,7 +37,7 @@ Feature: Step - has()
     """
     When iterated to list
     Then the result should be unordered
-      | vertex | josh   |
-      | vertex | josh   |
-      | vertex | peter  |
+      | v[josh] |
+      | v[josh] |
+      | v[peter] |
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/map/Count.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature
index 1233ed3..b7f5c66 100644
--- a/gremlin-test/features/map/Count.feature
+++ b/gremlin-test/features/map/Count.feature
@@ -25,7 +25,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 6 |
+      | d[6] |
 
   Scenario: g_V_out_count
     Given the modern graph
@@ -35,7 +35,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 6 |
+      | d[6] |
 
   Scenario: g_V_both_both_count
     Given the modern graph
@@ -45,7 +45,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 30 |
+      | d[30] |
 
   Scenario: g_V_fold_countXlocalX
     Given the modern graph
@@ -55,7 +55,7 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 6 |
+      | d[6] |
 
   Scenario: g_V_hasXnoX_count
     Given the modern graph
@@ -65,4 +65,4 @@ Feature: Step - count()
       """
     When iterated to list
     Then the result should be ordered
-      | numeric | 0 |
\ No newline at end of file
+      | d[0] |
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/map/Select.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature
index b2d208c..9166954 100644
--- a/gremlin-test/features/map/Select.feature
+++ b/gremlin-test/features/map/Select.feature
@@ -26,5 +26,5 @@ Feature: Step - select()
       """
     When iterated to list
     Then the result should be unordered
-      | map | {"a": "v[marko]", "b": "v[vadas]"} |
-      | map | {"a": "v[marko]", "b": "v[josh]"} |
\ No newline at end of file
+      | m[{"a": "v[marko]", "b": "v[vadas]"}] |
+      | m[{"a": "v[marko]", "b": "v[josh]"}] |
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/map/Vertex.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/map/Vertex.feature b/gremlin-test/features/map/Vertex.feature
index 5bed2a6..9aa506c 100644
--- a/gremlin-test/features/map/Vertex.feature
+++ b/gremlin-test/features/map/Vertex.feature
@@ -26,9 +26,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | string | marko |
-      | string | vadas |
-      | string | lop |
+      | marko |
+      | vadas |
+      | lop |
 
   Scenario: g_VXlistXv1_v2_v3XX_name
     Given the modern graph
@@ -39,9 +39,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | string | marko |
-      | string | vadas |
-      | string | lop |
+      | marko |
+      | vadas |
+      | lop |
 
   Scenario: g_V
     Given the modern graph
@@ -51,12 +51,12 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko |
-      | vertex | vadas |
-      | vertex | lop |
-      | vertex | josh |
-      | vertex | ripple |
-      | vertex | peter |
+      | v[marko] |
+      | v[vadas] |
+      | v[lop] |
+      | v[josh] |
+      | v[ripple] |
+      | v[peter] |
 
   Scenario: g_VX1X_out
     Given the modern graph
@@ -67,9 +67,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | vadas |
-      | vertex | lop |
-      | vertex | josh |
+      | v[vadas] |
+      | v[lop] |
+      | v[josh] |
 
   Scenario: g_VX2X_in
     Given the modern graph
@@ -80,7 +80,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko |
+      | v[marko] |
 
   Scenario: g_VX4X_both
     Given the modern graph
@@ -91,9 +91,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | vertex | marko |
-      | vertex | lop |
-      | vertex | ripple |
+      | v[marko] |
+      | v[lop] |
+      | v[ripple] |
 
   Scenario: g_E
     Given the modern graph
@@ -103,12 +103,12 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | marko-created->lop |
-      | edge | marko-knows->josh |
-      | edge | marko-knows->vadas |
-      | edge | peter-created->lop |
-      | edge | josh-created->lop |
-      | edge | josh-created->ripple |
+      | e[marko-created->lop] |
+      | e[marko-knows->josh] |
+      | e[marko-knows->vadas] |
+      | e[peter-created->lop] |
+      | e[josh-created->lop] |
+      | e[josh-created->ripple] |
 
   Scenario: g_EX11X
     Given the modern graph
@@ -119,7 +119,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | josh-created->lop |
+      | e[josh-created->lop] |
 
   Scenario: g_VX1X_outE
     Given the modern graph
@@ -130,9 +130,9 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | marko-created->lop |
-      | edge | marko-knows->josh |
-      | edge | marko-knows->vadas |
+      | e[marko-created->lop] |
+      | e[marko-knows->josh] |
+      | e[marko-knows->vadas] |
 
   Scenario: g_VX2X_outE
     Given the modern graph
@@ -143,7 +143,7 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | marko-knows->vadas |
+      | e[marko-knows->vadas] |
 
   Scenario: g_VX4X_bothEXcreatedX
     Given the modern graph
@@ -154,8 +154,8 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | josh-created->lop |
-      | edge | josh-created->ripple |
+      | e[josh-created->lop] |
+      | e[josh-created->ripple] |
 
   Scenario: g_VX4X_bothE
     Given the modern graph
@@ -166,6 +166,6 @@ Feature: Step - V(), E(), out(), in(), both(), inE(), outE(), bothE()
       """
     When iterated to list
     Then the result should be unordered
-      | edge | josh-created->lop |
-      | edge | josh-created->ripple |
-      | edge | marko-knows->josh |
+      | e[josh-created->lop] |
+      | e[josh-created->ripple] |
+      | e[marko-knows->josh] |

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/01a6d777/gremlin-test/features/sideEffect/GroupCount.feature
----------------------------------------------------------------------
diff --git a/gremlin-test/features/sideEffect/GroupCount.feature b/gremlin-test/features/sideEffect/GroupCount.feature
index 7b4a0a6..bfb7363 100644
--- a/gremlin-test/features/sideEffect/GroupCount.feature
+++ b/gremlin-test/features/sideEffect/GroupCount.feature
@@ -25,24 +25,25 @@ Feature: Step - groupCount()
       """
     When iterated to list
     Then the result should be ordered
-      | map | {"ripple": 1, "lop": 3} |
+      | m[{"ripple": 1, "lop": 3}] |
 
-  Scenario: Edge count distribution
-    Given the modern graph
-    And the traversal of
-      """
-      g.V().groupCount().by(bothE().count())
-      """
-    When iterated to list
-    Then the result should be ordered
-      | map | {"d[1]": 3, "d[3]": 3} |
-
-  Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
-    Given the modern graph
-    And the traversal of
-      """
-      g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a")
-      """
-    When iterated to list
-    Then the result should be ordered
-      | map | {"v[marko]": 6, "v[vadas]": 2, "v[lop]": 6, "v[josh]": 6, "v[ripple]": 2, "v[peter]": 2} |
\ No newline at end of file
+# NOT SUPPORTED UNTIL GRAPHSON 3.X WHICH HAS SUPPORT FOR NON-STRING KEYS
+#  Scenario: Edge count distribution
+#    Given the modern graph
+#    And the traversal of
+#      """
+#      g.V().groupCount().by(bothE().count())
+#      """
+#    When iterated to list
+#    Then the result should be ordered
+#      | m[{"d[1]": 3, "d[3]": 3}] |
+#
+#  Scenario: Group count vertices, cap to retrieve the map and unfold it to group count again
+#    Given the modern graph
+#    And the traversal of
+#      """
+#      g.V().both().groupCount("a").out().cap("a").select(Column.keys).unfold().both().groupCount("a").cap("a")
+#      """
+#    When iterated to list
+#    Then the result should be ordered
+#      | m[{"v[marko]": 6, "v[vadas]": 2, "v[lop]": 6, "v[josh]": 6, "v[ripple]": 2, "v[peter]": 2}] |
\ No newline at end of file