cuke: test travel time of individual instructions
This commit is contained in:
parent
165c252fc8
commit
df83dfdfe8
@ -46,6 +46,8 @@ When /^I route I should get$/ do |table|
|
|||||||
compasses = compass_list json['route_instructions']
|
compasses = compass_list json['route_instructions']
|
||||||
turns = turn_list json['route_instructions']
|
turns = turn_list json['route_instructions']
|
||||||
modes = mode_list json['route_instructions']
|
modes = mode_list json['route_instructions']
|
||||||
|
times = time_list json['route_instructions']
|
||||||
|
distances = distance_list json['route_instructions']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -90,6 +92,12 @@ When /^I route I should get$/ do |table|
|
|||||||
if table.headers.include? 'modes'
|
if table.headers.include? 'modes'
|
||||||
got['modes'] = modes
|
got['modes'] = modes
|
||||||
end
|
end
|
||||||
|
if table.headers.include? 'times'
|
||||||
|
got['times'] = times
|
||||||
|
end
|
||||||
|
if table.headers.include? 'distances'
|
||||||
|
got['distances'] = distances
|
||||||
|
end
|
||||||
if table.headers.include? '#' # comment column
|
if table.headers.include? '#' # comment column
|
||||||
got['#'] = row['#'] # copy value so it always match
|
got['#'] = row['#'] # copy value so it always match
|
||||||
end
|
end
|
||||||
|
@ -80,25 +80,23 @@ def route_status response
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def way_list instructions
|
def extract_instruction_list instructions, index, postfix=nil
|
||||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
||||||
map { |r| r[1] }.
|
map { |r| r[index] }.
|
||||||
map { |r| r=="" ? '""' : r }.
|
map { |r| (r=="" || r==nil) ? '""' : "#{r}#{postfix}" }.
|
||||||
join(',')
|
join(',')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def way_list instructions
|
||||||
|
extract_instruction_list instructions, 1
|
||||||
|
end
|
||||||
|
|
||||||
def compass_list instructions
|
def compass_list instructions
|
||||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
extract_instruction_list instructions, 6
|
||||||
map { |r| r[6] }.
|
|
||||||
map { |r| r=="" ? '""' : r }.
|
|
||||||
join(',')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def bearing_list instructions
|
def bearing_list instructions
|
||||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
extract_instruction_list instructions, 7
|
||||||
map { |r| r[7] }.
|
|
||||||
map { |r| r=="" ? '""' : r }.
|
|
||||||
join(',')
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def turn_list instructions
|
def turn_list instructions
|
||||||
@ -125,15 +123,20 @@ def turn_list instructions
|
|||||||
# replace instructions codes with strings
|
# replace instructions codes with strings
|
||||||
# "11-3" (enter roundabout and leave a 3rd exit) gets converted to "enter_roundabout-3"
|
# "11-3" (enter roundabout and leave a 3rd exit) gets converted to "enter_roundabout-3"
|
||||||
instructions.map do |r|
|
instructions.map do |r|
|
||||||
r[0].to_s.gsub!(/^\d*/) do |match|
|
r[0].to_s.gsub(/^\d*/) do |match|
|
||||||
types[match.to_i].to_s
|
types[match.to_i].to_s
|
||||||
end
|
end
|
||||||
end.join(',')
|
end.join(',')
|
||||||
end
|
end
|
||||||
|
|
||||||
def mode_list instructions
|
def mode_list instructions
|
||||||
instructions.reject { |r| r[0].to_s=="#{DESTINATION_REACHED}" }.
|
extract_instruction_list instructions, 8
|
||||||
map { |r| r[8] }.
|
end
|
||||||
map { |r| (r=="" || r==nil) ? '""' : r }.
|
|
||||||
join(',')
|
def time_list instructions
|
||||||
|
extract_instruction_list instructions, 4, "s"
|
||||||
|
end
|
||||||
|
|
||||||
|
def distance_list instructions
|
||||||
|
extract_instruction_list instructions, 2, "m"
|
||||||
end
|
end
|
@ -16,15 +16,15 @@ Feature: Estimation of travel time
|
|||||||
| f | e | d |
|
| f | e | d |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| xa | primary |
|
| xa | primary |
|
||||||
| xb | primary |
|
| xb | primary |
|
||||||
| xc | primary |
|
| xc | primary |
|
||||||
| xd | primary |
|
| xd | primary |
|
||||||
| xe | primary |
|
| xe | primary |
|
||||||
| xf | primary |
|
| xf | primary |
|
||||||
| xg | primary |
|
| xg | primary |
|
||||||
| xh | primary |
|
| xh | primary |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time |
|
||||||
@ -45,15 +45,15 @@ Feature: Estimation of travel time
|
|||||||
| f | e | d |
|
| f | e | d |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| xa | primary |
|
| xa | primary |
|
||||||
| xb | primary |
|
| xb | primary |
|
||||||
| xc | primary |
|
| xc | primary |
|
||||||
| xd | primary |
|
| xd | primary |
|
||||||
| xe | primary |
|
| xe | primary |
|
||||||
| xf | primary |
|
| xf | primary |
|
||||||
| xg | primary |
|
| xg | primary |
|
||||||
| xh | primary |
|
| xh | primary |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time |
|
||||||
@ -74,15 +74,15 @@ Feature: Estimation of travel time
|
|||||||
| f | e | d |
|
| f | e | d |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| xa | primary |
|
| xa | primary |
|
||||||
| xb | primary |
|
| xb | primary |
|
||||||
| xc | primary |
|
| xc | primary |
|
||||||
| xd | primary |
|
| xd | primary |
|
||||||
| xe | primary |
|
| xe | primary |
|
||||||
| xf | primary |
|
| xf | primary |
|
||||||
| xg | primary |
|
| xg | primary |
|
||||||
| xh | primary |
|
| xh | primary |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time |
|
||||||
@ -103,15 +103,15 @@ Feature: Estimation of travel time
|
|||||||
| f | e | d |
|
| f | e | d |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| xa | primary |
|
| xa | primary |
|
||||||
| xb | primary |
|
| xb | primary |
|
||||||
| xc | primary |
|
| xc | primary |
|
||||||
| xd | primary |
|
| xd | primary |
|
||||||
| xe | primary |
|
| xe | primary |
|
||||||
| xf | primary |
|
| xf | primary |
|
||||||
| xg | primary |
|
| xg | primary |
|
||||||
| xh | primary |
|
| xh | primary |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time |
|
||||||
@ -183,9 +183,9 @@ Feature: Estimation of travel time
|
|||||||
| | | e |
|
| | | e |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| abc | primary |
|
| abc | primary |
|
||||||
| cde | tertiary |
|
| cde | tertiary |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time |
|
||||||
@ -213,3 +213,26 @@ Feature: Estimation of travel time
|
|||||||
| 4 | 3 | ab | 10s +-1 |
|
| 4 | 3 | ab | 10s +-1 |
|
||||||
| 4 | 2 | ab | 20s +-1 |
|
| 4 | 2 | ab | 20s +-1 |
|
||||||
| 4 | 1 | ab | 30s +-1 |
|
| 4 | 1 | ab | 30s +-1 |
|
||||||
|
|
||||||
|
@bug
|
||||||
|
Scenario: Total travel time should match sum of times of individual ways
|
||||||
|
Given a grid size of 1000 meters
|
||||||
|
And the node map
|
||||||
|
| a | b | | | |
|
||||||
|
| | | | | |
|
||||||
|
| | c | | | d |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes | highway |
|
||||||
|
| ab | primary |
|
||||||
|
| bc | primary |
|
||||||
|
| cd | primary |
|
||||||
|
|
||||||
|
When I route I should get
|
||||||
|
| from | to | route | distances | distance | times | time |
|
||||||
|
| a | b | ab | 1000m +-1 | 1000m +-1 | 100s +-1 | 100s +-1 |
|
||||||
|
| b | c | bc | 2000m +-1 | 2000m +-1 | 200s +-1 | 200s +-1 |
|
||||||
|
| c | d | cd | 3000m +-1 | 3000m +-1 | 300s +-1 | 300s +-1 |
|
||||||
|
| a | c | ab,bc | 1000m,2000m +-1 | 3000m +-1 | 100s,200s +-1 | 300s +-1 |
|
||||||
|
| b | d | bc,cd | 2000m,3000m +-1 | 5000m +-1 | 200s,300s +-1 | 500s +-1 |
|
||||||
|
| a | d | ab,bc,cd | 1000m,2000m,3000m +-1 | 6000m +-1 | 100s,200s,300s +-1 | 600s +-1 |
|
||||||
|
Loading…
Reference in New Issue
Block a user