Holger Frey
7 years ago
11 changed files with 112 additions and 27 deletions
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
{% extends "ordr:templates/layout.jinja2" %} |
||||
|
||||
{% block content %} |
||||
<div class="content"> |
||||
<h1>FAQ</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> |
||||
{% endblock content %} |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
''' functional tests for ordr2 ''' |
||||
|
||||
import pytest |
||||
import transaction |
||||
import webtest |
||||
|
||||
from .. import APP_SETTINGS |
||||
|
||||
WEBTEST_SETTINGS = APP_SETTINGS.copy() |
||||
# WEBTEST_SETTINGS['pyramid.includes'].append('pyramid_mailer.testing') |
||||
|
||||
|
||||
class CustomTestApp(webtest.TestApp): |
||||
''' might add custom functionality to webtest.TestApp ''' |
||||
pass |
||||
|
||||
|
||||
|
||||
@pytest.fixture(scope='module') |
||||
def testapp(): |
||||
''' fixture for using webtest ''' |
||||
from ordr.models.meta import Base |
||||
from ordr.models import get_tm_session |
||||
from ordr import main |
||||
|
||||
app = main({}, **WEBTEST_SETTINGS) |
||||
testapp = CustomTestApp(app) |
||||
|
||||
session_factory = app.registry['dbsession_factory'] |
||||
engine = session_factory.kw['bind'] |
||||
Base.metadata.create_all(engine) |
||||
|
||||
with transaction.manager: |
||||
# set up test data here |
||||
dbsession = get_tm_session(session_factory, transaction.manager) |
||||
# create_users(dbsession) |
||||
|
||||
yield testapp |
||||
|
||||
Base.metadata.drop_all(engine) |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
''' functional tests for ordr2.views.errors ''' |
||||
|
||||
from . import testapp |
||||
|
||||
|
||||
def test_404(testapp): |
||||
result = testapp.get('/unknown', status=404) |
||||
assert '404' in result |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
''' functional tests for ordr2.views.pages ''' |
||||
|
||||
from . import testapp |
||||
|
||||
|
||||
def test_welcome(testapp): |
||||
result = testapp.get('/') |
||||
assert 'Ordr' in result |
||||
|
||||
|
||||
def test_faq(testapp): |
||||
result = testapp.get('/faq') |
||||
assert 'FAQ' in result |
@ -0,0 +1,8 @@
@@ -0,0 +1,8 @@
|
||||
from pyramid.testing import DummyRequest |
||||
|
||||
def test_welcome(): |
||||
from ordr.views.errors import notfound_view |
||||
request = DummyRequest() |
||||
result = notfound_view(None, request) |
||||
assert result == {} |
||||
assert request.response.status == '404 Not Found' |
@ -0,0 +1,14 @@
@@ -0,0 +1,14 @@
|
||||
|
||||
|
||||
def test_welcome(): |
||||
from ordr.views.pages import welcome |
||||
result = welcome(None, None) |
||||
assert result == {} |
||||
|
||||
|
||||
def test_faq(): |
||||
from ordr.views.pages import faq |
||||
result = faq(None, None) |
||||
assert result == {} |
||||
|
||||
|
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
from pyramid.view import view_config |
||||
|
||||
|
||||
@view_config( |
||||
context='ordr.resources.RootResource', |
||||
permission='view', |
||||
renderer='ordr:templates/pages/welcome.jinja2', |
||||
) |
||||
def welcome(context, request): |
||||
return {} |
||||
|
||||
|
||||
@view_config( |
||||
context='ordr.resources.RootResource', |
||||
name='faq', |
||||
permission='view', |
||||
renderer='ordr:templates/pages/faq.jinja2' |
||||
) |
||||
def faq(context, request): |
||||
return {} |
@ -1,14 +0,0 @@
@@ -1,14 +0,0 @@
|
||||
from pyramid.response import Response |
||||
from pyramid.view import view_config |
||||
|
||||
from sqlalchemy.exc import DBAPIError |
||||
|
||||
from ..models import MyModel |
||||
|
||||
|
||||
@view_config( |
||||
context='ordr.resources.RootResource', |
||||
renderer='ordr:templates/pages/welcome.jinja2' |
||||
) |
||||
def home(context, request): |
||||
return {} |
Reference in new issue