Holger Frey
7 years ago
6 changed files with 146 additions and 13 deletions
@ -1,8 +1,35 @@
@@ -1,8 +1,35 @@
|
||||
{% extends "ordr:templates/layout.jinja2" %} |
||||
|
||||
{% block content %} |
||||
<div class="content"> |
||||
<h1>Ordr</h1> |
||||
<p class="lead">Welcome to <span class="font-normal">Ordr</span>, a Pyramid application generated by<br><span class="font-normal">Cookiecutter</span>.</p> |
||||
<div class="row mt-5"> |
||||
<div class="col-8 offset-2"> |
||||
<div class="jumbotron"> |
||||
<h1 class="display-4">Welcome to <span class="text-primary">ordr</span>!</h1> |
||||
<p class="lead">An order management system to simplify your shopping for laborartory supplies.</p> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<div class="row"> |
||||
<div class="col-4 offset-2"> |
||||
<h4 class="mb-4">Login</h4> |
||||
<form action="/login" method="POST"> |
||||
<div class="form-group"> |
||||
<input type="text" class="form-control" id="input-username" placeholder="Username" name="username" autofocus="autofocus"> |
||||
</div> |
||||
<div class="form-group"> |
||||
<input type="text" class="form-control" id="input-password" placeholder="Password" name="password"> |
||||
</div> |
||||
<button type="submit" class="btn btn-primary">Login</button> |
||||
<small class="float-right mt-2"><a href="/forgot">Forgot your password?</a></small> |
||||
</form> |
||||
</div> |
||||
<div class="col-4"> |
||||
<h4 class="mb-4">Register</h4> |
||||
<p> |
||||
Registration is easy as 1-2-3. |
||||
Just fill out the <a href="/register">form</a> and as soon as your |
||||
account has been activated you can start shopping. |
||||
</p> |
||||
</div> |
||||
</div> |
||||
{% endblock content %} |
||||
|
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
''' 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 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 |
Reference in new issue