CPI Ordering System (the old version)
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

58 lines
1.8 KiB

''' functional tests for ordr2.templates.layout
The tests for the layout are performed on '/faqs' or '/orders', since these
two urls are accessible by either everyone or all active users
'''
import pytest
from . import testappsetup, testapp # noqa: F401
def test_navbar_no_user(testapp): # noqa: F811
''' test the navigation on top of the page for an unauthenticated user '''
response = testapp.get('/faq')
navbar = response.html.find('nav', class_='navbar-dark')
expected = [
'http://localhost/',
'http://localhost/',
'http://localhost/faq',
'http://localhost/account/register'
]
hrefs = [a['href'] for a in navbar.find_all('a')]
assert expected == hrefs
assert '/orders' not in response
assert 'nav-item dropdown' not in response
7 years ago
@pytest.mark.parametrize( # noqa: F811
'username,password,extras', [
('TerryGilliam', 'Terry', []),
('EricIdle', 'Eric', []),
('TerryJones', 'Terry', ['http://localhost/admin']),
]
)
7 years ago
def test_navbar_with_user(testapp, username, password, extras):
''' test the navigation on top of the page for an authenticated user '''
testapp.login(username, password)
response = testapp.get('/faq')
navbar = response.html.find('nav', class_='navbar-dark')
hrefs = [a['href'] for a in navbar.find_all('a')]
expected = [
'http://localhost/',
'http://localhost/orders',
'http://localhost/faq'
]
7 years ago
expected.extend(extras)
expected.extend([
'#',
'http://localhost/account/logout',
'http://localhost/account/settings',
'http://localhost/account/password'
])
assert expected == hrefs
assert 'nav-item dropdown' in response
assert username in response