From be5aeb06766c04fccefa96656c1ca7e133a5de83 Mon Sep 17 00:00:00 2001 From: Adam Shimali Date: Wed, 9 Mar 2016 14:30:50 +0000 Subject: [PATCH] View function for request go live was always calling update service. Actually this should be no op until whatever workflow will take place in the real world is implemented. For the moment just display flash message to say request being processed and do nothing. --- app/main/views/service_settings.py | 30 ++++++++++++++----- tests/app/main/views/test_service_settings.py | 15 ++++++++-- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index b813b4f5a..a57696375 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -1,14 +1,30 @@ from flask import ( - render_template, redirect, request, url_for, abort, session) -from flask_login import (login_required, current_user) + render_template, + redirect, + request, + url_for, + abort, + session, + flash +) + +from flask_login import ( + login_required, + current_user +) + +from notifications_python_client.errors import HTTPError + +from app.main.dao.services_dao import ( + get_service_by_id, + delete_service, + update_service +) from app.main import main from app.utils import user_has_permissions -from app.main.dao.services_dao import ( - get_service_by_id, delete_service, update_service) from app.main.dao.users_dao import verify_password from app.main.forms import ConfirmPasswordForm, ServiceNameForm -from notifications_python_client.errors import HTTPError @main.route("/services//service-settings") @@ -102,8 +118,8 @@ def service_request_to_go_live(service_id): service_id=service_id ) elif request.method == 'POST': - service['restricted'] - update_service(service) + flash('Thanks your request to go live is being processed', 'default') + # TODO implement whatever this action would do in the real world return redirect(url_for('.service_settings', service_id=service_id)) diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 7d9f52822..f0210dd7e 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -1,5 +1,6 @@ -from flask import (url_for, session) +from flask import url_for from tests import validate_route_permission +from bs4 import BeautifulSoup def test_should_show_overview(app_, @@ -134,7 +135,6 @@ def test_should_show_request_to_go_live(app_, def test_should_redirect_after_request_to_go_live(app_, api_user_active, mock_get_service, - mock_update_service, mock_get_user, mock_get_user_by_email, mock_login, @@ -151,7 +151,16 @@ def test_should_redirect_after_request_to_go_live(app_, 'main.service_settings', service_id=service_id, _external=True) assert settings_url == response.location assert mock_get_service.called - assert mock_update_service.called + + with app_.test_client() as client: + client.login(api_user_active) + service_id = 123 + response = client.post(url_for( + 'main.service_request_to_go_live', service_id=service_id), follow_redirects=True) + + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + flash_banner = page.find('div', class_='banner-default').string.strip() + assert flash_banner == 'Thanks your request to go live is being processed' def test_should_show_status_page(app_,