From 421d336b0f2b6396c641685a4097682a599abdbe Mon Sep 17 00:00:00 2001 From: Lev Dragunov Date: Tue, 17 Jan 2017 13:49:31 +0300 Subject: [PATCH] Cucumber test support for alternatives count parameter --- features/step_definitions/matching.js | 10 +++++++++- features/support/route.js | 5 +++++ features/testbot/matching.feature | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/features/step_definitions/matching.js b/features/step_definitions/matching.js index 042505358..8635ba997 100644 --- a/features/step_definitions/matching.js +++ b/features/step_definitions/matching.js @@ -39,7 +39,8 @@ module.exports = function () { duration = '', annotation = '', geometry = '', - OSMIDs = ''; + OSMIDs = '', + alternatives = ''; if (res.statusCode === 200) { @@ -95,6 +96,10 @@ module.exports = function () { if (json.matchings.length != 1) throw new Error('*** Checking geometry only supported for matchings with one subtrace'); geometry = json.matchings[0].geometry; } + + if (headers.has('alternatives')) { + alternatives = this.alternativesList(json); + } } if (headers.has('turns')) { @@ -137,6 +142,9 @@ module.exports = function () { got['OSM IDs'] = OSMIDs; } + if (headers.has('alternatives')) { + got['alternatives'] = alternatives; + } var ok = true; var encodedResult = '', extendedTarget = ''; diff --git a/features/support/route.js b/features/support/route.js index 0be1f75c0..e3c714bf5 100644 --- a/features/support/route.js +++ b/features/support/route.js @@ -180,6 +180,11 @@ module.exports = function () { return merged; }; + this.alternativesList = (instructions) => { + // alternatives_count come from tracepoints list + return instructions.tracepoints.map(t => t.alternatives_count.toString()).join(','); + }; + this.lanesList = (instructions) => { return this.extractInstructionList(instructions, instruction => { if( 'lanes' in instruction.intersections[0] ) diff --git a/features/testbot/matching.feature b/features/testbot/matching.feature index fcfa60418..02fcc525e 100644 --- a/features/testbot/matching.feature +++ b/features/testbot/matching.feature @@ -263,6 +263,22 @@ Feature: Basic Map Matching | trace | matchings | geometry | | abd | abd | 1,1,1,1.00009,1,1.00009,0.99991,1.00009 | + Scenario: Testbot - Matching alternatives count test + Given the node map + """ + a b c d e f + g h i + """ + + And the ways + | nodes | oneway | + | abcdef | yes | + | dghi | yes | + + When I match I should get + | trace | matchings | alternatives | + | abcdef | abcde | 1,1,1,1,2,2 | + Scenario: Testbot - Speed greater than speed threshhold Given a grid size of 10 meters Given the query options