Exemple #1
0
def here_basic_routing_test(valid_here_routing_response):
    origin = make_pt_object(type_pb2.POI, 2.439938, 48.572841)
    destination = make_pt_object(type_pb2.STOP_AREA, 2.440548, 48.57307)
    fallback_extremity = PeriodExtremity(str_to_time_stamp('20161010T152000'),
                                         True)
    response = Here._read_response(
        response=valid_here_routing_response,
        mode='walking',
        origin=origin,
        destination=destination,
        fallback_extremity=fallback_extremity,
        request={'datetime': str_to_time_stamp('20170621T174600')},
    )
    assert response.status_code == 200
    assert response.response_type == response_pb2.ITINERARY_FOUND
    assert len(response.journeys) == 1
    assert response.journeys[0].duration == 588
    assert len(response.journeys[0].sections) == 1
    section = response.journeys[0].sections[0]
    assert section.type == response_pb2.STREET_NETWORK
    assert section.length == 4012
    assert section.duration == 588
    assert section.destination == destination
    assert section.origin == origin
    assert section.begin_date_time == str_to_time_stamp('20161010T152000')
    assert section.end_date_time == section.begin_date_time + section.duration
Exemple #2
0
def here_basic_routing_test(valid_here_routing_response):
    origin = make_pt_object(type_pb2.POI, 2.439938, 48.572841)
    destination = make_pt_object(type_pb2.STOP_AREA, 2.440548, 48.57307)

    # for a beginning fallback
    fallback_extremity = PeriodExtremity(str_to_time_stamp('20161010T152000'),
                                         True)
    response = Here._read_response(
        response=valid_here_routing_response,
        mode='walking',
        origin=origin,
        destination=destination,
        fallback_extremity=fallback_extremity,
        request={'datetime': str_to_time_stamp('20161010T152000')},
        direct_path_type=StreetNetworkPathType.BEGINNING_FALLBACK,
    )
    assert response.status_code == 200
    assert response.response_type == response_pb2.ITINERARY_FOUND
    assert len(response.journeys) == 1
    assert response.journeys[0].duration == 1468
    assert len(response.journeys[0].sections) == 1
    section = response.journeys[0].sections[0]
    assert section.type == response_pb2.STREET_NETWORK
    assert section.length == 21919
    assert section.duration == 1468
    assert section.destination == destination
    assert section.origin == origin
    assert section.begin_date_time == str_to_time_stamp('20161010T152000')
    assert section.end_date_time == section.begin_date_time + section.duration
    assert section.base_begin_date_time == str_to_time_stamp(
        '20161010T152000') + (1468 - 1344)
    assert section.base_end_date_time == section.begin_date_time + section.duration
    # dynamic_speed
    dynamic_speeds = section.street_network.dynamic_speeds
    assert len(dynamic_speeds) == 6
    first_ds = dynamic_speeds[0]
    assert round(first_ds.base_speed, 2) == 13.89
    assert round(first_ds.traffic_speed, 2) == 11.94
    assert first_ds.geojson_offset == 0
    last_ds = dynamic_speeds[5]
    assert round(last_ds.base_speed, 2) == 13.89
    assert round(last_ds.traffic_speed, 2) == 13.89
    assert last_ds.geojson_offset == 769

    # for a direct path and clockiwe == True
    response = Here._read_response(
        response=valid_here_routing_response,
        mode='walking',
        origin=origin,
        destination=destination,
        fallback_extremity=fallback_extremity,
        request={'datetime': str_to_time_stamp('20161010T152000')},
        direct_path_type=StreetNetworkPathType.DIRECT,
    )
    assert response.status_code == 200
    assert response.response_type == response_pb2.ITINERARY_FOUND
    assert len(response.journeys) == 1
    assert len(response.journeys[0].sections) == 1
    section = response.journeys[0].sections[0]
    assert section.begin_date_time == str_to_time_stamp('20161010T152000')
    assert section.end_date_time == section.begin_date_time + section.duration
    assert section.base_begin_date_time == str_to_time_stamp(
        '20161010T152000') + (1468 - 1344)
    assert section.base_end_date_time == section.begin_date_time + section.duration

    # for a ending fallback
    fallback_extremity = PeriodExtremity(str_to_time_stamp('20161010T152000'),
                                         True)
    response = Here._read_response(
        response=valid_here_routing_response,
        mode='walking',
        origin=origin,
        destination=destination,
        fallback_extremity=fallback_extremity,
        request={'datetime': str_to_time_stamp('20161010T152000')},
        direct_path_type=StreetNetworkPathType.ENDING_FALLBACK,
    )
    assert response.status_code == 200
    assert response.response_type == response_pb2.ITINERARY_FOUND
    assert len(response.journeys) == 1
    section = response.journeys[0].sections[0]
    assert section.begin_date_time == str_to_time_stamp(
        '20161010T152000') - section.duration
    assert section.end_date_time == str_to_time_stamp('20161010T152000')
    assert section.base_begin_date_time == str_to_time_stamp(
        '20161010T152000') - section.duration
    assert section.base_end_date_time == section.end_date_time - (1468 - 1344)

    # for a direct path and clockiwe == False
    fallback_extremity = PeriodExtremity(str_to_time_stamp('20161010T152000'),
                                         False)
    response = Here._read_response(
        response=valid_here_routing_response,
        mode='walking',
        origin=origin,
        destination=destination,
        fallback_extremity=fallback_extremity,
        request={'datetime': str_to_time_stamp('20161010T152000')},
        direct_path_type=StreetNetworkPathType.DIRECT,
    )
    assert response.status_code == 200
    assert response.response_type == response_pb2.ITINERARY_FOUND
    assert len(response.journeys) == 1
    assert len(response.journeys[0].sections) == 1
    section = response.journeys[0].sections[0]
    assert section.end_date_time == str_to_time_stamp('20161010T152000')
    assert section.begin_date_time == section.end_date_time - section.duration
    assert section.base_end_date_time == section.end_date_time
    assert section.base_begin_date_time == section.base_end_date_time - section.duration + (
        1468 - 1344)

    # for a beginning fallback and clockiwe == False
    fallback_extremity = PeriodExtremity(str_to_time_stamp('20161010T152000'),
                                         False)
    response = Here._read_response(
        response=valid_here_routing_response,
        mode='walking',
        origin=origin,
        destination=destination,
        fallback_extremity=fallback_extremity,
        request={'datetime': str_to_time_stamp('20161010T152000')},
        direct_path_type=StreetNetworkPathType.BEGINNING_FALLBACK,
    )
    assert response.status_code == 200
    assert response.response_type == response_pb2.ITINERARY_FOUND
    assert len(response.journeys) == 1
    assert len(response.journeys[0].sections) == 1
    section = response.journeys[0].sections[0]
    assert section.end_date_time == str_to_time_stamp('20161010T152000')
    assert section.begin_date_time == section.end_date_time - section.duration
    assert section.base_end_date_time == section.end_date_time
    assert section.base_begin_date_time == section.base_end_date_time - section.duration + (
        1468 - 1344)