def test_example_neighborhood_map():
    """Check a specific neighborhood."""
    figure = neighborhood_map(*NBHD_DATA, selected=0)
    center = {'lon': -122.36866107043352, 'lat': 47.66757206792284}
    assert figure['data'][0]['type'] == 'choroplethmapbox'
    assert figure['data'][0]['selectedpoints'] == [0]
    assert figure['layout']['mapbox']['center'] == center
def test_default_neighborhood_map():
    """Check a default values."""
    figure = neighborhood_map(*NBHD_DATA)
    center = {'lon': -122.3079690839059, 'lat': 47.6591634637792}
    assert figure['data'][0]['type'] == 'choroplethmapbox'
    assert figure['data'][0]['selectedpoints'] == [92]
    assert figure['layout']['mapbox']['center'] == center
Esempio n. 3
0
def update_neighborhood_map(neighborhood):
    """Update Seattle neighborhood map.

    Update neighborhood map after a drowpdown selection is made.

    Parameters
    ----------
    neighborhood : int
        Currently selected neighborhood (0-102).

    Returns
    -------
    figure : dict
        Plotly choroplethmapbox figure.
    """
    return neighborhood_map(*NBHD_DATA, selected=neighborhood)
def test_output_type_neighborhood_map():
    """Check output type of neighborhood map."""
    figure = neighborhood_map(*NBHD_DATA)
    assert isinstance(figure, dict)
def test_neighborhood_neighborhood_map():
    """Ensure function breaks if given wrong neighborhood."""
    with pytest.raises(KeyError):
        neighborhood_map(*NBHD_DATA, selected=200)
Esempio n. 6
0
 # Row two
 html.Div(
     id='rowTwo',
     className='twelve columns',
     children=[
         # Seattle Neighborhood Map
         html.Div(
             id='neighborhoodMapContainer',
             className='six columns prettyContainer',
             children=[
                 html.H4(
                     className='centerTitle',
                     children='Seattle Neighborhoods'),
                 dcc.Graph(
                     id='neighborhoodMapFigure',
                     figure=neighborhood_map(*NBHD_DATA)
                 ),
                 html.Br(),
                 html.P(NBHD_DESCRIPTION)
             ]
         ),
         # Neighborhood Road Map
         html.Div(
             id='roadMapContainer',
             className='six columns prettyContainer',
             children=[
                 html.H4(
                     id='roadMapTitle',
                     className='centerTitle',
                     children='Neighborhood Roads'
                 ),