working on cucumber tests
This commit is contained in:
parent
a60ed5c78a
commit
18542d1df1
@ -1,30 +1,52 @@
|
|||||||
@routing @basic
|
@routing @basic
|
||||||
Feature: Basic Routing
|
Feature: Basic Routing
|
||||||
|
|
||||||
Scenario: Smallest possible datasat
|
Scenario Outline: Smallest possible datasat
|
||||||
Given the nodes
|
Given the nodes
|
||||||
| a | b |
|
| a | b |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes |
|
| nodes |
|
||||||
| ab |
|
| ab |
|
||||||
|
|
||||||
When I route I should get
|
When I route between "<from>" and "<to>"
|
||||||
|
Then "<route>" should be returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| from | to | route |
|
||||||
|
| a | b | ab |
|
||||||
|
| b | a | ba |
|
||||||
|
|
||||||
|
Scenario Outline: Smallest possible datasat
|
||||||
|
Given the nodes
|
||||||
|
| a | b |
|
||||||
|
|
||||||
|
And the ways
|
||||||
|
| nodes |
|
||||||
|
| ab |
|
||||||
|
|
||||||
|
When I route between "<from>" and "<to>"
|
||||||
|
Then "<route>" should be returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | b | ab |
|
| a | b | ab |
|
||||||
| b | a | ba |
|
| b | a | ba |
|
||||||
|
|
||||||
Scenario: Connected ways
|
Scenario Outline: Connected ways
|
||||||
Given the nodes
|
Given the nodes
|
||||||
| a | | c |
|
| a | | c |
|
||||||
| | b | |
|
| | b | |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes |
|
| nodes |
|
||||||
| ab |
|
| ab |
|
||||||
| bc |
|
| bc |
|
||||||
|
|
||||||
When I route I should get
|
When I route between "<from>" and "<to>"
|
||||||
|
Then "<route>" should be returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | c | abc |
|
| a | c | abc |
|
||||||
| c | a | cba |
|
| c | a | cba |
|
||||||
@ -33,17 +55,20 @@ Feature: Basic Routing
|
|||||||
| b | c | bc |
|
| b | c | bc |
|
||||||
| c | b | cb |
|
| c | b | cb |
|
||||||
|
|
||||||
Scenario: Unconnected ways
|
Scenario Outline: Unconnected ways
|
||||||
Given the nodes
|
Given the nodes
|
||||||
| a | b |
|
| a | b |
|
||||||
| c | d |
|
| c | d |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes |
|
| nodes |
|
||||||
| ab |
|
| ab |
|
||||||
| cd |
|
| cd |
|
||||||
|
|
||||||
When I route I should get
|
When I route between "<from>" and "<to>"
|
||||||
|
Then "<route>" should be returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | b | ab |
|
| a | b | ab |
|
||||||
| b | a | ba |
|
| b | a | ba |
|
||||||
@ -56,18 +81,20 @@ Feature: Basic Routing
|
|||||||
| a | d | |
|
| a | d | |
|
||||||
| d | a | |
|
| d | a | |
|
||||||
|
|
||||||
Scenario: Pick the fastest way type
|
Scenario Outline: Pick the fastest way type
|
||||||
Given the nodes
|
Given the nodes
|
||||||
| a | s |
|
| a | s |
|
||||||
| p | b |
|
| p | b |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes | highway |
|
| nodes | highway |
|
||||||
| apb | primary |
|
| apb | primary |
|
||||||
| asb | secondary |
|
| asb | secondary |
|
||||||
|
|
||||||
When I route I should get
|
When I route between "<from>" and "<to>"
|
||||||
|
Then "<route>" should be returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | b | apb |
|
| a | b | apb |
|
||||||
| b | a | bpa |
|
| b | a | bpa |
|
||||||
|
|
||||||
@ -1,8 +1,9 @@
|
|||||||
@routing @oneways
|
@routing @oneways
|
||||||
Feature: Oneway streets
|
Feature: Oneway streets
|
||||||
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
|
Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing
|
||||||
|
|
||||||
Scenario: Implied oneways
|
Scenario: Implied oneways
|
||||||
|
Given the speedprofile "car"
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | junction | forw | backw |
|
| highway | junction | forw | backw |
|
||||||
| motorway | | x | x |
|
| motorway | | x | x |
|
||||||
@ -12,6 +13,7 @@ Feature: Oneway streets
|
|||||||
| primary | roundabout | x | |
|
| primary | roundabout | x | |
|
||||||
|
|
||||||
Scenario: Overriding implied oneways
|
Scenario: Overriding implied oneways
|
||||||
|
Given the defaults
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | junction | oneway | forw | backw |
|
| highway | junction | oneway | forw | backw |
|
||||||
| motorway_link | | no | x | x |
|
| motorway_link | | no | x | x |
|
||||||
@ -22,6 +24,7 @@ Feature: Oneway streets
|
|||||||
| primary | roundabout | -1 | | x |
|
| primary | roundabout | -1 | | x |
|
||||||
|
|
||||||
Scenario: Handle various oneway tag values
|
Scenario: Handle various oneway tag values
|
||||||
|
Given the defaults
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | oneway | forw | backw |
|
| highway | oneway | forw | backw |
|
||||||
| primary | | x | x |
|
| primary | | x | x |
|
||||||
@ -35,10 +38,9 @@ Feature: Oneway streets
|
|||||||
| primary | -1 | | x |
|
| primary | -1 | | x |
|
||||||
|
|
||||||
Scenario: Disabling oneways in speedprofile
|
Scenario: Disabling oneways in speedprofile
|
||||||
Given the speedprofile
|
Given the speedprofile settings
|
||||||
| obeyOneways | no |
|
| obeyOneways | no |
|
||||||
|
Then routability should be
|
||||||
Then routability should be
|
|
||||||
| highway | junction | oneway | forw | backw |
|
| highway | junction | oneway | forw | backw |
|
||||||
| primary | | yes | x | x |
|
| primary | | yes | x | x |
|
||||||
| primary | | true | x | x |
|
| primary | | true | x | x |
|
||||||
@ -49,9 +51,7 @@ Feature: Oneway streets
|
|||||||
| primary | roundabout | | x | x |
|
| primary | roundabout | | x | x |
|
||||||
|
|
||||||
Scenario: Oneways and bicycles
|
Scenario: Oneways and bicycles
|
||||||
Given the speedprofile
|
Given the defaults
|
||||||
| accessTag | bicycle |
|
|
||||||
|
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | junction | oneway | oneway:bicycle | forw | backw |
|
| highway | junction | oneway | oneway:bicycle | forw | backw |
|
||||||
| primary | | | yes | x | |
|
| primary | | | yes | x | |
|
||||||
@ -77,9 +77,9 @@ Feature: Oneway streets
|
|||||||
| primary | roundabout | | -1 | | x |
|
| primary | roundabout | | -1 | | x |
|
||||||
|
|
||||||
Scenario: Cars should not be affected by bicycle tags
|
Scenario: Cars should not be affected by bicycle tags
|
||||||
Given the speedprofile
|
Given the speedprofile settings
|
||||||
| accessTag | motorcar |
|
| accessTag | motorcar |
|
||||||
|
|
||||||
Then routability should be
|
Then routability should be
|
||||||
| highway | junction | oneway | oneway:bicycle | forw | backw |
|
| highway | junction | oneway | oneway:bicycle | forw | backw |
|
||||||
| primary | | yes | yes | x | |
|
| primary | | yes | yes | x | |
|
||||||
|
|||||||
@ -12,7 +12,7 @@ Feature: Outlines
|
|||||||
| ab |
|
| ab |
|
||||||
| bc |
|
| bc |
|
||||||
|
|
||||||
When I route I between "<from>" and "<to>"
|
When I route from "<from>" to "<to>"
|
||||||
Then I should get the route "<route>"
|
Then I should get the route "<route>"
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|||||||
@ -1,28 +1,30 @@
|
|||||||
@routing @restrictions
|
@routing @restrictions
|
||||||
Feature: Turn restrictions
|
Feature: Turn restrictions
|
||||||
OSRM should handle turn restrictions as defined by http://wiki.openstreetmap.org/wiki/Relation:restriction
|
Handle turn restrictions as defined by http://wiki.openstreetmap.org/wiki/Relation:restriction
|
||||||
|
|
||||||
Scenario: No left turn at T-junction
|
Scenario Outline: No left turn at T-junction
|
||||||
Given the nodes
|
Given the nodes
|
||||||
| a | j | b |
|
| a | j | b |
|
||||||
| | s | |
|
| | s | |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes |
|
| nodes |
|
||||||
| aj |
|
| aj |
|
||||||
| jb |
|
| jb |
|
||||||
| sj |
|
| sj |
|
||||||
|
|
||||||
And the relations
|
And the relations
|
||||||
| from | to | via | restriction |
|
| from | to | via | restriction |
|
||||||
| sj | ja | j | no_left_turn |
|
| sj | ja | j | no_left_turn |
|
||||||
|
|
||||||
When I route I should get
|
When I route between "<from>" and "<to>"
|
||||||
|
Then "<route>" should be returned
|
||||||
|
|
||||||
|
Examples:
|
||||||
| from | to | route |
|
| from | to | route |
|
||||||
| a | b | ajb |
|
| a | b | ajb |
|
||||||
| a | s | ajs |
|
| a | s | ajs |
|
||||||
| b | a | bja |
|
| b | a | bja |
|
||||||
| b | s | bjs |
|
| b | s | bjs |
|
||||||
| s | a | |
|
| s | a | |
|
||||||
| s | b | sjb |
|
| s | b | sjb |
|
||||||
|
|
||||||
@ -75,10 +75,3 @@ end
|
|||||||
When /^preprocessed files for "([^"]*)" has been removed$/ do |file|
|
When /^preprocessed files for "([^"]*)" has been removed$/ do |file|
|
||||||
FileUtils.rm_r Dir["#{file}.*"], :secure => true
|
FileUtils.rm_r Dir["#{file}.*"], :secure => true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
Given /^the speed profile$/ do |table|
|
|
||||||
table.hashes.each do |hash|
|
|
||||||
#Whatever you need to do
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@ -1,4 +1,5 @@
|
|||||||
|
|
||||||
|
|
||||||
def request_route a,b
|
def request_route a,b
|
||||||
uri = URI.parse "http://localhost:5000/viaroute&start=#{a}&dest=#{b}&output=json&geomformat=cmp"
|
uri = URI.parse "http://localhost:5000/viaroute&start=#{a}&dest=#{b}&output=json&geomformat=cmp"
|
||||||
#puts "routing: #{uri}"
|
#puts "routing: #{uri}"
|
||||||
@ -65,7 +66,7 @@ end
|
|||||||
Then /^I should get a route$/ do
|
Then /^I should get a route$/ do
|
||||||
step "I should get a valid response"
|
step "I should get a valid response"
|
||||||
step "a route should be found"
|
step "a route should be found"
|
||||||
puts @response.body
|
#puts @response.body
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^I should not get a route$/ do
|
Then /^I should not get a route$/ do
|
||||||
@ -145,7 +146,7 @@ end
|
|||||||
def parse_response response
|
def parse_response response
|
||||||
if response.code == "200" && response.body.empty? == false
|
if response.code == "200" && response.body.empty? == false
|
||||||
json = JSON.parse response.body
|
json = JSON.parse response.body
|
||||||
puts response.body
|
#puts response.body
|
||||||
if json['status'] == 0
|
if json['status'] == 0
|
||||||
route = json['route_instructions'].map { |r| r[1] }.reject(&:empty?).join(', ')
|
route = json['route_instructions'].map { |r| r[1] }.reject(&:empty?).join(', ')
|
||||||
if route.empty?
|
if route.empty?
|
||||||
@ -184,20 +185,50 @@ When /^I route on tagged ways I should get $/ do |table|
|
|||||||
pending
|
pending
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I route between "([^"]*)" and "([^"]*)"$/ do |from,to|
|
||||||
|
end
|
||||||
|
|
||||||
When /^I speak I should get$/ do |table|
|
Then /^"([^"]*)" should be returned$/ do |route|
|
||||||
actual = [['one','two','three']]
|
end
|
||||||
table.hashes.each do |row|
|
|
||||||
actual << [ row['one'].dup, row['two'].dup, 'xx' ]
|
def build_ways_from_table table
|
||||||
|
#add one unconnected way for each row
|
||||||
|
table.hashes.each_with_index do |row,ri|
|
||||||
|
#two nodes...
|
||||||
|
node1 = OSM::Node.new nil, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+0*ZOOM, ORIGIN[1]-ri*ZOOM
|
||||||
|
node2 = OSM::Node.new nil, OSM_USER, OSM_TIMESTAMP, ORIGIN[0]+1*ZOOM, ORIGIN[1]-ri*ZOOM
|
||||||
|
node1.uid = OSM_UID
|
||||||
|
node2.uid = OSM_UID
|
||||||
|
osm_db << node1
|
||||||
|
osm_db << node2
|
||||||
|
|
||||||
|
#...with a way between them
|
||||||
|
way = OSM::Way.new -ri-1, OSM_USER, OSM_TIMESTAMP
|
||||||
|
way.uid = OSM_UID
|
||||||
|
tags = row.dup
|
||||||
|
tags.delete 'forw'
|
||||||
|
tags.delete 'backw'
|
||||||
|
tags.reject! { |k,v| v=='' }
|
||||||
|
way << tags
|
||||||
|
way << node1
|
||||||
|
way << node2
|
||||||
|
osm_db << way
|
||||||
|
end
|
||||||
|
Dir.chdir TEST_FOLDER do
|
||||||
|
write_osm
|
||||||
|
end
|
||||||
|
must_reprocess
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^routability should be$/ do |table|
|
||||||
|
build_ways_from_table table
|
||||||
|
reprocess_if_needed
|
||||||
|
actual = [ table.column_names ]
|
||||||
|
Dir.chdir 'test' do
|
||||||
|
launch
|
||||||
|
p "#{ORIGIN[0]+0*ZOOM},#{ORIGIN[1]-0*ZOOM}", "#{ORIGIN[0]+1*ZOOM},#{ORIGIN[1]-0*ZOOM}"
|
||||||
|
p request_route("#{ORIGIN[0]+0*ZOOM},#{ORIGIN[1]-0*ZOOM}", "#{ORIGIN[0]+1*ZOOM},#{ORIGIN[1]-0*ZOOM}").body
|
||||||
|
kill
|
||||||
end
|
end
|
||||||
table.diff! actual
|
table.diff! actual
|
||||||
end
|
end
|
||||||
|
|
||||||
When /^I route I between "([^"]*)" and "([^"]*)"$/ do |from, to|
|
|
||||||
end
|
|
||||||
|
|
||||||
Then /^I should get the route "([^"]*)"$/ do |route|
|
|
||||||
route.should == "xx"
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
@ -11,6 +11,8 @@ DATA_FOLDER = 'data'
|
|||||||
OSM_FILE = 'test'
|
OSM_FILE = 'test'
|
||||||
LOG_FILE = 'test.log'
|
LOG_FILE = 'test.log'
|
||||||
|
|
||||||
|
DEFAULT_SPEEDPROFILE = 'bicycle'
|
||||||
|
|
||||||
ORIGIN = [1,1]
|
ORIGIN = [1,1]
|
||||||
ZOOM = 0.001
|
ZOOM = 0.001
|
||||||
|
|
||||||
@ -51,16 +53,15 @@ def find_way_by_name s
|
|||||||
end
|
end
|
||||||
|
|
||||||
def reset_data
|
def reset_data
|
||||||
|
Dir.chdir "#{TEST_FOLDER}" do
|
||||||
|
clear_log
|
||||||
|
clear_data_files
|
||||||
|
end
|
||||||
osm_db.clear
|
osm_db.clear
|
||||||
name_node_hash.clear
|
name_node_hash.clear
|
||||||
name_way_hash.clear
|
name_way_hash.clear
|
||||||
must_reprocess
|
must_reprocess
|
||||||
reset_speedprofile
|
reset_speedprofile
|
||||||
$stdout.flush
|
|
||||||
Dir.chdir "#{TEST_FOLDER}" do
|
|
||||||
clear_log
|
|
||||||
clear_data_files
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_data_files
|
def clear_data_files
|
||||||
@ -77,7 +78,12 @@ end
|
|||||||
|
|
||||||
def reset_speedprofile
|
def reset_speedprofile
|
||||||
@speedprofile = {}
|
@speedprofile = {}
|
||||||
s = File.read 'test/speedprofiles/default.ini'
|
read_speedprofile DEFAULT_SPEEDPROFILE
|
||||||
|
end
|
||||||
|
|
||||||
|
def read_speedprofile profile
|
||||||
|
@speedprofile = {}
|
||||||
|
s = File.read "test/speedprofiles/#{profile}.ini"
|
||||||
s.scan /(.*)=(.*)/ do |option|
|
s.scan /(.*)=(.*)/ do |option|
|
||||||
@speedprofile[option[0].strip] = option[1].strip
|
@speedprofile[option[0].strip] = option[1].strip
|
||||||
end
|
end
|
||||||
@ -121,8 +127,18 @@ def write_osm
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Given /^the speedprofile "([^"]*)"$/ do |profile|
|
||||||
|
read_speedprofile profile
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Given /^the speedprofile settings$/ do |table|
|
||||||
|
table.raw.each do |row|
|
||||||
|
speedprofile[ row[0] ] = row[1]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Given /^the nodes$/ do |table|
|
Given /^the nodes$/ do |table|
|
||||||
reset_data
|
|
||||||
table.raw.each_with_index do |row,ri|
|
table.raw.each_with_index do |row,ri|
|
||||||
row.each_with_index do |name,ci|
|
row.each_with_index do |name,ci|
|
||||||
unless name.empty?
|
unless name.empty?
|
||||||
@ -163,3 +179,5 @@ Given /^the relations$/ do |table|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^the defaults$/ do
|
||||||
|
end
|
||||||
|
|||||||
3
features/support/hooks.rb
Normal file
3
features/support/hooks.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Before do
|
||||||
|
reset_data
|
||||||
|
end
|
||||||
@ -1,9 +1,20 @@
|
|||||||
[bicycle]
|
[default]
|
||||||
primary = 15
|
accessTag = motorcar
|
||||||
obeyOneways = yes
|
defaultSpeed = 50
|
||||||
useRestrictions = yes
|
|
||||||
accessTag = bicycle
|
barrier = bollard
|
||||||
excludeFromGrid = ferry
|
|
||||||
defaultSpeed = 15
|
motorway = 110
|
||||||
obeyBollards = no
|
motorway_link = 90
|
||||||
trafficLightPenalty = 10
|
trunk = 90
|
||||||
|
trunk_link = 70
|
||||||
|
primary = 70
|
||||||
|
primary_link = 60
|
||||||
|
secondary = 60
|
||||||
|
secondary_link = 50
|
||||||
|
tertiary = 40
|
||||||
|
residential = 30
|
||||||
|
living_street = 25
|
||||||
|
service = 25
|
||||||
|
unclassified = 25
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user