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.
 
 
 
 
 

65 lines
1.8 KiB

''' functional tests for ordr2.views.pages '''
import pytest
from . import testappsetup, testapp # noqa: F401
def test_login_get(testapp): # noqa: F811
''' test the login form '''
response = testapp.get('/account/login')
active = response.html.find('li', class_='active')
form = response.form
assert active.a['href'] == 'http://localhost/'
assert form.action == 'http://localhost/account/login'
def test_login_ok(testapp): # noqa: F811
''' test login form with valid credentials '''
response = testapp.get('/account/login')
login_form = response.forms[0]
login_form['username'] = 'TerryGilliam'
login_form['password'] = 'Terry'
response = login_form.submit()
assert response.location == 'http://localhost/'
response = testapp.get('/faq')
assert 'TerryGilliam' in response
@pytest.mark.parametrize( # noqa: F811
'username,password',
[('John', 'Cleese'), ('unknown user', 'wrong password')]
)
def test_login_denied(testapp, username, password):
''' test login form with invalid credentials '''
response = testapp.get('/account/login')
login_form = response.forms[0]
login_form['username'] = 'John'
login_form['password'] = 'Cleese'
response = login_form.submit()
assert 'account is not activated' in response
def test_logout(testapp): # noqa: F811
''' test login form with valid credentials '''
response = testapp.get('/account/login')
login_form = response.forms[0]
login_form['username'] = 'TerryGilliam'
login_form['password'] = 'Terry'
login_form.submit()
response = testapp.get('/faq')
assert 'TerryGilliam' in response
response = testapp.get('/account/logout')
assert response.location == 'http://localhost/'
response = testapp.get('/faq')
assert 'TerryGilliam' not in response