Beispiel #1
0
def test_ordnance_survey_tile_styles():
    """
    Tests that setting the Ordnance Survey tile style works as expected.

    This is essentially just assures information is properly propagated through
    the class structure.
    """
    dummy_apikey = "None"

    ref_url = ('https://api2.ordnancesurvey.co.uk/'
               'mapping_api/v1/service/wmts?'
               'key=None&height=256&width=256&tilematrixSet=EPSG%3A3857&'
               'version=1.0.0&style=true&layer={layer}%203857&'
               'SERVICE=WMTS&REQUEST=GetTile&format=image%2Fpng&'
               'TileMatrix=EPSG%3A3857%3A{z}&TileRow={y}&TileCol={x}')
    tile = ["1", "2", "3"]

    # Default is Road.
    os = cimgt.OrdnanceSurvey(dummy_apikey)
    url = os._image_url(tile)
    assert url == ref_url.format(layer="Road", z=tile[2], y=tile[1], x=tile[0])

    for layer in ['Outdoor', 'Light', 'Night', 'Leisure']:
        os = cimgt.OrdnanceSurvey(dummy_apikey, layer=layer)
        url = os._image_url(tile)
        assert url == ref_url.format(layer=layer,
                                     z=tile[2],
                                     y=tile[1],
                                     x=tile[0])

    # Exception is raised if unknown style is passed.
    with pytest.raises(ValueError):
        cimgt.OrdnanceSurvey(dummy_apikey, layer="random_style")
Beispiel #2
0
def test_ordnance_survey_tile_styles():
    """
    Tests that setting the Ordnance Survey tile style works as expected.

    This is essentially just assures information is properly propagated through
    the class structure.
    """
    dummy_apikey = "None"

    ref_url = ('https://api2.ordnancesurvey.co.uk/'
               'mapping_api/v1/service/wmts?'
               'key=None&height=256&width=256&tilematrixSet=EPSG%3A3857&'
               'version=1.0.0&style=true&layer={layer}%203857&'
               'SERVICE=WMTS&REQUEST=GetTile&format=image%2Fpng&'
               'TileMatrix=EPSG%3A3857%3A{z}&TileRow={y}&TileCol={x}')
    tile = ["1", "2", "3"]

    # Default is Road.
    os = cimgt.OrdnanceSurvey(dummy_apikey)
    url = os._image_url(tile)
    assert url == ref_url.format(layer="Road",
                                 z=tile[2], y=tile[1], x=tile[0])

    for layer in ['Outdoor', 'Light', 'Night', 'Leisure']:
        os = cimgt.OrdnanceSurvey(dummy_apikey, layer=layer)
        url = os._image_url(tile)
        assert url == ref_url.format(layer=layer,
                                     z=tile[2], y=tile[1], x=tile[0])

    # Exception is raised if unknown style is passed.
    with pytest.raises(ValueError):
        cimgt.OrdnanceSurvey(dummy_apikey, layer="random_style")