def test_speed_road_map():
    """Check speed limit values."""
    figure = road_map(STREET_DATA, map_type='speed')
    color = 'rgb(0.000000,0.407843,0.215686)'
    title = 'Speed Limit (mph)'
    assert figure['data'][0]['marker']['colorscale'][0][1] == color
    assert figure['layout']['yaxis']['title'] == title
def test_flow_road_map():
    """Check flow count values."""
    figure = road_map(STREET_DATA, map_type='flow', year=2007)
    color = 'rgb(0.267004,0.004874,0.329415)'
    title = '2007 Average Weekday Traffic (1000 vehicles)'
    assert figure['data'][0]['marker']['colorscale'][0][1] == color
    assert figure['layout']['yaxis']['title'] == title
def test_road_road_map():
    """Check road type values."""
    figure = road_map(STREET_DATA, map_type='road')
    color = 'rgb(0.121569,0.466667,0.705882)'
    legend = 'Not Designated'
    title = 'Arterial Classification'
    assert figure['data'][0]['marker']['colorscale'][0][1] == color
    assert figure['data'][0]['marker']['colorbar']['ticktext'][0] == legend
    assert figure['layout']['yaxis']['title'] == title
def update_road_map(neighborhood, map_type, year):
    """Update neighborhood road map.

    Update road map after a dropdown, radio, or slider selection is
    made. Also triggered by neighborhood map selection via dropdown
    callback.

    Parameters
    ----------
    neighborhood : int
        Currently selected neighborhood (0-102)
    map_type : str
        Currently selected map type (flow, speed, road).
    year : int
        Currently selected year (2007-2018)

    Returns
    -------
    figure : dict
        Plotly scattermapbox figure.
    """
    return road_map(STREET_DATA, neighborhood, map_type, year)
def test_type_road_map():
    """Ensure function breaks if given wrong map type."""
    with pytest.raises(KeyError):
        road_map(STREET_DATA, map_type='dummy')
def test_neighborhood_road_map():
    """Ensure function breaks if given wrong neighborhood."""
    with pytest.raises(KeyError):
        road_map(STREET_DATA, neighborhood=200)
def test_example_road_map():
    """Check specific neighborhood."""
    figure = road_map(STREET_DATA, neighborhood=0)
    assert figure['data'][0]['type'] == 'scattergl'
    assert figure['data'][0]['x'] == [-122.36866107043352]
    assert figure['data'][0]['y'] == [47.66757206792284]
def test_default_road_map():
    """Check default neighborhood."""
    figure = road_map(STREET_DATA)
    assert figure['data'][0]['type'] == 'scattergl'
    assert figure['data'][0]['x'] == [-122.3079690839059]
    assert figure['data'][0]['y'] == [47.6591634637792]
def test_output_type_road_map():
    """Check output type of road map."""
    figure = road_map(STREET_DATA)
    assert isinstance(figure, dict)
def test_year_road_map():
    """Ensure function breaks if given wrong year."""
    with pytest.raises(KeyError):
        road_map(STREET_DATA, year=0)
                 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'
                 ),
                 dcc.Graph(
                     id='roadMapFigure',
                     figure=road_map(STREET_DATA)
                 ),
                 html.Br(),
                 html.P(MAP_DESCRIPTION)
             ]
         )
     ]
 ),
 # Row three
 html.Div(
     id='rowThree',
     className='twelve columns',
     children=[
         # Flow Count Bar Chart
         html.Div(
             id='flowCountContainer',