From 0e6dab3f5c3566242b9e8e746d382067da315658 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 17 Dec 2015 16:21:34 +0000 Subject: [PATCH] Add unit tests for activity (and SMS) flows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are basic tests to make sure that the pages stay stitched together. Added for both the jobs and send SMS flows (because the send SMS flow didn’t have any before) --- app/main/views/jobs.py | 2 +- tests/app/main/views/test_jobs.py | 20 ++++++++++++++++++++ tests/app/main/views/test_sms.py | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 tests/app/main/views/test_jobs.py create mode 100644 tests/app/main/views/test_sms.py diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 0d7e5b528..deeb92ed0 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -40,7 +40,7 @@ def showjobs(): return render_template('views/jobs.html') -@main.route("/jobs/job/") +@main.route("/jobs/job") def showjob(): return render_template( 'views/job.html', diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py new file mode 100644 index 000000000..68cd7820b --- /dev/null +++ b/tests/app/main/views/test_jobs.py @@ -0,0 +1,20 @@ +def test_should_return_list_of_all_jobs(notifications_admin): + response = notifications_admin.test_client().get('/jobs') + + assert response.status_code == 200 + assert 'This page will be where we show the list of jobs that this service has processed' in response.get_data(as_text=True) # noqa + + +def test_should_show_page_for_one_job(notifications_admin): + response = notifications_admin.test_client().get('/jobs/job') + + assert response.status_code == 200 + assert 'contact-demo.csv sent with Reminder template' in response.get_data(as_text=True) + + +def test_should_show_page_for_one_notification(notifications_admin): + response = notifications_admin.test_client().get('/jobs/job/notification/3') + + assert response.status_code == 200 + assert 'Text message' in response.get_data(as_text=True) + assert '+44 7700 900 522' in response.get_data(as_text=True) diff --git a/tests/app/main/views/test_sms.py b/tests/app/main/views/test_sms.py new file mode 100644 index 000000000..092d1c03d --- /dev/null +++ b/tests/app/main/views/test_sms.py @@ -0,0 +1,27 @@ +def test_should_return_sms_template_picker(notifications_admin): + response = notifications_admin.test_client().get('/sms/send') + + assert response.status_code == 200 + assert 'Choose text message template' in response.get_data(as_text=True) + + +def test_should_redirect_to_sms_check_page(notifications_admin): + response = notifications_admin.test_client().post('/sms/send') + + assert response.status_code == 302 + assert response.location == 'http://localhost/sms/check' + + +def test_should_return_check_sms_page(notifications_admin): + response = notifications_admin.test_client().get('/sms/check') + + assert response.status_code == 200 + assert 'Check and confirm' in response.get_data(as_text=True) + assert 'Send 10 text messages' in response.get_data(as_text=True) + + +def test_should_redirect_to_job(notifications_admin): + response = notifications_admin.test_client().post('/sms/check') + + assert response.status_code == 302 + assert response.location == 'http://localhost/jobs/job'