From 79c15ec9cfe956e7939a8b62ee1f04d9c1630a7f Mon Sep 17 00:00:00 2001 From: Nicholas Staples Date: Wed, 6 Jan 2016 16:51:35 +0000 Subject: [PATCH] Code checks and all tests passing. --- app/main/views/sign_out.py | 1 - tests/app/main/views/test_dashboard.py | 21 ++++++++++++++++----- tests/conftest.py | 5 +++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/main/views/sign_out.py b/app/main/views/sign_out.py index 8f7b97cf4..0466d0af9 100644 --- a/app/main/views/sign_out.py +++ b/app/main/views/sign_out.py @@ -10,4 +10,3 @@ from app.main import main def sign_out(): logout_user() return redirect(url_for('main.render_sign_in')) - diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 2b134b39d..d32002ccf 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -1,6 +1,17 @@ -def test_should_show_recent_jobs_on_dashboard(notifications_admin): - response = notifications_admin.test_client().get('/dashboard') +from tests.app.main import create_test_user +from flask import url_for - assert response.status_code == 200 - assert 'Test message 1' in response.get_data(as_text=True) - assert 'Asdfgg' in response.get_data(as_text=True) + +def test_should_show_recent_jobs_on_dashboard(notifications_admin, + notifications_admin_db, + notify_db_session): + with notifications_admin.test_request_context(): + with notifications_admin.test_client() as client: + with client.session_transaction() as session: + user = create_test_user('active') + client.login(user) + response = client.get(url_for('main.dashboard')) + + assert response.status_code == 200 + assert 'Test message 1' in response.get_data(as_text=True) + assert 'Asdfgg' in response.get_data(as_text=True) diff --git a/tests/conftest.py b/tests/conftest.py index cd7d3cd09..a98083297 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,14 +13,15 @@ from app.main.dao import verify_codes_dao from app import create_app, db + class TestClient(FlaskClient): def login(self, user): # Skipping authentication here and just log them in with self.session_transaction() as session: session['user_id'] = user.id verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='sms') - response = self.post('/two-factor', - data={'sms_code': '12345'}) + response = self.post( + url_for('main.process_two_factor'), data={'sms_code': '12345'}) def logout(self, user): self.get(url_for("main.logout"))