update db,vbb via tests

This commit is contained in:
Julius Tens 2018-03-16 14:30:49 +01:00
parent 28641cd711
commit 429d0d1f0c
2 changed files with 20 additions and 78 deletions

View file

@ -218,34 +218,30 @@ test('Berlin Jungfernheide to ATZE Musiktheater', co(function* (t) {
t.end() t.end()
})) }))
test('journeys: via works changing trains', co(function* (t) { test('journeys: via works with detour', co(function* (t) {
// Going from Westhafen to Wedding via Württembergalle without changing // Going from Westhafen to Wedding via Württembergalle without detour
// is currently impossible. We check if the routing engine lets us change // is currently impossible
// at Württembergallee if we set it as via.
const westhafen = '008089116' const westhafen = '008089116'
const wedding = '008089131' const wedding = '008089131'
const württembergallee = '731084' const württembergallee = '731084'
const [journey] = yield client.journeys(westhafen, wedding, { const [journey] = yield client.journeys(westhafen, wedding, {
via: württembergallee, via: württembergallee,
results: 1, results: 1,
when when,
passedStations: true
}) })
t.ok(journey) 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) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee))
t.ok(i2 >= 0, 'no leg with Württembergallee as origin') t.ok(l, 'no stopover at Württembergalle')
t.ok(i2 >= i1)
t.end() 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* // When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
// to change trains. We check if the routing engine *does not* require // to change trains / no need for a "detour".
// one to change at the via station.
const ruhleben = '000731058' const ruhleben = '000731058'
const zoo = '008010406' const zoo = '008010406'
const kastanienallee = '730983' const kastanienallee = '730983'
@ -257,36 +253,13 @@ test('journeys: via works *without* changing trains', co(function* (t) {
}) })
t.ok(journey) 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.ok(l, 'no stopover at Kastanienallee')
t.end() 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) { test('earlier/later journeys, Jungfernheide -> München Hbf', co(function* (t) {
const model = yield client.journeys(jungfernh, münchenHbf, { const model = yield client.journeys(jungfernh, münchenHbf, {
results: 3, when results: 3, when

View file

@ -300,36 +300,30 @@ test('journeys  station to POI', co(function* (t) {
t.end() t.end()
})) }))
test('journeys: via works with detour', co(function* (t) {
// Going from Westhafen to Wedding via Württembergalle without detour
test('journeys: via works  changing trains', co(function* (t) { // is currently impossible
// 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 westhafen = '900000001201'
const wedding = '900000009104' const wedding = '900000009104'
const württembergallee = '900000026153' const württembergallee = '900000026153'
const [journey] = yield client.journeys(westhafen, wedding, { const [journey] = yield client.journeys(westhafen, wedding, {
via: württembergallee, via: württembergallee,
results: 1, results: 1,
when when,
passedStations: true
}) })
t.ok(journey) 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) const l = journey.legs.some(l => l.passed && l.passed.some(p => p.station.id === württembergallee))
t.ok(i2 >= 0, 'no leg with Württembergallee as origin') t.ok(l, 'no stopover at Württembergalle')
t.ok(i2 >= i1)
t.end() 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* // When going from Ruhleben to Zoo via Kastanienallee, there is *no need*
// to change trains. We check if the routing engine *does not* require // to change trains / no need for a "detour".
// one to change at the via station.
const ruhleben = '900000025202' const ruhleben = '900000025202'
const zoo = '900000023201' const zoo = '900000023201'
const kastanienallee = '900000020152' const kastanienallee = '900000020152'
@ -341,38 +335,13 @@ test('journeys: via works *without* changing trains', co(function* (t) {
}) })
t.ok(journey) 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.ok(l, 'no stopover at Kastanienallee')
t.end() 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) { test('departures', co(function* (t) {
const deps = yield client.departures(spichernstr, {duration: 5, when}) const deps = yield client.departures(spichernstr, {duration: 5, when})