Exemplo n.º 1
0
def test_can_ask_several_layers(client, fetchall, recipes):

    fetchall([])
    recipe = Recipe(copy(recipes['default']))
    layer = Layer(recipe, copy(recipes['default'].layers['mylayer']))
    layer['name'] = 'other'
    recipe.layers['other'] = layer
    recipes['default'] = recipe

    resp = client.get('/mylayer+other/0/0/0.pbf')
    assert resp.status_code == 200
Exemplo n.º 2
0
def test_can_ask_several_layers(client, fetchall, recipes):

    fetchall([])
    recipe = Recipe(copy(recipes['default']))
    layer = Layer(recipe, copy(recipes['default'].layers['mylayer']))
    layer['name'] = 'other'
    recipe.layers['other'] = layer
    recipes['default'] = recipe

    resp = client.get('/mylayer+other/0/0/0.pbf')
    assert resp.status_code == 200
Exemplo n.º 3
0
def test_can_ask_for_specific_recipe_layers(client, fetchall, recipes):
    def check_query(query, *args, **kwargs):
        assert 'yetanother' in query

    fetchall([], check_query)

    recipe = Recipe(copy(recipes['default']))
    layer = Layer(recipe, copy(recipes['default'].layers['mylayer']))
    layer.queries[0]['sql'] = 'SELECT * FROM yetanother'
    recipe.layers['mylayer'] = layer
    recipe['name'] = 'other'
    recipes['other'] = recipe

    resp = client.get('/other/mylayer/0/0/0.pbf')
    assert resp.status_code == 200
Exemplo n.º 4
0
def test_can_ask_for_specific_recipe_layers(client, fetchall, recipes):

    def check_query(query, *args, **kwargs):
        assert 'yetanother' in query

    fetchall([], check_query)

    recipe = Recipe(copy(recipes['default']))
    layer = Layer(recipe, copy(recipes['default'].layers['mylayer']))
    layer.queries[0]['sql'] = 'SELECT * FROM yetanother'
    recipe.layers['mylayer'] = layer
    recipe['name'] = 'other'
    recipes['other'] = recipe

    resp = client.get('/other/mylayer/0/0/0.pbf')
    assert resp.status_code == 200
Exemplo n.º 5
0
def test_basic_recipe():
    recipe = Recipe({
        "name":
        "myrecipe",
        "layers": [{
            "name": "mylayer",
            "queries": [{
                "sql": "SELECT * FROM table"
            }]
        }]
    })
    assert isinstance(recipe, Recipe)
    assert isinstance(recipe.layers['mylayer'], Layer)
    assert isinstance(recipe.layers['mylayer'].queries[0], Query)
Exemplo n.º 6
0
def test_query_inherit_from_parents():
    recipe = Recipe({
        "name":
        "myrecipe",
        "srid":
        3857,
        "buffer":
        256,
        "layers": [{
            "name": "mylayer",
            "buffer": 128,
            "queries": [{
                "sql": "SELECT * FROM table"
            }]
        }]
    })
    query = recipe.layers['mylayer'].queries[0]
    assert query.sql == "SELECT * FROM table"
    assert query.buffer == 128
    assert query.srid == 3857
    assert query.unknown is None
Exemplo n.º 7
0
def pytest_configure(config):
    path = Path(str(config.rootdir)) / 'utilery/config/test.py'
    config.OLD_UTILERY_SETTINGS = os.environ.get('UTILERY_SETTINGS')
    os.environ['UTILERY_SETTINGS'] = str(path)
    from utilery import config as uconfig
    uconfig.RECIPES = []
    uconfig.PLUGINS = [TestPlugin]
    from utilery import core
    from utilery.models import Recipe
    core.RECIPES['default'] = Recipe({
        'name': 'default',
        'layers': [{
            'name': 'mylayer',
            'queries': [
                {
                    'sql': 'SELECT geometry AS way, type, name FROM osm_landusages_gen0',  # noqa
                    'maxzoom': 9
                }
            ]
        }]
    })
Exemplo n.º 8
0
def layer(recipes):
    from utilery.models import Recipe
    recipe = Recipe(copy(recipes['default']))
    recipes['default'] = recipe
    layer = recipe.layers['mylayer']
    return layer