You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.2 KiB
80 lines
2.2 KiB
''' tests for the common layout and simple (static)''' |
|
|
|
from . import testapp |
|
|
|
|
|
# tests for layout template |
|
|
|
def test_layout_unauthenticated_user(testapp): |
|
''' test the layout template elements for unauthenticated users |
|
|
|
The '/faq' path is used; '/' will redirect on authenticated users |
|
''' |
|
testapp.reset() |
|
|
|
response = testapp.get('/faq') |
|
|
|
assert '<!-- No logged in user -->' in response |
|
assert 'id="login-form' in response |
|
|
|
|
|
def test_layout_authenticated_user(testapp): |
|
''' test the layout template elements for unauthenticated users |
|
|
|
The '/faq' path is used; '/' will redirect on authenticated users |
|
''' |
|
testapp.reset() |
|
testapp.login('user') |
|
|
|
response = testapp.get('/faq') |
|
|
|
assert '<!-- user is logged in -->' in response |
|
assert 'id="login-form"' not in response |
|
assert 'Admin</a></li>' not in response |
|
assert 'Logged in as <span>TerryGilliam</span>' in response |
|
|
|
|
|
def test_layout_authenticated_admin(testapp): |
|
''' test the layout template elements for unauthenticated users |
|
|
|
The '/faq' path is used; '/' will redirect on authenticated users |
|
''' |
|
testapp.reset() |
|
testapp.login('admin') |
|
|
|
response = testapp.get('/faq') |
|
|
|
assert '<!-- user is logged in -->' in response |
|
assert 'id="login-form"' not in response |
|
assert 'Admin</a></li>' in response |
|
assert 'Logged in as <span>TerryJones</span>' in response |
|
|
|
|
|
# tests for simple pages |
|
|
|
def test_page_welcome_unauthenticated(testapp): |
|
''' test the welcome page for a unauthenticated user ''' |
|
testapp.reset() |
|
|
|
response = testapp.get('/') |
|
|
|
# basic content test |
|
assert 'Ordr | Welcome' in response |
|
# test that no sections are highlightet |
|
assert '<li class="nav-item active">' not in response |
|
|
|
|
|
def test_faq_unauthenticated(testapp): |
|
''' test the faq page for a unauthenticated user ''' |
|
testapp.reset() |
|
|
|
response = testapp.get('/faq') |
|
|
|
# basic content test |
|
assert 'Ordr | FAQ' in response |
|
# test the main nav section links and highlighting |
|
li_one, li_two = response.html.find_all('li', class_='nav-item') |
|
assert 'active' in li_one['class'] |
|
assert li_one.find('a').text == 'FAQs' |
|
assert 'active' not in li_two['class'] |
|
assert li_two.find('a').text == 'Register'
|
|
|