Beispiel #1
0
 def isochrone(self, request, instance):
     return new_default.Scenario().isochrone(request, instance)
Beispiel #2
0
def create_next_kraken_request_test():
    request_clock = {'datetime': 100000, 'clockwise': True}
    request_anticlock = {'datetime': 110000, 'clockwise': False}
    response = response_pb2.Response()

    # test with one walk and one pt
    journey_walk = response.journeys.add()
    journey_walk.departure_date_time = 100000
    journey_walk.arrival_date_time = 101500
    journey_walk.duration = 1500
    section = journey_walk.sections.add()
    section.type = response_pb2.STREET_NETWORK
    section.street_network.mode = response_pb2.Walking
    journey_pt = response.journeys.add()
    journey_pt.departure_date_time = 100500
    journey_pt.arrival_date_time = 103000
    journey_pt.duration = 2500
    add_pt_sections(journey_pt)
    new_def = new_default.Scenario()
    # clockwise: we should have the next request one second after departure of pt journey
    next_request = new_def.create_next_kraken_request(request_clock,
                                                      [response])
    assert next_request == {'datetime': 100501, 'clockwise': True}
    # anticlockwise: we should have the next request one second before arrival of pt journey
    next_request = new_def.create_next_kraken_request(request_anticlock,
                                                      [response])
    assert next_request == {'datetime': 102999, 'clockwise': False}

    # test with one walk, 2 pt 1005->1030 and 1010->1025
    journey_pt = response.journeys.add()
    journey_pt.departure_date_time = 101000
    journey_pt.arrival_date_time = 102500
    journey_pt.duration = 1500
    add_pt_sections(journey_pt)
    # clockwise: we should have the next request one second after departure of pt journey arriving at 1025
    next_request = new_def.create_next_kraken_request(request_clock,
                                                      [response])
    assert next_request == {'datetime': 101001, 'clockwise': True}
    # anticlockwise: we should have the next request one second before arrival of pt journey leaving at 1010
    next_request = new_def.create_next_kraken_request(request_anticlock,
                                                      [response])
    assert next_request == {'datetime': 102499, 'clockwise': False}

    # test with one walk, 3 pt 1005->1030, 1010->1025 and 1015->1025
    journey_pt = response.journeys.add()
    journey_pt.departure_date_time = 101500
    journey_pt.arrival_date_time = 102500
    journey_pt.duration = 1000
    add_pt_sections(journey_pt)
    # clockwise: we should have the next request one second after departure of pt journey 1015->1025
    next_request = new_def.create_next_kraken_request(request_clock,
                                                      [response])
    assert next_request == {'datetime': 101501, 'clockwise': True}

    # test with one walk, 4 pt 1005->1030, 1010->1025, 1015->1025 and 1015->1020
    journey_pt = response.journeys.add()
    journey_pt.departure_date_time = 101500
    journey_pt.arrival_date_time = 102000
    journey_pt.duration = 500
    add_pt_sections(journey_pt)
    # anticlockwise: we should have the next request one second after departure of pt journey 1015->1020
    next_request = new_def.create_next_kraken_request(request_anticlock,
                                                      [response])
    assert next_request == {'datetime': 101999, 'clockwise': False}