diff --git a/ordr/resources/__init__.py b/ordr/resources/__init__.py index 4c38897..5c3cec2 100644 --- a/ordr/resources/__init__.py +++ b/ordr/resources/__init__.py @@ -28,6 +28,5 @@ def includeme(config): Initialize the resources for traversal in a Pyramid app. Activate this setup using ``config.include('ordr2.resources')``. - ''' config.set_root_factory(RootResource) diff --git a/ordr/templates/pages/faq.jinja2 b/ordr/templates/pages/faq.jinja2 new file mode 100644 index 0000000..ab45df4 --- /dev/null +++ b/ordr/templates/pages/faq.jinja2 @@ -0,0 +1,8 @@ +{% extends "ordr:templates/layout.jinja2" %} + +{% block content %} +
+

FAQ

+

Welcome to Ordr, a Pyramid application generated by
Cookiecutter.

+
+{% endblock content %} diff --git a/ordr/templates/pages/welcome.jinja2 b/ordr/templates/pages/welcome.jinja2 index 4103636..f5bc451 100644 --- a/ordr/templates/pages/welcome.jinja2 +++ b/ordr/templates/pages/welcome.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy project

+

Ordr

Welcome to Ordr, a Pyramid application generated by
Cookiecutter.

{% endblock content %} diff --git a/ordr/tests/__init__.py b/ordr/tests/__init__.py index 41a4dd6..034e14a 100644 --- a/ordr/tests/__init__.py +++ b/ordr/tests/__init__.py @@ -38,14 +38,3 @@ def dbsession(app_config): transaction.abort() Base.metadata.drop_all(engine) - - -def test_passing_view(dbsession): - from ordr.views.default import my_view - from ordr.models import MyModel - model = MyModel(name='one', value=55) - dbsession.add(model) - info = my_view(None, testing.DummyRequest(dbsession=dbsession)) - assert info['one'].name == 'one' - assert info['project'] == 'Ordr' - diff --git a/ordr/tests/_functional/__init__.py b/ordr/tests/_functional/__init__.py new file mode 100644 index 0000000..4866f56 --- /dev/null +++ b/ordr/tests/_functional/__init__.py @@ -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) diff --git a/ordr/tests/_functional/errors.py b/ordr/tests/_functional/errors.py new file mode 100644 index 0000000..aa11657 --- /dev/null +++ b/ordr/tests/_functional/errors.py @@ -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 diff --git a/ordr/tests/_functional/pages.py b/ordr/tests/_functional/pages.py new file mode 100644 index 0000000..99b86fc --- /dev/null +++ b/ordr/tests/_functional/pages.py @@ -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 diff --git a/ordr/tests/views/errors.py b/ordr/tests/views/errors.py new file mode 100644 index 0000000..93a5c92 --- /dev/null +++ b/ordr/tests/views/errors.py @@ -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' diff --git a/ordr/tests/views/pages.py b/ordr/tests/views/pages.py new file mode 100644 index 0000000..862061b --- /dev/null +++ b/ordr/tests/views/pages.py @@ -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 == {} + + diff --git a/ordr/views/pages.py b/ordr/views/pages.py new file mode 100644 index 0000000..e64237d --- /dev/null +++ b/ordr/views/pages.py @@ -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 {} diff --git a/ordr/views/public.py b/ordr/views/public.py deleted file mode 100644 index c43d99c..0000000 --- a/ordr/views/public.py +++ /dev/null @@ -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 {}