Пример #1
0
def test_tilequery_with_radius_limit_dedupe_geometry_and_layers():
    add(
        method=GET,
        url="https://api.mapbox.com" + "/v4" + "/mapbox.mapbox-streets-v8" +
        "/tilequery" + "/0.0,1.1.json" + "?access_token=pk.test" +
        "&radius=25" + "&limit=25" + "&dedupe=true" + "&geometry=linestring" +
        "&layers=layer0,layer1%2Clayer2",
        match_querystring=True,
        body='{"key": "value"}',
        status=200,
    )

    tilequery = Tilequery(access_token="pk.test")

    response = tilequery.tilequery(
        "mapbox.mapbox-streets-v8",
        lon=0.0,
        lat=1.1,
        radius=25,
        limit=25,
        dedupe=True,
        geometry="linestring",
        layers=["layer0", "layer1", "layer2"],
    )

    assert response.status_code == 200
Пример #2
0
def test_object_properties():
    tilequery = Tilequery()

    assert tilequery.api_name
    assert tilequery.api_version
    assert tilequery.valid_geometries
    assert tilequery.base_uri
Пример #3
0
def test_tilequery_one_mapid():
    add(
        method=GET,
        url="https://api.mapbox.com" + "/v4" + "/mapbox.mapbox-streets-v8" +
        "/tilequery" + "/0.0,1.1.json" + "?access_token=pk.test",
        match_querystring=True,
        body='{"key": "value"}',
        status=200,
    )

    tilequery = Tilequery(access_token="pk.test")

    response = tilequery.tilequery("mapbox.mapbox-streets-v8",
                                   lon=0.0,
                                   lat=1.1)

    assert response.status_code == 200
Пример #4
0
def test_tilequery_with_radius_and_geometry():
    add(
        method=GET,
        url="https://api.mapbox.com" + "/v4" + "/mapbox.mapbox-streets-v8" +
        "/tilequery" + "/0.0,1.1.json" + "?access_token=pk.test" +
        "&radius=25" + "&geometry=linestring",
        match_querystring=True,
        body='{"key": "value"}',
        status=200,
    )

    tilequery = Tilequery(access_token="pk.test")

    response = tilequery.tilequery("mapbox.mapbox-streets-v8",
                                   lon=0.0,
                                   lat=1.1,
                                   radius=25,
                                   geometry="linestring")

    assert response.status_code == 200
Пример #5
0
def test_validate_radius_geometry(geometry):
    tilequery = Tilequery()
    result = tilequery._validate_geometry(geometry)
    assert result == geometry
Пример #6
0
def test_validate_geometry_invalid():
    tilequery = Tilequery()

    with raises(InvalidParameterError):
        tilequery._validate_geometry("invalid")
Пример #7
0
def test_validate_limit_valid(limit):
    tilequery = Tilequery()
    result = tilequery._validate_limit(limit)
    assert result == limit
Пример #8
0
def test_validate_limit_invalid(limit):
    tilequery = Tilequery()

    with raises(InvalidParameterError):
        tilequery._validate_limit(limit)
Пример #9
0
def test_validate_radius_valid(radius):
    tilequery = Tilequery()
    result = tilequery._validate_radius(radius)
    assert result == radius
Пример #10
0
def test_validate_radius_invalid():
    tilequery = Tilequery()

    with raises(InvalidParameterError):
        tilequery._validate_radius(-1)
Пример #11
0
def test_validate_lat_valid(lat):
    tilequery = Tilequery()
    result = tilequery._validate_lat(lat)
    assert result == lat
Пример #12
0
def test_validate_lat_invalid(lat):
    tilequery = Tilequery()

    with raises(InvalidCoordError):
        tilequery._validate_lat(lat)
Пример #13
0
def test_validate_lon_valid(lon):
    tilequery = Tilequery()
    result = tilequery._validate_lon(lon)
    assert result == lon
Пример #14
0
def test_validate_lon_invalid(lon):
    tilequery = Tilequery()

    with raises(InvalidCoordError):
        tilequery._validate_lon(lon)