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.
 
 
 
 
 

38 lines
1.3 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
result = testapp.get('/faq')
navbar = result.html.find('nav', class_='navbar-dark')
expected = ['/', '/', '/faq', '/register']
hrefs = [a['href'] for a in navbar.find_all('a')]
assert expected == hrefs
assert '/orders' not in result
assert 'nav-item dropdown' not in result
@pytest.mark.xfail # noqa: F811
@pytest.mark.parametrize(
'username,password,expected', [
('user', 'password', ['/', '/orders', '/logout', '/account']),
('purchaser', 'password', ['/', '/orders', '/logout', '/account']),
('admin', 'password', [
'/', '/orders', '/admin', '/logout', '/account'
]),
]
)
def test_navbar_with_user(testapp, username, password, expected):
testapp.login(username, password)
result = testapp.get('/faq')
navbar = result.html.find('nav', class_='navbar-dark')
hrefs = [a['href'] for a in navbar.find_all('a')]
assert expected == hrefs
assert 'nav-item dropdown' in result