From 21e33b3a3de650124b7823692771bce82ce43624 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Wed, 18 Oct 2017 15:11:18 +0200 Subject: [PATCH] split functional tests for accounts in two modules --- .../{account.py => login-logout.py} | 18 ---------- tests/_functional/registration.py | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 18 deletions(-) rename tests/_functional/{account.py => login-logout.py} (86%) create mode 100644 tests/_functional/registration.py diff --git a/tests/_functional/account.py b/tests/_functional/login-logout.py similarity index 86% rename from tests/_functional/account.py rename to tests/_functional/login-logout.py index 7c7788b..09c5ff2 100644 --- a/tests/_functional/account.py +++ b/tests/_functional/login-logout.py @@ -23,24 +23,6 @@ def assert_user_login_failed(response, username): assert 'You entered the wrong username or password' in response -# test for account registration - -def test_account_register_unauthenticated(testapp): - ''' test the registration page for a unauthenticated user ''' - testapp.reset() - - response = testapp.get('/account/register') - - # basic content test - assert 'Ordr | Account Registration' in response - # test the main nav section links and highlighting - li_one, li_two = response.html.find_all('li', class_='nav-item') - assert 'active' not in li_one['class'] - assert li_one.find('a').text == 'FAQs' - assert 'active' in li_two['class'] - assert li_two.find('a').text == 'Register' - - # tests for login and logout of users def test_account_login_only_by_post(testapp): diff --git a/tests/_functional/registration.py b/tests/_functional/registration.py new file mode 100644 index 0000000..d2d7555 --- /dev/null +++ b/tests/_functional/registration.py @@ -0,0 +1,33 @@ +''' tests for the login, logout, registration and account settings''' + +import pytest + +from . import testapp +from .. import get_user + + +def test_account_register_authenticated_users(testapp): + ''' registration page should not be accessible for authenticated users ''' + testapp.reset() + + testapp.login('user') + response = testapp.get('/account/register', status=403) + + assert response.status.startswith('403') + + +def test_account_register_unauthenticated(testapp): + ''' test the registration page for a unauthenticated user ''' + testapp.reset() + + response = testapp.get('/account/register') + + # basic content test + assert 'Ordr | Account Registration' in response + # test the main nav section links and highlighting + li_one, li_two = response.html.find_all('li', class_='nav-item') + assert 'active' not in li_one['class'] + assert li_one.find('a').text == 'FAQs' + assert 'active' in li_two['class'] + assert li_two.find('a').text == 'Register' +