From 081831e6eaf573d933671e224dcb93707676daf9 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Mon, 18 Mar 2013 15:37:10 +0100 Subject: [PATCH] test for mode flag (todo) --- features/bicycle/mode.feature | 89 ++++++++++++++++++++++++++++ features/step_definitions/routing.rb | 4 ++ features/support/route.rb | 11 +++- features/testbot/mode.feature | 26 ++++++++ 4 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 features/bicycle/mode.feature create mode 100644 features/testbot/mode.feature diff --git a/features/bicycle/mode.feature b/features/bicycle/mode.feature new file mode 100644 index 000000000..c24af4686 --- /dev/null +++ b/features/bicycle/mode.feature @@ -0,0 +1,89 @@ +@routing @bicycle @mode +Feature: Bike - Mode flag + + Background: + Given the profile "bicycle" + + @todo + Scenario: Bike - Mode when using a ferry + Given the node map + | a | b | | + | | c | d | + + And the ways + | nodes | highway | route | duration | + | ab | primary | | | + | bc | | ferry | 0:01 | + | cd | primary | | | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left, destination | bike,ferry,bike | + | d | a | cd,bc,ab | head,right,left, destination | bike,ferry,bike | + | c | a | bc,ab | head,left,destination | ferry,bike | + | d | b | cd,bc | head,right,destination | bike,ferry | + | a | c | ab,bc | head,right,destination | bike,ferry | + | b | d | bc,cd | head,left,destination | ferry,bike | + + @todo + Scenario: Bike - Mode when pushing bike against oneways + Given the node map + | a | b | | + | | c | d | + + And the ways + | nodes | highway | oneway | + | ab | primary | | + | bc | primary | yes | + | cd | primary | | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | bike,push,bike | + | d | a | cd,bc,ab | head,right,left,destination | bike,push,bike | + | c | a | bc,ab | head,left,destination | push,bike | + | d | b | cd,bc | head,right,destination | bike,push | + | a | c | ab,bc | head,right,destination | bike,push | + | b | d | bc,cd | head,left,destination | push,bike | + + @todo + Scenario: Bike - Mode when pushing on pedestrain streets + Given the node map + | a | b | | + | | c | d | + + And the ways + | nodes | highway | + | ab | primary | + | bc | pedestrian | + | cd | primary | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | bike,push,bike | + | d | a | cd,bc,ab | head,right,left,destination | bike,push,bike | + | c | a | bc,ab | head,left,destination | push,bike | + | d | b | cd,bc | head,right,destination | bike,push | + | a | c | ab,bc | head,right,destination | bike,push | + | b | d | bc,cd | head,left,destination | push,bike | + + @todo + Scenario: Bike - Mode when pushing on pedestrain areas + Given the node map + | a | b | | | + | | c | d | f | + + And the ways + | nodes | highway | area | + | ab | primary | | + | bcd | pedestrian | yes | + | df | primary | | + + When I route I should get + | from | to | route | modes | + | a | f | ab,bcd,df | bike,push,bike | + | f | a | df,bcd,ab | bike,push,bike | + | d | a | bcd,ab | push,bike | + | f | b | df,bcd | bike,push | + | a | d | ab,bcd | bike,push | + | b | f | bcd,df | push,bike | diff --git a/features/step_definitions/routing.rb b/features/step_definitions/routing.rb index 7ef5ba756..1d75d50a8 100644 --- a/features/step_definitions/routing.rb +++ b/features/step_definitions/routing.rb @@ -15,6 +15,7 @@ When /^I route I should get$/ do |table| bearings = bearing_list json['route_instructions'] compasses = compass_list json['route_instructions'] turns = turn_list json['route_instructions'] + modes = mode_list json['route_instructions'] end end @@ -46,6 +47,9 @@ When /^I route I should get$/ do |table| if table.headers.include? 'turns' got['turns'] = turns end + if table.headers.include? 'modes' + got['modes'] = modes + end if table.headers.include? '#' # comment column got['#'] = row['#'] # copy value so it always match end diff --git a/features/support/route.rb b/features/support/route.rb index 8be4e9219..9bbdd732c 100644 --- a/features/support/route.rb +++ b/features/support/route.rb @@ -108,9 +108,18 @@ def turn_list instructions 12 => :leave_roundabout, 13 => :stay_roundabout, 14 => :start_end_of_street, - 15 => :destination + 15 => :destination, + 16 => :enter_contraflow, + 17 => :leave_contraflow } instructions. map { |r| types[r[0].to_i].to_s }. join(',') end + +def mode_list instructions + instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }. + map { |r| r[8] }. + map { |r| (r=="" || r==nil) ? '""' : r }. + join(',') +end \ No newline at end of file diff --git a/features/testbot/mode.feature b/features/testbot/mode.feature new file mode 100644 index 000000000..3192c48f9 --- /dev/null +++ b/features/testbot/mode.feature @@ -0,0 +1,26 @@ +@routing @testbot @mode +Feature: Testbot - Mode flag + + Background: + Given the profile "testbot" + + @todo + Scenario: Bike - Mode + Given the node map + | a | b | | + | | c | d | + + And the ways + | nodes | highway | route | duration | + | ab | primary | | | + | bc | | ferry | 0:01 | + | cd | primary | | | + + When I route I should get + | from | to | route | turns | modes | + | a | d | ab,bc,cd | head,right,left,destination | bot,ferry,bot | + | d | a | cd,bc,ab | head,right left,destination | bot,ferry,bot | + | c | a | bc,ab | head,left,destination | ferry,bot | + | d | b | cd,bc | head,right,destination | bot,ferry | + | a | c | ab,bc | head,right,destination | bot,ferry | + | b | d | bc,cd | head,left,destination | ferry,bot |