Esempio n. 1
0
def mock_get_public_transport_stops_query(monkeypatch, current_location):
    api = overpy.Overpass()
    monkeypatch.setattr(
        overpass_service.API, "query", lambda query: api.parse_json(
            utils.get_file(
                _get_public_transport_stops_result_filename(current_location),
                'overpass')))
Esempio n. 2
0
 def mockreturn(current_location_inner, exit_uic_ref_inner,
                call_counter_inner):
     return api.parse_json(
         utils.get_file(
             _get_connection_coordinates_result_filename(
                 current_location_inner, exit_uic_ref_inner,
                 call_counter_inner), 'overpass'))
def _mock_test_get_public_transport_connection_get_connection(
        start, destination):
    response_file = None
    # Test: test_get_public_transport_connection_single_leg
    # Zürich, Rote Fabrik to Zürich, Stadtgrenze
    if start == '8587347' and destination == '8.5411959,47.3353129':
        response_file = utils.get_file('search_ch_response_single_leg.json',
                                       'search_ch')

    # Test: test_get_public_transport_connection_filtered_walking_leg
    # Zürich, Rote Fabrik to Zürich Enge, Bahnhof
    elif start == '8587347' and destination == '8.5307605,47.3641833':
        response_file = utils.get_file('search_ch_response_walking_leg.json',
                                       'search_ch')

    # Test: test_get_public_transport_connection_filtered_multiple_leg
    # Zürich, Seerose to Zürich Enge, Bahnhof
    elif start == '8591357' and destination == '8.5307605,47.3641833':
        response_file = utils.get_file('search_ch_response_multiple_legs.json',
                                       'search_ch')

    if response_file is None:
        assert False
    return search_ch_parser.parse_connections(response_file)['connections'][0]
def test_parse_connection_with_no_timetables():
    with pytest.raises(RuntimeError):
        search_ch_response = utils.get_file(
            'search_ch_response_no_timetable_information.json', 'search_ch')
        search_ch_parser.parse_connections(search_ch_response)
def test_parse_connections_invalid_response():
    with pytest.raises(RuntimeError):
        search_ch_response = utils.get_file('search_ch_invalid_response.json',
                                            'search_ch')
        search_ch_parser.parse_connections(search_ch_response)
Esempio n. 6
0
def test_parse_connections():
    search_ch_response = utils.get_file('search_ch_response.json', 'search_ch')
    parsed_response = search_ch_parser.parse_connections(search_ch_response)
    # a walking leg and the last one will be skipped
    assert parsed_response['connections'][0]['number_of_legs'] == 2
Esempio n. 7
0
def test_parse_connection_address_as_destination():
    search_ch_response = utils.get_file('search_ch_response_address_destination.json', 'search_ch')
    parsed_response = search_ch_parser.parse_connections(search_ch_response)
    # two walking legs and the last one will be skipped
    assert parsed_response['connections'][0]['number_of_legs'] == 3
def mock_get_connection(monkeypatch):
    monkeypatch.setattr(
        search_ch_service, "_query", lambda payload: utils.get_file(
            _get_get_connection_filename(payload), 'search_ch'))