From 2506e4c4951a2c6f510abc9a74970c4d871025f0 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 6 Mar 2018 02:47:05 +0100 Subject: [PATCH 1/5] DB, VBB: proper via tests :white_check_mark: --- test/db.js | 71 ++++++++++++++++++++++++++++++++++++++++++++------- test/vbb.js | 73 +++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 124 insertions(+), 20 deletions(-) diff --git a/test/db.js b/test/db.js index f38d2ddd..a9a4e770 100644 --- a/test/db.js +++ b/test/db.js @@ -217,18 +217,71 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) { t.end() })) -test('Berlin Hbf to München Hbf with stopover at Hannover Hbf', co(function* (t) { - const [journey] = yield client.journeys(berlinHbf, münchenHbf, { - via: hannoverHbf, - results: 1 +test('journeys: via works – changing trains', co(function* (t) { + // Going from Westhafen to Wedding via Württembergalle without changing + // is currently impossible. We check if the routing engine lets us change + // at Württembergallee if we set it as via. + const westhafen = '008089116' + const wedding = '008089131' + const württembergallee = '731084' + const [journey] = yield client.journeys(westhafen, wedding, { + via: württembergallee, + results: 1, + when }) - const i = journey.legs.findIndex(leg => leg.destination.id === hannoverHbf) - t.ok(i >= 0, 'no leg with Hannover Hbf as destination') + t.ok(journey) + const i1 = journey.legs.findIndex(l => l.destination.id === württembergallee) + t.ok(i1 >= 0, 'no leg with Württembergallee as destination') - const nextLeg = journey.legs[i + 1] - t.ok(nextLeg) - t.equal(nextLeg.origin.id, hannoverHbf) + const i2 = journey.legs.findIndex(l => l.origin.id === württembergallee) + t.ok(i2 >= 0, 'no leg with Württembergallee as origin') + t.ok(i2 >= i1) + + t.end() +})) + +test('journeys: via works – *without* changing trains', co(function* (t) { + // When going from Ruhleben to Zoo via Kastanienallee, there is *no need* + // to change trains. We check if the routing engine *does not* require + // one to change at the via station. + const ruhleben = '000731058' + const zoo = '008010406' + const kastanienallee = '730983' + const [journey] = yield client.journeys(ruhleben, zoo, { + via: kastanienallee, + results: 1, + when, + passedStations: true + }) + + t.ok(journey) + const i1 = journey.legs.findIndex(l => l.destination.id === kastanienallee) + t.ok(i1 < 0, 'routing engine changes at Kastanienallee') + + const l = journey.legs.some(l => l.passed.some(p => p.station.id === kastanienallee)) + t.ok(l, 'no stopover at Kastanienallee') + + t.end() +})) + +test('journeys: via works – even if on the obvious path', co(function* (t) { + const birkenwerder = '008080190' + const borgsdorf = '8080200' + const lehnitz = '008081722' + const [journey] = yield client.journeys(birkenwerder, lehnitz, { + via: borgsdorf, + results: 1, + when, + passedStations: true + }) + + t.ok(journey) + const i1 = journey.legs.findIndex(l => l.destination.id === borgsdorf) + t.ok(i1 < 0, 'routing engine changes at Borgsdorf') + + const l = journey.legs.some(l => l.passed.some(p => p.station.id === borgsdorf)) + t.ok(l, 'no stopover at Borgsdorf') t.end() })) diff --git a/test/vbb.js b/test/vbb.js index 29b41d63..4b8dd0d0 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -302,20 +302,71 @@ test('journeys – station to POI', co(function* (t) { -test('journeys – with stopover', co(function* (t) { - const halleschesTor = '900000012103' - const leopoldplatz = '900000009102' - const [journey] = yield client.journeys(spichernstr, halleschesTor, { - via: leopoldplatz, - results: 1 +test('journeys: via works – changing trains', co(function* (t) { + // Going from Westhafen to Wedding via Württembergalle without changing + // is currently impossible. We check if the routing engine lets us change + // at Württembergallee if we set it as via. + const westhafen = '900000001201' + const wedding = '900000009104' + const württembergallee = '900000026153' + const [journey] = yield client.journeys(westhafen, wedding, { + via: württembergallee, + results: 1, + when }) - const i = journey.legs.findIndex(leg => leg.destination.id === leopoldplatz) - t.ok(i >= 0, 'no leg with Leopoldplatz as destination') + t.ok(journey) + const i1 = journey.legs.findIndex(l => l.destination.id === württembergallee) + t.ok(i1 >= 0, 'no leg with Württembergallee as destination') - const nextLeg = journey.legs[i + 1] - t.ok(nextLeg) - t.equal(nextLeg.origin.id, leopoldplatz) + const i2 = journey.legs.findIndex(l => l.origin.id === württembergallee) + t.ok(i2 >= 0, 'no leg with Württembergallee as origin') + t.ok(i2 >= i1) + + t.end() +})) + +test('journeys: via works – *without* changing trains', co(function* (t) { + // When going from Ruhleben to Zoo via Kastanienallee, there is *no need* + // to change trains. We check if the routing engine *does not* require + // one to change at the via station. + const ruhleben = '900000025202' + const zoo = '900000023201' + const kastanienallee = '900000020152' + const [journey] = yield client.journeys(ruhleben, zoo, { + via: kastanienallee, + results: 1, + when, + passedStations: true + }) + + t.ok(journey) + const i1 = journey.legs.findIndex(l => l.destination.id === kastanienallee) + t.ok(i1 < 0, 'routing engine changes at Kastanienallee') + + const l = journey.legs.some(l => l.passed.some(p => p.station.id === kastanienallee)) + t.ok(l, 'no stopover at Kastanienallee') + + t.end() +})) + +test('journeys: via works – even if on the obvious path', co(function* (t) { + const birkenwerder = '900000200008' + const borgsdorf = '900000200007' + const lehnitz = '900000200006' + const [journey] = yield client.journeys(birkenwerder, lehnitz, { + via: borgsdorf, + results: 1, + when, + passedStations: true + }) + + t.ok(journey) + const i1 = journey.legs.findIndex(l => l.destination.id === borgsdorf) + t.ok(i1 < 0, 'routing engine changes at Borgsdorf') + + const l = journey.legs.some(l => l.passed.some(p => p.station.id === borgsdorf)) + t.ok(l, 'no stopover at Borgsdorf') t.end() })) From cd63078b83fd33ab024acbcaf6ed838e07b6b8fd Mon Sep 17 00:00:00 2001 From: Julius Tens Date: Fri, 16 Mar 2018 14:22:00 +0100 Subject: [PATCH 2/5] =?UTF-8?q?add=20=C3=B6bb=20via=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/oebb.js | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/test/oebb.js b/test/oebb.js index 178c58db..0378d1e8 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -257,19 +257,47 @@ test('Albertina to Salzburg Hbf', co(function* (t) { t.end() })) -test('Wien to Klagenfurt Hbf with stopover at Salzburg Hbf', co(function* (t) { - const [journey] = yield client.journeys(wien, klagenfurtHbf, { - via: salzburgHbf, +test('journeys: via works – with detour', co(function* (t) { + // Going from Stephansplatz to Schottenring via Donauinsel without detour + // is currently impossible + const stephansplatz = '001390167' + const schottenring = '001390163' + const donauinsel = '001392277' + const donauinselPassed = '922001' + const [journey] = yield client.journeys(stephansplatz, schottenring, { + via: donauinsel, results: 1, - when + when, + passedStations: true }) - const i1 = journey.legs.findIndex(leg => leg.destination.id === salzburgHbf) - t.ok(i1 >= 0, 'no leg with Salzburg Hbf as destination') + t.ok(journey) - const i2 = journey.legs.findIndex(leg => leg.origin.id === salzburgHbf) - t.ok(i2 >= 0, 'no leg with Salzburg Hbf as origin') - t.ok(i2 > i1, 'leg with Salzburg Hbf as origin must be after leg to it') + const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === donauinselPassed)) + t.ok(l, 'no stopover at Donauinsel') + + t.end() +})) + +test('journeys: via works – without detour', co(function* (t) { + // When going from Karlsplatz to Praterstern via Museumsquartier, there is *no need* + // to change trains / no need for a "detour". + const karlsplatz = '001390461' + const praterstern = '001290201' + const museumsquartier = '001390171' + const museumsquartierPassed = '901014' + + const [journey] = yield client.journeys(karlsplatz, praterstern, { + via: museumsquartier, + results: 1, + when, + passedStations: true + }) + + t.ok(journey) + + const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === museumsquartierPassed)) + t.ok(l, 'no stopover at Weihburggasse') t.end() })) From 9ce1e836215578724bd3558cf9e1b49b409efe59 Mon Sep 17 00:00:00 2001 From: Julius Tens Date: Fri, 16 Mar 2018 14:30:49 +0100 Subject: [PATCH 3/5] update db,vbb via tests --- test/db.js | 47 ++++++++++------------------------------------- test/vbb.js | 51 ++++++++++----------------------------------------- 2 files changed, 20 insertions(+), 78 deletions(-) diff --git a/test/db.js b/test/db.js index a9a4e770..527d4318 100644 --- a/test/db.js +++ b/test/db.js @@ -217,34 +217,30 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) { t.end() })) -test('journeys: via works – changing trains', co(function* (t) { - // Going from Westhafen to Wedding via Württembergalle without changing - // is currently impossible. We check if the routing engine lets us change - // at Württembergallee if we set it as via. +test('journeys: via works – with detour', co(function* (t) { + // Going from Westhafen to Wedding via Württembergalle without detour + // is currently impossible const westhafen = '008089116' const wedding = '008089131' const württembergallee = '731084' const [journey] = yield client.journeys(westhafen, wedding, { via: württembergallee, results: 1, - when + when, + passedStations: true }) t.ok(journey) - const i1 = journey.legs.findIndex(l => l.destination.id === württembergallee) - t.ok(i1 >= 0, 'no leg with Württembergallee as destination') - const i2 = journey.legs.findIndex(l => l.origin.id === württembergallee) - t.ok(i2 >= 0, 'no leg with Württembergallee as origin') - t.ok(i2 >= i1) + const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee)) + t.ok(l, 'no stopover at Württembergalle') t.end() })) -test('journeys: via works – *without* changing trains', co(function* (t) { +test('journeys: via works – without detour', co(function* (t) { // When going from Ruhleben to Zoo via Kastanienallee, there is *no need* - // to change trains. We check if the routing engine *does not* require - // one to change at the via station. + // to change trains / no need for a "detour". const ruhleben = '000731058' const zoo = '008010406' const kastanienallee = '730983' @@ -256,36 +252,13 @@ test('journeys: via works – *without* changing trains', co(function* (t) { }) t.ok(journey) - const i1 = journey.legs.findIndex(l => l.destination.id === kastanienallee) - t.ok(i1 < 0, 'routing engine changes at Kastanienallee') - const l = journey.legs.some(l => l.passed.some(p => p.station.id === kastanienallee)) + const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee)) t.ok(l, 'no stopover at Kastanienallee') t.end() })) -test('journeys: via works – even if on the obvious path', co(function* (t) { - const birkenwerder = '008080190' - const borgsdorf = '8080200' - const lehnitz = '008081722' - const [journey] = yield client.journeys(birkenwerder, lehnitz, { - via: borgsdorf, - results: 1, - when, - passedStations: true - }) - - t.ok(journey) - const i1 = journey.legs.findIndex(l => l.destination.id === borgsdorf) - t.ok(i1 < 0, 'routing engine changes at Borgsdorf') - - const l = journey.legs.some(l => l.passed.some(p => p.station.id === borgsdorf)) - t.ok(l, 'no stopover at Borgsdorf') - - t.end() -})) - test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) { const model = yield client.journeys(jungfernh, münchenHbf, { results: 3, when diff --git a/test/vbb.js b/test/vbb.js index 4b8dd0d0..6906a5db 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -300,36 +300,30 @@ test('journeys – station to POI', co(function* (t) { t.end() })) - - -test('journeys: via works – changing trains', co(function* (t) { - // Going from Westhafen to Wedding via Württembergalle without changing - // is currently impossible. We check if the routing engine lets us change - // at Württembergallee if we set it as via. +test('journeys: via works – with detour', co(function* (t) { + // Going from Westhafen to Wedding via Württembergalle without detour + // is currently impossible const westhafen = '900000001201' const wedding = '900000009104' const württembergallee = '900000026153' const [journey] = yield client.journeys(westhafen, wedding, { via: württembergallee, results: 1, - when + when, + passedStations: true }) t.ok(journey) - const i1 = journey.legs.findIndex(l => l.destination.id === württembergallee) - t.ok(i1 >= 0, 'no leg with Württembergallee as destination') - const i2 = journey.legs.findIndex(l => l.origin.id === württembergallee) - t.ok(i2 >= 0, 'no leg with Württembergallee as origin') - t.ok(i2 >= i1) + const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee)) + t.ok(l, 'no stopover at Württembergalle') t.end() })) -test('journeys: via works – *without* changing trains', co(function* (t) { +test('journeys: via works – without detour', co(function* (t) { // When going from Ruhleben to Zoo via Kastanienallee, there is *no need* - // to change trains. We check if the routing engine *does not* require - // one to change at the via station. + // to change trains / no need for a "detour". const ruhleben = '900000025202' const zoo = '900000023201' const kastanienallee = '900000020152' @@ -341,38 +335,13 @@ test('journeys: via works – *without* changing trains', co(function* (t) { }) t.ok(journey) - const i1 = journey.legs.findIndex(l => l.destination.id === kastanienallee) - t.ok(i1 < 0, 'routing engine changes at Kastanienallee') - const l = journey.legs.some(l => l.passed.some(p => p.station.id === kastanienallee)) + const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee)) t.ok(l, 'no stopover at Kastanienallee') t.end() })) -test('journeys: via works – even if on the obvious path', co(function* (t) { - const birkenwerder = '900000200008' - const borgsdorf = '900000200007' - const lehnitz = '900000200006' - const [journey] = yield client.journeys(birkenwerder, lehnitz, { - via: borgsdorf, - results: 1, - when, - passedStations: true - }) - - t.ok(journey) - const i1 = journey.legs.findIndex(l => l.destination.id === borgsdorf) - t.ok(i1 < 0, 'routing engine changes at Borgsdorf') - - const l = journey.legs.some(l => l.passed.some(p => p.station.id === borgsdorf)) - t.ok(l, 'no stopover at Borgsdorf') - - t.end() -})) - - - test('departures', co(function* (t) { const deps = yield client.departures(spichernstr, {duration: 5, when}) From 9b315ec7194125ba61302aa476de6d69c28a866a Mon Sep 17 00:00:00 2001 From: Julius Tens Date: Fri, 16 Mar 2018 14:34:37 +0100 Subject: [PATCH 4/5] clarify code comments --- test/db.js | 2 +- test/oebb.js | 2 +- test/vbb.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/db.js b/test/db.js index 527d4318..5af0b434 100644 --- a/test/db.js +++ b/test/db.js @@ -219,7 +219,7 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) { test('journeys: via works – with detour', co(function* (t) { // Going from Westhafen to Wedding via Württembergalle without detour - // is currently impossible + // is currently impossible. We check if the routing engine computes a detour. const westhafen = '008089116' const wedding = '008089131' const württembergallee = '731084' diff --git a/test/oebb.js b/test/oebb.js index 0378d1e8..84e9be23 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -259,7 +259,7 @@ test('Albertina to Salzburg Hbf', co(function* (t) { test('journeys: via works – with detour', co(function* (t) { // Going from Stephansplatz to Schottenring via Donauinsel without detour - // is currently impossible + // is currently impossible. We check if the routing engine computes a detour. const stephansplatz = '001390167' const schottenring = '001390163' const donauinsel = '001392277' diff --git a/test/vbb.js b/test/vbb.js index 6906a5db..38b83298 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -302,7 +302,7 @@ test('journeys – station to POI', co(function* (t) { test('journeys: via works – with detour', co(function* (t) { // Going from Westhafen to Wedding via Württembergalle without detour - // is currently impossible + // is currently impossible. We check if the routing engine computes a detour. const westhafen = '900000001201' const wedding = '900000009104' const württembergallee = '900000026153' From 51e41ba4e59f91dce2108df0cb5216dd2345ca1e Mon Sep 17 00:00:00 2001 From: Julius Tens Date: Fri, 16 Mar 2018 14:38:08 +0100 Subject: [PATCH 5/5] clarify code comments --- test/db.js | 4 ++-- test/oebb.js | 4 ++-- test/vbb.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/db.js b/test/db.js index 5af0b434..0c623d73 100644 --- a/test/db.js +++ b/test/db.js @@ -233,7 +233,7 @@ test('journeys: via works – with detour', co(function* (t) { t.ok(journey) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee)) - t.ok(l, 'no stopover at Württembergalle') + t.ok(l, 'Württembergalle is not being passed') t.end() })) @@ -254,7 +254,7 @@ test('journeys: via works – without detour', co(function* (t) { t.ok(journey) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee)) - t.ok(l, 'no stopover at Kastanienallee') + t.ok(l, 'Kastanienallee is not being passed') t.end() })) diff --git a/test/oebb.js b/test/oebb.js index 84e9be23..62e6412b 100644 --- a/test/oebb.js +++ b/test/oebb.js @@ -274,7 +274,7 @@ test('journeys: via works – with detour', co(function* (t) { t.ok(journey) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === donauinselPassed)) - t.ok(l, 'no stopover at Donauinsel') + t.ok(l, 'Donauinsel is not being passed') t.end() })) @@ -297,7 +297,7 @@ test('journeys: via works – without detour', co(function* (t) { t.ok(journey) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === museumsquartierPassed)) - t.ok(l, 'no stopover at Weihburggasse') + t.ok(l, 'Weihburggasse is not being passed') t.end() })) diff --git a/test/vbb.js b/test/vbb.js index 38b83298..778c432b 100644 --- a/test/vbb.js +++ b/test/vbb.js @@ -316,7 +316,7 @@ test('journeys: via works – with detour', co(function* (t) { t.ok(journey) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee)) - t.ok(l, 'no stopover at Württembergalle') + t.ok(l, 'Württembergalle is not being passed') t.end() })) @@ -337,7 +337,7 @@ test('journeys: via works – without detour', co(function* (t) { t.ok(journey) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === kastanienallee)) - t.ok(l, 'no stopover at Kastanienallee') + t.ok(l, 'Kastanienallee is not being passed') t.end() }))