Ejemplo n.º 1
0
def test_get_connection_breaking_changes(monkeypatch):
    """ uses different service to test breaking changes in the api """
    mock.mock_search_ch_wrong_url(monkeypatch)
    with pytest.raises(ServiceError):
        search_ch_service.get_connection('Zürich, Sternen Oerlikon',
                                         'Zürich, Messe/Hallenstadion',
                                         '14:11')
Ejemplo n.º 2
0
def test_get_connection():
    connection = search_ch_service.get_connection(
        'Zürich, Sternen Oerlikon', 'Zürich, Messe/Hallenstadion', '14:11',
        '08.12.2017')
    assert connection is not None
    assert connection['from'] == 'Zürich, Sternen Oerlikon'
    assert connection['to'] == 'Zürich, Messe/Hallenstadion'
    assert len(connection['legs']) == 1
    assert connection['number_of_legs'] == 1
Ejemplo n.º 3
0
def test_get_connection(monkeypatch):
    mock.mock_get_connection(monkeypatch)
    connection = search_ch_service.get_connection('Zürich, Sternen Oerlikon',
                                                  'Zürich Altstetten', '14:11')
    assert connection is not None
    assert connection['from'] == 'Zürich, Sternen Oerlikon'
    assert connection['to'] == 'Zürich Altstetten'
    assert len(connection['legs']) == 2
    assert connection['number_of_legs'] == 2
Ejemplo n.º 4
0
def test_get_connection_with_disruptions(monkeypatch):
    mock.mock_get_connection(monkeypatch)
    connection = search_ch_service.get_connection(
        'Zürich Hardbrücke', 'Volketswil, Schwerzenbachstr. 16', '08:09')
    assert connection is not None
    assert connection['from'] == 'Zürich Hardbrücke'
    assert connection['to'] == 'Volketswil, Schwerzenbachstr. 16'
    assert len(connection['legs']) == 3
    assert connection['number_of_legs'] == 3
Ejemplo n.º 5
0
def test_get_connection_unavailble_service(monkeypatch):
    mock.mock_search_ch_unavailable_url(monkeypatch)
    with pytest.raises(ServiceError):
        search_ch_service.get_connection('Zürich, Sternen Oerlikon',
                                         'Zürich, Messe/Hallenstadion',
                                         '14:11')
Ejemplo n.º 6
0
def test_get_connection_same_start_and_destination():
    with pytest.raises(ValidationError):
        search_ch_service.get_connection('Zürich, Hallenstadionn',
                                         'Zürich, Messe/Hallenstadion',
                                         '07:00')
def get_public_transport_connection(start_uic_ref: str, destination: tuple,
                                    departure: str) -> dict:
    connection = search_ch_service.get_connection(start_uic_ref,
                                                  _tuple_to_str(destination),
                                                  departure)
    return _generate_public_transport_connection(connection)