def test_isonline_routing_exception():
    """Test isonline exceptions."""
    ls = LS(api_key=LS_API_KEY)
    with pytest.raises(ValueError):
        ls.calculate_isoline(
            range="900",
            range_type="time",
            mode="fastest;car;",
        )
    with pytest.raises(ValueError):
        ls.calculate_isoline(
            range="900",
            range_type="time",
            mode="fastest;car;",
            arrival="2020-05-04T17:00:00+02",
            start=[52.5, 13.4],
        )
    with pytest.raises(ValueError):
        ls.calculate_isoline(
            range="900",
            range_type="time",
            mode="fastest;car;",
            departure="2020-05-04T17:00:00+02",
            destination=[52.5, 13.4],
        )
def test_isonline_routing():
    """Test isonline routing api."""
    ls = LS(api_key=LS_API_KEY)
    result = ls.calculate_isoline(
        start=[52.5, 13.4],
        range="900",
        range_type="time",
        mode="fastest;car;",
        departure="2020-05-04T17:00:00+02",
    )

    coordinates = result.isoline[0]["component"][0]["shape"]
    assert coordinates[0]
    geo_json = result.to_geojson()
    assert geo_json.type == "Feature"
    assert geo_json.geometry.type == "Polygon"

    result2 = ls.calculate_isoline(
        destination=[52.5, 13.4],
        range="900",
        range_type="time",
        mode="fastest;car;",
        arrival="2020-05-04T17:00:00+02",
    )
    coordinates = result2.isoline[0]["component"][0]["shape"]
    assert coordinates[0]

    with pytest.raises(ValueError):
        ls.calculate_isoline(
            start=[52.5, 13.4],
            range="900",
            range_type="time",
            mode="fastest;car;",
            destination=[52.5, 13.4],
        )
    with pytest.raises(ApiError):
        ls2 = LS(api_key="dummy")
        ls2.calculate_isoline(
            start=[52.5, 13.4],
            range="900",
            range_type="time",
            mode="fastest;car;",
        )