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.
50 lines
1.4 KiB
50 lines
1.4 KiB
''' functional tests for ordr2.views.pages ''' |
|
|
|
import pytest |
|
|
|
from . import testappsetup, testapp # noqa: F401 |
|
|
|
|
|
def test_login_get(testapp): # noqa: F811 |
|
response = testapp.get('/login') |
|
active = response.html.find('li', class_='active') |
|
assert active.a['href'] == '/' |
|
|
|
expected = {'/', '/faq', '/register', '/forgot', '/register'} |
|
hrefs = {a['href'] for a in response.html.find_all('a')} |
|
assert expected == hrefs |
|
|
|
forms = response.html.find_all('form') |
|
assert len(forms) == 1 |
|
|
|
login_form = forms[0] |
|
assert login_form['action'] == '/login' |
|
assert login_form['method'] == 'POST' |
|
|
|
assert 'account is not activated' not in response |
|
|
|
|
|
def test_login_ok(testapp): # noqa: F811 |
|
response = testapp.get('/login') |
|
|
|
login_form = response.forms[0] |
|
login_form['username'] = 'TerryGilliam' |
|
login_form['password'] = 'Terry' |
|
response = login_form.submit() |
|
|
|
assert response.location == 'http://localhost/' |
|
|
|
|
|
@pytest.mark.parametrize( # noqa: F811 |
|
'username,password', |
|
[('John', 'Cleese'), ('unknown user', 'wrong password')] |
|
) |
|
def test_login_denied(testapp, username, password): |
|
response = testapp.get('/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
|
|
|