Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DC2D5200D0F for ; Fri, 29 Sep 2017 20:00:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DAB171609BC; Fri, 29 Sep 2017 18:00:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D0633160BEA for ; Fri, 29 Sep 2017 20:00:16 +0200 (CEST) Received: (qmail 45069 invoked by uid 500); 29 Sep 2017 18:00:16 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 44953 invoked by uid 99); 29 Sep 2017 18:00:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Sep 2017 18:00:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7C90FDFA25; Fri, 29 Sep 2017 18:00:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: spmallette@apache.org To: commits@tinkerpop.apache.org Date: Fri, 29 Sep 2017 18:00:36 -0000 Message-Id: In-Reply-To: <3378e2c2c96843d3996a60727dc75f6e@git.apache.org> References: <3378e2c2c96843d3996a60727dc75f6e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [23/24] tinkerpop git commit: TINKERPOP-1784 Added test for select in GLV tests archived-at: Fri, 29 Sep 2017 18:00:19 -0000 TINKERPOP-1784 Added test for select in GLV tests Included infrastructure for validating maps and refactored other related code. Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/ebb15a52 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/ebb15a52 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/ebb15a52 Branch: refs/heads/TINKERPOP-1784 Commit: ebb15a525565421a16134365a81596266d138d28 Parents: 97bf935 Author: Stephen Mallette Authored: Sat Sep 23 07:12:07 2017 -0400 Committer: Stephen Mallette Committed: Fri Sep 29 13:59:57 2017 -0400 ---------------------------------------------------------------------- .../src/main/jython/radish/feature_steps.py | 76 ++++++++++++-------- gremlin-test/features/map/Select.feature | 30 ++++++++ 2 files changed, 75 insertions(+), 31 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ebb15a52/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 35103f3..8ef0f1b 100644 --- a/gremlin-python/src/main/jython/radish/feature_steps.py +++ b/gremlin-python/src/main/jython/radish/feature_steps.py @@ -32,14 +32,27 @@ def choose_graph(step, graph_name): step.context.g = Graph().traversal().withRemote(step.context.remote_conn[graph_name]) +@given("using the parameter {param_name:w} is {param:QuotedString}") +def add_parameter(step, param_name, param): + if not hasattr(step.context, "traversal_params"): + step.context.traversal_params = {} + + step.context.traversal_params[param_name.encode('utf-8')] = __convert(param, step.context) + + @given("the traversal of") def translate_traversal(step): g = step.context.g - step.context.traversal = eval(step.text, {"g": g, - "Column": Column, - "P": P, - "Scope": Scope, - "bothE": __.bothE}) + b = {"g": g, + "Column": Column, + "P": P, + "Scope": Scope, + "bothE": __.bothE} + + if hasattr(step.context, "traversal_params"): + b.update(step.context.traversal_params) + + step.context.traversal = eval(step.text, b) @when("iterated to list") @@ -47,18 +60,32 @@ def iterate_the_traversal(step): step.context.result = step.context.traversal.toList() -def __convert(m, ctx): - # transform string map keys from the test spec to numbers when it encounters the appropriate patterns - n = {} - for key, value in m.items(): - if re.match("d\[.*\]", key): - n[long(key[2:-1])] = value - elif re.match("v\[.*\]", key): - n[ctx.lookup["modern"][key[2:-1]]] = value - else: - n[key] = value +@then("the result should be {characterized_as:w}") +def assert_result(step, characterized_as): + if characterized_as == "empty": + assert_that(len(step.context.result), equal_to(0)) + elif characterized_as == "ordered": + __ordered_assertion(step) + elif characterized_as == "unordered": + __unordered_assertion(step) + else: + raise ValueError("unknown data characterization of " + characterized_as) + - return n +def __convert(val, ctx): + if isinstance(val, dict): + n = {} + for key, value in val.items(): + n[__convert(key, ctx)] = __convert(value, ctx) + return n + elif isinstance(val, (str, unicode)) and re.match("d\[.*\]", val): + return long(val[2:-1]) + elif isinstance(val, (str, unicode)) and re.match("v\[.*\]", val): + return ctx.lookup["modern"][val[2:-1]] + elif isinstance(val, unicode): + return val.encode('utf-8') + else: + return str(val) def __ordered_assertion(step): @@ -108,23 +135,10 @@ def __unordered_assertion(step): assert_that(v, is_in(results_to_test)) results_to_test.remove(v) elif line[0] == "map": - val = __convert(json.load(line[1]), step.context) + 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]) - assert_that(len(results_to_test), is_(0)) - - -@then("the result should be {characterized_as:w}") -def assert_result(step, characterized_as): - if characterized_as == "empty": - assert_that(len(step.context.result), equal_to(0)) - elif characterized_as == "ordered": - __ordered_assertion(step) - elif characterized_as == "unordered": - __unordered_assertion(step) - else: - raise ValueError("unknown data characterization of " + characterized_as) - + assert_that(len(results_to_test), is_(0)) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/ebb15a52/gremlin-test/features/map/Select.feature ---------------------------------------------------------------------- diff --git a/gremlin-test/features/map/Select.feature b/gremlin-test/features/map/Select.feature new file mode 100644 index 0000000..e64417a --- /dev/null +++ b/gremlin-test/features/map/Select.feature @@ -0,0 +1,30 @@ +# 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 - select() + + Scenario: Select vertices + Given the modern graph + And using the parameter v1 is "v[marko]" + And the traversal of + """ + g.V(v1).as_("a").out("knows").as_("b").select("a", "b") + """ + 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