def test_zoom_level_zero():
    style = _get_fill_style(
        {"fill-opacity": {
            "base": 1,
            "stops": [[0, 0.9], [10, 0.3]]
        }})
    styles = get_styles(style)
    assert len(styles) == 2
    assert _are_dicts_equal(
        styles[0], {
            'zoom_level': 0,
            'max_scale_denom': 1000000000,
            'min_scale_denom': 750000,
            'fill-color': '0,0,0,0',
            'fill-opacity': 0.9
        })

    assert _are_dicts_equal(
        styles[1], {
            'zoom_level': 10,
            'max_scale_denom': 750000,
            'min_scale_denom': 1,
            'fill-color': '0,0,0,0',
            'fill-opacity': 0.3
        })
def test_get_styles():
    style = _get_fill_style({
        "fill-outline-color": "#dfdbd7",
        "fill-color": "#f2eae2",
        "fill-opacity": {
            "base": 1,
            "stops": [[13, 0], [16, 1]]
        }
    })
    styles = get_styles(style)
    assert len(styles) == 2
    styles = sorted(styles, key=lambda s: s["zoom_level"])
    assert _are_dicts_equal(
        styles[0], {
            'fill-outline-color': '#dfdbd7',
            'fill-color': '#f2eae2',
            'zoom_level': 13,
            'fill-opacity': 0,
            'max_scale_denom': 100000,
            'min_scale_denom': 12500
        })
    assert _are_dicts_equal(
        styles[1], {
            'fill-outline-color': '#dfdbd7',
            'fill-color': '#f2eae2',
            'zoom_level': 16,
            'fill-opacity': 1,
            'max_scale_denom': 12500,
            'min_scale_denom': 1
        })
def test_highway_motorway():
    style = _get_line_layer(
        {"line-width": {
            "base": 1.2,
            "stops": [[6.5, 0], [7, 0.5], [20, 18]]
        }})
    result = get_styles(style)
    assert len(result) == 2
def test_stops():
    style = _get_line_layer({
        "line-color": "#9e9cab",
        "line-dasharray": [3, 1, 1, 1],
        "line-width": {
            "base": 1.4,
            "stops": [[4, 0.4], [5, 1], [12, 3]]
        }
    })
    styles = get_styles(style)
def test_line_dasharray():
    style = _get_line_layer({
        "line-color": "#cba",
        "line-dasharray": [1.5, 0.75],
        "line-width": {
            "base": 1.2,
            "stops": [[15, 1.2], [20, 4]]
        }
    })
    styles = get_styles(style)
def test_line_cap():
    style = {
        "id": None,
        "type": "line",
        "layout": {
            "line-cap": "round",
            "line-join": "square"
        }
    }
    styles = get_styles(style)
    assert len(styles) == 1
    assert styles[0]["line-join"] == "square"
    assert styles[0]["line-cap"] == "round"
def test_get_styles_float():
    style = _get_fill_style({
        "fill-opacity": 0.7,
        "fill-color": "#f2eae2",
    })
    styles = get_styles(style)
    assert styles[0] == {
        "fill-color": "#f2eae2",
        "fill-opacity": 0.7,
        "zoom_level": None,
        "min_scale_denom": None,
        "max_scale_denom": None
    }
def test_get_styles_simple():
    style = _get_fill_style({
        "fill-outline-color": "#dfdbd7",
        "fill-color": "#f2eae2",
    })
    styles = get_styles(style)
    assert len(styles) == 1
    assert styles[0] == {
        "fill-outline-color": "#dfdbd7",
        "fill-color": "#f2eae2",
        "zoom_level": None,
        "min_scale_denom": None,
        "max_scale_denom": None
    }
def test_line_dasharray_multiple():
    layer = _get_line_layer({"id": "test", "line-dasharray": [5, 6, 10, 11]})
    styles = get_styles(layer)
    d = xml_helper._get_line_symbol(0, styles[0])
    a = ""
def test_scale():
    style = _get_line_layer({"line-width": {"stops": [[10, 0], [15, 1]]}})
    styles = get_styles(style)
    assert len(styles) == 1
    assert styles[0]["zoom_level"] == 10