Skip to content

Commit

Permalink
Fix leaflet python example and add test (equinor#721)
Browse files Browse the repository at this point in the history
Co-authored-by: Håvard Bjerke <[email protected]>
  • Loading branch information
HansKallekleiv and hkfb authored Jul 14, 2022
1 parent c83145f commit 21525d1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/example_leaflet_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def array2d_to_png(z_array):
"url": map_data,
"colorScale": {
"colors": DEFAULT_COLORSCALE_COLORS,
"prefixz_arrayeroAlpha": False,
"prefixZeroAlpha": False,
"scaleType": "linear",
"cutPointMin": 0,
"cutPointMax": 1,
Expand All @@ -130,7 +130,7 @@ def array2d_to_png(z_array):
"coordinatePosition": "bottomright",
},
updateMode="",
minz_arrayoom=-5,
minZoom=-5,
)

app = dash.Dash(__name__)
Expand Down
29 changes: 29 additions & 0 deletions tests/test_leaflet_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# Copyright (C) 2020 - Equinor ASA.

import json

import dash
import webviz_subsurface_components


# Basic test for the component rendering.
def test_render_leaflet_map(dash_duo: dash.testing.composite.DashComposite) -> None:

with open(
"react/src/demo/example-data/leaflet-map.json", encoding="utf8"
) as json_file:
leaflet_data = json.load(json_file)["layers"][1:]

app = dash.Dash(__name__)
app.layout = dash.html.Div(
style={"height": "90vh"},
children=webviz_subsurface_components.LeafletMap(
id="leaflet", minZoom=-5, crs="simple", layers=leaflet_data
),
)
dash_duo.start_server(app)
assert dash_duo.get_logs() == [] # Console should have no errors

0 comments on commit 21525d1

Please sign in to comment.