def serve_layout(): return html.Div(children=[ # hidden signal value html.Div(id='signal', style={'display': 'none'}), dcc.Interval(id='interval-component', interval=get_query_interval(), n_intervals=0), html.H1(children='Covid-19 Statistics (D, A, CH, UK, US)'), html.Div(children=[ 'Sources: ', dcc.Link( 'Robert-Koch-Institut (DE)', href= 'https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Fallzahlen.html' ), ', ', dcc.Link( 'Sozialministerium (AT)', href= 'https://www.sozialministerium.at/Informationen-zum-Coronavirus/Neuartiges-Coronavirus-(2019-nCov).html' ), ', ', dcc.Link( 'Bundesamt fuer Gesundheit (CH)', href= 'https://www.bag.admin.ch/bag/de/home/krankheiten/ausbrueche-epidemien-pandemien/aktuelle-ausbrueche-epidemien/novel-cov/situation-schweiz-und-international.html' ), ', ', dcc.Link( 'British Government (UK)', href= 'https://www.gov.uk/guidance/coronavirus-covid-19-information-for-the-public' ), ', ', dcc.Link( 'Centers for Disease Control and Prevention (US)', href= 'https://www.cdc.gov/coronavirus/2019-ncov/cases-updates/cases-in-us.html?CDC_AA_refVal=https%3A%2F%2Fwww.cdc.gov%2Fcoronavirus%2F2019-ncov%2Fcases-in-us.html' ), html.Br(), html.Div(id='last-updated') ]), dcc.Graph(id='covid-cases-graph'), dcc.Graph(id='covid-deaths-graph'), html.Br(), dcc.Link('track-covid19', href="https://github.com/ondrno/track-covid19"), html.Span(', version: {}'.format(cov19.__version__)), ])
'x': ch["date"], 'y': ch["d"], 'name': "Switzerland" }, { 'x': uk["date"], 'y': uk["d"], 'name': "United Kingdom" }, { 'x': us["date"], 'y': us["d"], 'name': "United States" }, ], 'layout': { 'title': 'Confirmed deaths', 'yaxis': { 'type': 'log' }, } } return fig app.layout = serve_layout if __name__ == '__main__': logger.info("Update cycle={} minutes", get_query_interval() / 1000 / 60) app.run_server(port=os.environ.get('PORT', 8050))
def test_query_interval_returns_set_env_values(mock_get, value, exp_ms): mock_get.return_value = value interval = get_query_interval() assert exp_ms == interval
def test_query_interval_raises_exception_for_values_with_invalid_units( mock_get, value): mock_get.return_value = value with pytest.raises(ValueError): get_query_interval()
def test_query_interval_casts_valid_units_to_default(mock_get, value): mock_get.return_value = value four_hours_in_ms = 4 * 60 * 60 * 1000 interval = get_query_interval() assert four_hours_in_ms == interval