1
"""In this module we test the DeckGL Bokeh Model"""
2

3 7
import json
4

5 7
import pytest
6 7
from panel.models.deckgl import DeckGLPlot
7

8 7
@pytest.fixture
9 2
def json_input():
10 7
    return ('{"initialViewState": {"bearing": -27.36, "latitude": 52.2323, '
11
            '"longitude": -1.415, "maxZoom": 15, "minZoom": 5, "pitch": 40.5, '
12
            '"zoom": 6}, "layers": [{"@@type": "HexagonLayer", "autoHighlight": '
13
            'true, "coverage": 1, "data": "https://raw.githubusercontent.com/'
14
            'uber-common/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv", '
15
            '"elevationRange": [0, 3000], "elevationScale": 50, "extruded": true, '
16
            '"getPosition": "@@=[lng, lat]", "id": "18a4e022-062c-428f-877f-c8c089472297", '
17
            '"pickable": true}], "mapStyle": "mapbox://styles/mapbox/dark-v9", '
18
            '"views": [{"@@type": "MapView", "controller": true}]}')
19

20

21 7
@pytest.fixture
22 2
def mapbox_api_key():
23 7
    return (
24
        "pk.eyJ1IjoibWFyY3Nrb3ZtYWRzZW4iLCJhIjoiY2s1anMzcG5rMDYzazNvcm10NTFybTE4cSJ9."
25
        "TV1XBgaMfR-iTLvAXM_Iew"
26
    )
27

28

29 7
@pytest.fixture
30 2
def tooltip():
31 7
    return True
32

33

34 7
def test_constructor(json_input, mapbox_api_key, tooltip):
35
    # When
36 7
    data = json.loads(json_input)
37 7
    layers = data.pop('layers')
38 7
    view_state = data.pop('initialViewState')
39 7
    actual = DeckGLPlot(data=data, layers=layers, initialViewState=view_state,
40
                        mapbox_api_key=mapbox_api_key, tooltip=tooltip,)
41
    # Then
42 7
    assert actual.data == data
43 7
    assert actual.layers == layers
44 7
    assert actual.initialViewState == view_state
45 7
    assert actual.mapbox_api_key == mapbox_api_key
46 7
    assert actual.tooltip == tooltip

Read our documentation on viewing source code .

Loading