Skip to content

Commit

Permalink
Add test for avoid flags
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMarex authored and Patrick Niklaus committed Aug 21, 2017
1 parent a3c94ef commit 960a595
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cucumber.js
@@ -1,7 +1,7 @@
module.exports = {
default: '--strict --tags ~@stress --tags ~@todo --require features/support --require features/step_definitions',
verify: '--strict --tags ~@stress --tags ~@todo -f progress --require features/support --require features/step_definitions',
default: '--strict --tags ~@stress --tags ~@mld --tags ~@todo --require features/support --require features/step_definitions',
verify: '--strict --tags ~@stress --tags ~@mld --tags ~@todo -f progress --require features/support --require features/step_definitions',
todo: '--strict --tags @todo --require features/support --require features/step_definitions',
all: '--strict --require features/support --require features/step_definitions',
mld: '--strict --tags ~@stress --tags ~@todo --tags ~@alternative --require features/support --require features/step_definitions -f progress'
}
};
66 changes: 66 additions & 0 deletions features/testbot/avoid.feature
@@ -0,0 +1,66 @@
@routing @testbot @avoid @mld
Feature: Testbot - Avoid flags
Background:
Given the profile "testbot"
Given the node map
"""
a....b-----c-$-$-d
$ $ :
e.$.$.f.....g
"""

And the ways
| nodes | highway | toll | # |
| ab | primary | | always drivable |
| bc | motorway | | not drivable for avoid=motorway and avoid=motorway,toll |
| be | primary | yes | not drivable for avoid=toll and avoid=motorway,toll |
| ef | primary | yes | not drivable for avoid=toll and avoid=motorway,toll |
| fc | primary | yes | not drivable for avoid=toll and avoid=motorway,toll |
| cd | motorway | yes | not drivable for avoid=motorway avoid=toll and avoid=motorway,toll |
| fg | primary | | always drivable |
| gd | primary | | always drivable |

Scenario: Testbot - avoid nothing
When I route I should get
| from | to | route |
| a | d | ab,bc,cd,cd |
| a | g | ab,be,ef,fg,fg |
| a | c | ab,bc,bc |
| a | f | ab,be,ef,ef |

Scenario: Testbot - avoid motorway
Given the query options
| avoid | motorway |

When I route I should get
| from | to | route |
| a | d | ab,be,ef,fg,gd,gd |
| a | g | ab,be,ef,fg,fg |
| a | c | ab,be,ef,fc,fc |
| a | f | ab,be,ef,ef |

Scenario: Testbot - avoid toll
Given the query options
| avoid | toll |

When I route I should get
| from | to | route |
| a | d | |
| a | g | |
| a | c | ab,bc,bc |
| a | f | |
| f | d | fg,gd,gd |

Scenario: Testbot - avoid motorway and toll
Given the query options
| avoid | motorway,toll |

When I route I should get
| from | to | route |
| a | d | |
| a | g | |
| a | c | ab,bc,bc |
| a | f | |
| f | d | fg,gd,gd |


17 changes: 17 additions & 0 deletions profiles/testbot.lua
Expand Up @@ -19,6 +19,12 @@ function setup()
use_turn_restrictions = true
},

avoidable = {
[1] = {["motorway"] = true},
[2] = {["toll"] = true},
[3] = {["motorway"] = true, ["toll"] = true}
},

default_speed = 24,
speeds = {
primary = 36,
Expand All @@ -40,6 +46,7 @@ end

function process_way (profile, way, result)
local highway = way:get_value_by_key("highway")
local toll = way:get_value_by_key("toll")
local name = way:get_value_by_key("name")
local oneway = way:get_value_by_key("oneway")
local route = way:get_value_by_key("route")
Expand Down Expand Up @@ -103,6 +110,16 @@ function process_way (profile, way, result)
result.backward_mode = mode.inaccessible
end

if highway == 'motorway' then
result.forward_classes["motorway"] = true
result.backward_classes["motorway"] = true
end

if toll == "yes" then
result.forward_classes["toll"] = true
result.backward_classes["toll"] = true
end

if junction == 'roundabout' then
result.roundabout = true
end
Expand Down

0 comments on commit 960a595

Please sign in to comment.