Skip to content

Commit

Permalink
Function to fetch scenario name
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Barton <[email protected]>
  • Loading branch information
michaelbarton committed Aug 19, 2015
1 parent 77f34a7 commit 48149f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions biobox_cli/behave_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ def get_failing(results):
def f(acc, item):
return acc + filter(is_failed_scenario, item['elements'])
return reduce(f, results, [])

def scenario_name(scenario):
return scenario["name"]
9 changes: 7 additions & 2 deletions test/test_behave_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ def feature(statuses):
return {'status' : feature_state,
'elements' : map(scenario, statuses)}

def scenario(status = "failed"):
def scenario(status = "failed", name = "scenario name"):
return {"keyword" : "Scenario",
"name" : "scenario name",
"name" : name,
"steps" : [{'result' : {'status' : status}}]}


Expand All @@ -28,3 +28,8 @@ def test_get_failing_for_multiple_failing_scenarios():
features = [feature(["failed", "passing"]),
feature(["failed", "passing"])]
nt.assert_equal([scenario(), scenario()], behave.get_failing(features))


def test_scenario_name():
nt.assert_equal("a", behave.scenario_name(scenario("failed", "a")))
nt.assert_equal("b", behave.scenario_name(scenario("passing", "b")))

0 comments on commit 48149f8

Please sign in to comment.