def mock_test_find_route_walking_faster(monkeypatch):
    monkeypatch.setattr(geocoding_service, 'geocode',
                        lambda destination_address: (8.54556659082, 47.3659258552))
    monkeypatch.setattr(walking_route_finder, 'get_walking_route',
                        lambda start, destination:
                        utils.get_json_file('8_54556659082_47_3659258552_to_kreuzplatz.json', 'walking_route'))
    monkeypatch.setattr(public_transport_connection_finder, 'get_public_transport_stops',
                        lambda start: {'8503003': (8.5483858, 47.3665643)})
    monkeypatch.setattr(public_transport_connection_finder, 'get_public_transport_connection',
                        lambda start, destination, departure:
                        utils.get_json_file('bellevue_kreuzplatz.json', 'public_transport_connection'))
def test_find_route(monkeypatch):
    """ tests the route from 8.55546, 47.41071 to Zürich, Hardbrücke """
    mock.mock_test_find_route(monkeypatch)

    expected_response = utils.get_json_file('find_route_expected_result.json')
    assert expected_response == plaza_route_finder.find_route('8.55546, 47.41071', 'Zürich, Hardbrücke',
                                                              '14:42', True)
def _mock_test_find_route_only_walking_get_walking_route(start, destination):
    file_name = ''
    if start == (8.55546, 47.41071):
        #  Zürich, Messe/Hallenstadion
        if destination == (8.5510247, 47.4109266):
            file_name = '8_55546_47_41071_to_messe_hallenstadion_only_walking.json'

    return utils.get_json_file(file_name, 'walking_route')
def test_find_route_walking_faster(monkeypatch):
    """
    Tests the route from 8.54556659082, 47.3659258552 to Zürich, Kreuzplatz.
    The destination is not in walking distance but walking is faster than waiting for and taking the public transport.
    """
    mock.mock_test_find_route_walking_faster(monkeypatch)
    expected_response = utils.get_json_file('find_route_walking_faster_result.json')
    assert expected_response == plaza_route_finder.find_route('8.54556659082, 47.3659258552', 'Zürich, Kreuzplatz',
                                                              '14:42', False)
def test_find_route_only_walking(monkeypatch):
    """
    Tests the route from  8.55546, 47.41071 to Zürich, Messe/Hallenstadion.
    The destination is in walking distance thus only a walking route should be returned.
    """
    mock.mock_test_find_route_only_walking(monkeypatch)

    expected_response = utils.get_json_file('find_route_only_walking_expected_result.json')
    assert expected_response == plaza_route_finder.find_route('8.55546, 47.41071', 'Zürich, Messe/Hallenstadion',
                                                              '14:42', True)
def _mock_test_find_route_get_public_transport_connection(public_transport_stop):
    file_name = ''

    if public_transport_stop == '8591273':  # Zürich, Messe/Hallenstadion
        file_name = 'messe_hallenstadion_hardbruecke.json'
    elif public_transport_stop == '8591175':  # Zürich, Hallenbad Oerlikon
        file_name = 'hallenbad_oerlikon_hardbruecke.json'
    elif public_transport_stop == '8591319':  # Zürich, Riedgraben
        file_name = 'riedgraben_hardbruecke.json'
    elif public_transport_stop == '8591318':  # Zürich, Riedbach
        file_name = 'riedbach_hardbruecke.json'
    elif public_transport_stop == '8591256':  # Zürich, Leutschenbach
        file_name = 'leutschenbach_hardbruecke.json'
    elif public_transport_stop == '8591172':  # Zürich, Hagenholz
        file_name = 'hagenholz_hardbruecke.json'

    return utils.get_json_file(file_name, 'public_transport_connection')
def _mock_test_find_route_get_walking_route(start, destination):
    file_name = ''

    # overall walking route from 8.55546, 47.41071 to Zürich, Hardbrücke
    if start == (8.55546, 47.41071) and destination == (8.51976218438478, 47.38790425):
        file_name = '8_55546_47_41071_to_8_51976218438478_47_38790425.json'

    # start walking route from 8.55546, 47.41071 to the following public transport stops
    # the second destination is the one provided in get_public_transport_stops
    # that is used to calculate the public transport departure
    if start == (8.55546, 47.41071):
        # Zürich, Messe/Hallenstadion
        if destination == (8.5520512, 47.4106724) or destination == (8.5514849, 47.4109665):
            file_name = '8_55546_47_41071_to_messe_hallenstadion.json'
        # Zürich, Hallenbad Oerlikon
        elif destination == (8.5554806, 47.4107529) or destination == (8.5554806, 47.4107529):
            file_name = '8_55546_47_41071_to_hallenbad_oerlikon.json'
        # Zürich, Riedgraben
        elif destination == (8.5592585, 47.4108265) or destination == (8.5583961, 47.4108071):
            file_name = '8_55546_47_41071_to_riedgraben.json'
        # Zürich, Riedbach
        elif destination == (8.5584518, 47.414522) or destination == (8.5584518, 47.414522):
            file_name = '8_55546_47_41071_to_riedbach.json'
        # Zürich, Leutschenbach
        elif destination == (8.5511875, 47.4145557) or destination == (8.5513423, 47.4145863):
            file_name = '8_55546_47_41071_to_leutschenbach.json'
        # Zürich, Hagenholz
        elif destination == (8.55528, 47.41446) or destination == (8.55528, 47.41446):
            file_name = '8_55546_47_41071_to_hagenholz.json'

    # end walking leg from Zürich, Hardbrücke on different tracks to 8.51976218438478, 47.38790425
    if destination == (8.51976218438478, 47.38790425):
        # arriving from Zürich, Hallenbad Oerlikon, Zürich, Leutschenbach,
        # Zürich, Messe/Hallenstadion and Zürich, Riedgraben on track 2
        if start == (8.51768587257564, 47.385087296919714):
            file_name = 'hardbruecke_track2_to_8_51976218438478_47_38790425.json'
        # arriving from Zürich, Riedbach, Zürich, Hagenholz on track 3
        elif start == (8.5173926, 47.3851609):
            file_name = 'hardbruecke_track3_to_8_51976218438478_47_38790425.json'

    return utils.get_json_file(file_name, 'walking_route')
예제 #8
0
def mock_geocode(monkeypatch):
    monkeypatch.setattr(geocoding_service, "_query",
                        lambda payload:
                        utils.get_json_file(_get_geocode_filename(payload), 'geocoding'))