def test_tile():
    # tuple

    add(method=GET,
        url=
        "https://api.mapbox.com/v4/mapbox.streets/0/0/0.png?access_token=pk.test",
        match_querystring=True,
        body="0.png",
        status=200)

    maps = Maps(access_token="pk.test")

    response = maps.tile("mapbox.streets", *(0, 0, 0))

    assert response.status_code == 200

    # individual x, y, and z

    add(method=GET,
        url=
        "https://api.mapbox.com/v4/mapbox.streets/0/0/0.png?access_token=pk.test",
        match_querystring=True,
        body="0.png",
        status=200)

    maps = Maps(access_token="pk.test")

    response = maps.tile("mapbox.streets", 0, 0, 0)

    assert response.status_code == 200
def test_tile_error():
    maps = Maps(access_token="pk.test")

    # x = None

    with raises(ValidationError) as exception:
        response = maps.tile("mapbox.streets", None, 0, 0)

    # y = None

    with raises(ValidationError) as exception:
        response = maps.tile("mapbox.streets", 0, None, 0)

    # z = None

    with raises(ValidationError) as exception:
        response = maps.tile("mapbox.streets", 0, 0, None)
def test_tile_with_different_file_format():
    add(method=GET,
        url=
        "https://api.mapbox.com/v4/mapbox.streets/0/0/0.grid.json?access_token=pk.test",
        match_querystring=True,
        body="0.grid.json",
        status=200)

    maps = Maps(access_token="pk.test")

    response = maps.tile("mapbox.streets", 0, 0, 0, file_format="grid.json")

    assert response.status_code == 200
def test_tile_with_retina():
    add(method=GET,
        url=
        "https://api.mapbox.com/v4/mapbox.streets/0/0/[email protected]?access_token=pk.test",
        match_querystring=True,
        body="*****@*****.**",
        status=200)

    maps = Maps(access_token="pk.test")

    response = maps.tile("mapbox.streets", 0, 0, 0, retina=True)

    assert response.status_code == 200
def test_tile_with_style():
    add(method=GET,
        url=
        "https://api.mapbox.com/v4/mapbox.streets/0/0/0.png?access_token=pk.test&style=mapbox://styles/mapbox/streets-v10@2018-01-01T00:00:00.000Z",
        match_querystring=True,
        body="0.png",
        status=200)

    maps = Maps(access_token="pk.test")

    response = maps.tile("mapbox.streets",
                         0,
                         0,
                         0,
                         style_id="mapbox://styles/mapbox/streets-v10",
                         timestamp="2018-01-01T00:00:00.000Z")

    assert response.status_code == 200
def test_tile_with_style_and_retina_and_different_file_format():
    add(method=GET,
        url=
        "https://api.mapbox.com/v4/mapbox.streets/0/0/[email protected]?access_token=pk.test&style=mapbox://styles/mapbox/streets-v10@2018-01-01T00:00:00.000Z",
        match_querystring=True,
        body="*****@*****.**",
        status=200)

    maps = Maps(access_token="pk.test")

    response = maps.tile("mapbox.streets",
                         0,
                         0,
                         0,
                         retina=True,
                         file_format="grid.json",
                         style_id="mapbox://styles/mapbox/streets-v10",
                         timestamp="2018-01-01T00:00:00.000Z")

    assert response.status_code == 200