def test_load_filters_areas(tmp_path, alert_dict, mocker): alert_dict['areas']['simple_polygons'] = 'polygons' mocker.patch.object(Alerts, 'from_yaml', return_value=[alert_dict]) mocker.patch.object(Alerts, 'from_api', return_value=[]) mocker.patch('app.models.alerts.is_in_uk', return_value=False) assert len(Alerts.load()) == 0 mocker.patch('app.models.alerts.is_in_uk', return_value=True) assert len(Alerts.load()) == 1
def show_page(key): alerts = Alerts.load() rendered_pages = get_rendered_pages(alerts) if key in rendered_pages: return rendered_pages[key] return current_app.send_static_file(key)
def publish_govuk_alerts(self): try: alerts = Alerts.load() rendered_pages = get_rendered_pages(alerts) upload_to_s3(rendered_pages) purge_fastly_cache() except Exception: current_app.logger.exception( "Failed to publish content to gov.uk/alerts") self.retry(queue=current_app.config['QUEUE_NAME'])
def test_load(alert_dict, mocker): mocker.patch.object(Alerts, 'from_yaml', return_value=[alert_dict]) mocker.patch.object(Alerts, 'from_api', return_value=[alert_dict]) alerts = Alerts.load() assert len(alerts) == 2 assert isinstance(alerts[0], Alert)