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 DC250200D35 for ; Fri, 29 Sep 2017 16:30:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DACDA1609ED; Fri, 29 Sep 2017 14:30:37 +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 14038160BCB for ; Fri, 29 Sep 2017 16:30:36 +0200 (CEST) Received: (qmail 26289 invoked by uid 500); 29 Sep 2017 14:30:31 -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 26224 invoked by uid 99); 29 Sep 2017 14:30:31 -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 14:30:31 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 8A24FF5C17; Fri, 29 Sep 2017 14:30:30 +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 14:30:42 -0000 Message-Id: <37ba040b8dff442b8fa341a81a9fef7d@git.apache.org> In-Reply-To: <2f61d79b2c1d4329a44cc1a9f48fd06d@git.apache.org> References: <2f61d79b2c1d4329a44cc1a9f48fd06d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [13/28] tinkerpop git commit: TINKERPOP-1784 Added coin() gherkin tests and refactored python archived-at: Fri, 29 Sep 2017 14:30:38 -0000 TINKERPOP-1784 Added coin() gherkin tests and refactored python Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/61ba8008 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/61ba8008 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/61ba8008 Branch: refs/heads/TINKERPOP-1784 Commit: 61ba8008233dfd8c8af94356fd17db5909ead5b2 Parents: 4436711 Author: Stephen Mallette Authored: Wed Sep 20 18:38:49 2017 -0400 Committer: Stephen Mallette Committed: Fri Sep 29 07:21:24 2017 -0400 ---------------------------------------------------------------------- .../main/jython/radish/count_features_step.py | 50 ------------- .../src/main/jython/radish/feature_steps.py | 77 ++++++++++++++++++++ gremlin-test/features/map/Coin.feature | 42 +++++++++++ gremlin-test/features/map/Count.feature | 46 ++++++------ 4 files changed, 144 insertions(+), 71 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/61ba8008/gremlin-python/src/main/jython/radish/count_features_step.py ---------------------------------------------------------------------- diff --git a/gremlin-python/src/main/jython/radish/count_features_step.py b/gremlin-python/src/main/jython/radish/count_features_step.py deleted file mode 100644 index ec04551..0000000 --- a/gremlin-python/src/main/jython/radish/count_features_step.py +++ /dev/null @@ -1,50 +0,0 @@ -''' -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. -''' - -from gremlin_python.structure.graph import Graph -from gremlin_python.process.graph_traversal import __ -from gremlin_python.process.traversal import Scope -from radish import before, given, when, then - -out = __.out - - -@given("the {graphName:w} graph") -def choose_graph(step, graphName): - # only have modern atm but graphName would be used to select the right one - step.context.g = Graph().traversal().withRemote(step.context.remote_conn_modern) - - -@given("the traversal of") -def translate_traversal(step): - g = step.context.g - step.context.traversal = eval(step.text, {"g": g, "Scope": Scope}) - - -@when("iterating") -def iterate_the_traversal(step): - step.context.result = step.context.traversal.toList() - - -@then("the result should be {number:d}") -def assert_single_result_of_number(step, number): - assert len(step.context.result) == 1 - assert step.context.result[0] == number - - http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/61ba8008/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 new file mode 100644 index 0000000..61297ff --- /dev/null +++ b/gremlin-python/src/main/jython/radish/feature_steps.py @@ -0,0 +1,77 @@ +''' +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. +''' + +from gremlin_python.structure.graph import Graph +from gremlin_python.process.graph_traversal import __ +from gremlin_python.process.traversal import Scope +from radish import before, given, when, then + +out = __.out + + +@given("the {graphName:w} graph") +def choose_graph(step, graphName): + # only have modern atm but graphName would be used to select the right one + step.context.g = Graph().traversal().withRemote(step.context.remote_conn_modern) + + +@given("the traversal of") +def translate_traversal(step): + g = step.context.g + step.context.traversal = eval(step.text, {"g": g, "Scope": Scope}) + + +@when("iterated to list") +def iterate_the_traversal(step): + step.context.result = step.context.traversal.toList() + + +@then("the result should be {characterized_as:w}") +def assert_result(step, characterized_as): + if characterized_as == "empty": + assert len(step.context.result) == 0 + elif characterized_as == "ordered": + data = step.table + + # results from traversal should have the same number of entries as the feature data table + assert len(step.context.result) == len(data) + + # assert the results by type where the first column will hold the type and the second column + # the data to assert. the contents of the second column will be dependent on the type specified + # in te first column + for ix, line in enumerate(data): + if line[0] == "numeric": + assert long(step.context.result[ix]) == long(line[1]) + elif line[0] == "string": + assert str(step.context.result[ix]) == str(line[1]) + else: + assert step.context.result[ix] == line[1] + elif characterized_as == "unordered": + data = step.table + + # results from traversal should have the same number of entries as the feature data table + assert len(step.context.result) == len(data) + + + +@then("the results should be empty") +def assert_result(step): + assert len(step.context.result) == 0 + + http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/61ba8008/gremlin-test/features/map/Coin.feature ---------------------------------------------------------------------- diff --git a/gremlin-test/features/map/Coin.feature b/gremlin-test/features/map/Coin.feature new file mode 100644 index 0000000..b21bd70 --- /dev/null +++ b/gremlin-test/features/map/Coin.feature @@ -0,0 +1,42 @@ +# 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 - coin() + + Scenario: Use coin at 1.0 + Given the modern graph + And the traversal of + """ + g.V().coin(1.0) + """ + When iterated to list + Then the result should be unordered as + | vertex | person | + | vertex | person | + | vertex | person | + | vertex | person | + | vertex | software | + | vertex | software | + + Scenario: Use coin at 0.0 + Given the modern graph + And the traversal of + """ + g.V().coin(0.0) + """ + When iterated to list + Then the result should be empty \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/61ba8008/gremlin-test/features/map/Count.feature ---------------------------------------------------------------------- diff --git a/gremlin-test/features/map/Count.feature b/gremlin-test/features/map/Count.feature index 383eecf..316976e 100644 --- a/gremlin-test/features/map/Count.feature +++ b/gremlin-test/features/map/Count.feature @@ -15,40 +15,44 @@ # specific language governing permissions and limitations # under the License. -Feature: Count Step +Feature: Step - count() Scenario: Count all vertices Given the modern graph And the traversal of - """ - g.V().count() - """ - When iterating - Then the result should be 6 + """ + g.V().count() + """ + When iterated to list + Then the result should be ordered + | numeric | 6 | Scenario: Count vertices after traversing both() twice Given the modern graph And the traversal of - """ - g.V().both().both().count() - """ - When iterating - Then the result should be 30 + """ + g.V().both().both().count() + """ + When iterated to list + Then the result should be ordered + | numeric | 30 | Scenario: Count local Given the modern graph And the traversal of - """ - g.V().fold().count(Scope.local) - """ - When iterating - Then the result should be 6 + """ + g.V().fold().count(Scope.local) + """ + When iterated to list + Then the result should be ordered + | numeric | 6 | Scenario: Count no vertices Given the modern graph And the traversal of - """ - g.V().has("no").count() - """ - When iterating - Then the result should be 0 \ No newline at end of file + """ + g.V().has("no").count() + """ + When iterated to list + Then the result should be ordered + | numeric | 0 | \ No newline at end of file