def test_with_old_data_diff_date(self, app, use_db, remote_data, remote_totals, mock_send_telegram_message): CaseDataFactory( location__minzdrav_name="Алматы", confirmed=1, recovered=2, fatal=3, date=date(2020, 12, 10), ) CaseDataFactory( location__minzdrav_name="Астана", confirmed=1, recovered=2, fatal=3, date=date(2020, 12, 10), ) CaseDataFactory( location__minzdrav_name="Шымкент", confirmed=1, recovered=2, fatal=3, date=date(2020, 12, 10), ) update_data() cases = CaseData.query.all() assert len(cases) == 6 assert queries.load_current_data() == remote_data assert queries.get_totals() == remote_totals mock_send_telegram_message.assert_called_once()
def test_totals(use_db): factories.TotalFactory(date=date(2020, 12, 10)) factories.TotalFactory(date=date(2020, 12, 11)) last = factories.TotalFactory(date=date(2020, 12, 12)) assert queries.get_totals() == { "confirmed": last.confirmed, "recovered": last.recovered, "fatal": last.fatal, }
def test_no_old_data( self, app, use_db, locations, remote_data, remote_totals, mock_send_telegram_message, ): update_data() cases = CaseData.query.all() assert len(cases) == 3 assert queries.load_current_data() == remote_data assert queries.get_totals() == remote_totals mock_send_telegram_message.assert_called_once()
def render_layout(): df = get_df() updated_at = get_updated_at() totals = get_totals() map_fig = get_map(df, updated_at) total_df = df.groupby("date").sum() confirmed_cumulative_chart = render_confirmed_cumulative_chart(total_df) confirmed_daily_chart = render_confirmed_daily_chart(total_df) recovered_cumulative_chart = render_recovered_cumulative_chart(total_df) daily_increase_chart = render_daily_increase_chart(total_df) fatal_cumulative_chart = render_fatal_cumulative_chart(total_df) confirmed_cumulative_by_region_chart = render_confirmed_cumulative_by_region_chart( df ) table = get_table(df) layout = html.Div( children=[ html.Header( children=[ html.Div( children=[ html.H1( "Карта распространения коронавирусной инфекции COVID-19 в Казахстане", className="main-title", ), ], className="box", ) ], className="header is-hidden-mobile", ), html.Div( children=[ html.Div( children=[ html.H2(totals["confirmed"], className="card-title danger"), html.H3( "Зарегистрированных случаев", className="card-subtitle", ), ], className="card", ), html.Div( children=[ html.H2( totals["recovered"], className="card-title success" ), html.H3("Выздоровевших", className="card-subtitle"), ], className="card", ), html.Div( children=[ html.H2(totals["fatal"], className="card-title"), html.H3("Летальных исходов", className="card-subtitle"), ], className="card", ), html.Div( children=[ html.P("Последнее обновление"), html.H3(updated_at, className="card-subtitle"), ], className="card is-hidden-mobile", ), ], className="summary", ), html.Div( children=[dcc.Graph(id="map", figure=map_fig, responsive=True), table], className="main", ), html.Div( children=[ dcc.Graph(figure=confirmed_cumulative_chart), dcc.Graph(figure=confirmed_cumulative_by_region_chart), dcc.Graph(figure=daily_increase_chart), dcc.Graph(figure=confirmed_daily_chart), dcc.Graph(figure=recovered_cumulative_chart), dcc.Graph(figure=fatal_cumulative_chart), ], className="charts", ), html.Div( children=[ html.Div( children=[ html.H4( "Сайт covidmap.kz создан исключительно в информативных целях", ), html.P( "Данные о зарегистрированных случаях берутся из официальных источников и обновляются в автоматическом режиме по мере публикации Министерством здравоохранения Республики Казахстан", ), ], className="box", ) ], className="footer", ), ], className="dashboard", ) return layout