From 94fd8de4263dc6294aa62425a5f98d905ef0584a Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 25 Dec 2019 03:35:14 -0800 Subject: Update quick_tour with cookiecutter master branch --- docs/quick_tour.rst | 22 ++++++++++++++++++---- docs/quick_tour/logging/pytest.ini | 2 +- docs/quick_tour/package/pytest.ini | 2 +- docs/quick_tour/sessions/pytest.ini | 2 +- docs/quick_tour/sqla_demo/development.ini | 7 ++++++- docs/quick_tour/sqla_demo/production.ini | 7 ++++++- docs/quick_tour/sqla_demo/setup.py | 10 +++++----- docs/quick_tour/sqla_demo/sqla_demo/__init__.py | 2 +- .../sqla_demo/sqla_demo/alembic/script.py.mako | 2 -- .../sqla_demo/alembic/versions/README.txt | 2 +- docs/quick_tour/sqla_demo/sqla_demo/pshell.py | 1 + .../sqla_demo/sqla_demo/templates/404.jinja2 | 2 +- .../sqla_demo/sqla_demo/templates/layout.jinja2 | 2 +- .../sqla_demo/templates/mytemplate.jinja2 | 4 ++-- docs/quick_tour/sqla_demo/sqla_demo/tests.py | 3 ++- .../sqla_demo/sqla_demo/views/default.py | 4 ++-- 16 files changed, 49 insertions(+), 25 deletions(-) (limited to 'docs') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index a428a77c3..e6914337f 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -493,7 +493,8 @@ So far we have done all of our *Quick Tour* as a single Python file. No Python packages, no structure. Most Pyramid projects, though, aren't developed this way. -To ease the process of getting started, the Pylons Project provides a :term:`cookiecutter` that generates sample Pyramid projects from project templates. This cookiecutter will install Pyramid and its dependencies as well. +To ease the process of getting started, the Pylons Project provides a :term:`cookiecutter` that generates a sample Pyramid project from project templates. +This cookiecutter will install Pyramid and its dependencies as well. First you'll need to install cookiecutter. @@ -894,9 +895,22 @@ We then run through the following commands as before. # Reset our environment variable for a new virtual environment. export VENV=~/sqla_demo/env -We now have a working sample SQLAlchemy application with all dependencies -installed. The sample project provides a console script to initialize a SQLite -database with tables. Let's run it, then start the application: +We now have a working sample SQLAlchemy application with all dependencies installed. +The sample project provides a method to generate a database migration from existing models and upgrade the database schema using Alembic. +Let's generate the first revision. + +.. code-block:: bash + + $VENV/bin/alembic -c development.ini revision --autogenerate -m "init" + +Now let's upgrade the database schema. + +.. code-block:: bash + + $VENV/bin/alembic -c development.ini upgrade head + +The sample project also provides a console script to load data into the SQLite database. +Let's run it, then start the application: .. code-block:: bash diff --git a/docs/quick_tour/logging/pytest.ini b/docs/quick_tour/logging/pytest.ini index f707d54e4..b419855e1 100644 --- a/docs/quick_tour/logging/pytest.ini +++ b/docs/quick_tour/logging/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = hello_world -python_files = *.py +python_files = test*.py diff --git a/docs/quick_tour/package/pytest.ini b/docs/quick_tour/package/pytest.ini index f707d54e4..b419855e1 100644 --- a/docs/quick_tour/package/pytest.ini +++ b/docs/quick_tour/package/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = hello_world -python_files = *.py +python_files = test*.py diff --git a/docs/quick_tour/sessions/pytest.ini b/docs/quick_tour/sessions/pytest.ini index f707d54e4..b419855e1 100644 --- a/docs/quick_tour/sessions/pytest.ini +++ b/docs/quick_tour/sessions/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = hello_world -python_files = *.py +python_files = test*.py diff --git a/docs/quick_tour/sqla_demo/development.ini b/docs/quick_tour/sqla_demo/development.ini index 056a672e4..a087e17a7 100644 --- a/docs/quick_tour/sqla_demo/development.ini +++ b/docs/quick_tour/sqla_demo/development.ini @@ -45,7 +45,7 @@ listen = localhost:6543 ### [loggers] -keys = root, sqla_demo, sqlalchemy +keys = root, sqla_demo, sqlalchemy, alembic [handlers] keys = console @@ -70,6 +70,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/quick_tour/sqla_demo/production.ini b/docs/quick_tour/sqla_demo/production.ini index fe7f946bd..ee588605d 100644 --- a/docs/quick_tour/sqla_demo/production.ini +++ b/docs/quick_tour/sqla_demo/production.ini @@ -39,7 +39,7 @@ listen = *:6543 ### [loggers] -keys = root, sqla_demo, sqlalchemy +keys = root, sqla_demo, sqlalchemy, alembic [handlers] keys = console @@ -64,6 +64,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/quick_tour/sqla_demo/setup.py b/docs/quick_tour/sqla_demo/setup.py index 28a8e0815..23740ba9f 100644 --- a/docs/quick_tour/sqla_demo/setup.py +++ b/docs/quick_tour/sqla_demo/setup.py @@ -9,17 +9,17 @@ with open(os.path.join(here, 'CHANGES.txt')) as f: CHANGES = f.read() requires = [ - 'alembic', 'plaster_pastedeploy', - 'pyramid >= 1.9', - 'pyramid_debugtoolbar', + 'pyramid', 'pyramid_jinja2', + 'pyramid_debugtoolbar', + 'waitress', + 'alembic', 'pyramid_retry', 'pyramid_tm', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', - 'waitress', ] tests_require = [ @@ -55,7 +55,7 @@ setup( 'main = sqla_demo:main', ], 'console_scripts': [ - 'initialize_sqla_demo_db = sqla_demo.scripts.initialize_db:main', + 'initialize_sqla_demo_db=sqla_demo.scripts.initialize_db:main', ], }, ) diff --git a/docs/quick_tour/sqla_demo/sqla_demo/__init__.py b/docs/quick_tour/sqla_demo/sqla_demo/__init__.py index 28bd1f80d..5c2ba5cc0 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/__init__.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.scan() return config.make_wsgi_app() diff --git a/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako b/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako +++ b/docs/quick_tour/sqla_demo/sqla_demo/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt b/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt +++ b/docs/quick_tour/sqla_demo/sqla_demo/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/quick_tour/sqla_demo/sqla_demo/pshell.py b/docs/quick_tour/sqla_demo/sqla_demo/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/pshell.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 index 1917f83c7..aaf12413f 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 +++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy scaffold

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 index 107691acf..82017688a 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 +++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/layout.jinja2 @@ -8,7 +8,7 @@ - Cookiecutter Alchemy project for the Pyramid Web Framework + Cookiecutter Starter project for the Pyramid Web Framework diff --git a/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 b/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 index d8b0a4232..f2e7283f8 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 +++ b/docs/quick_tour/sqla_demo/sqla_demo/templates/mytemplate.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy project

+

Pyramid Starter project

Welcome to {{project}}, a Pyramid application generated by
Cookiecutter.

-{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/tests.py b/docs/quick_tour/sqla_demo/sqla_demo/tests.py index 6db538ffd..df9b58780 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/tests.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py index f7ad4c8f2..a6b05c558 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py @@ -1,5 +1,5 @@ -from pyramid.response import Response from pyramid.view import view_config +from pyramid.response import Response from sqlalchemy.exc import DBAPIError @@ -21,7 +21,7 @@ Pyramid is having a problem using your SQL database. The problem might be caused by one of the following things: 1. You may need to initialize your database tables with `alembic`. - Check your README.txt for description and try to run it. + Check your README.txt for descriptions and try to run it. 2. Your database server may not be running. Check that the database server referred to by the "sqlalchemy.url" setting in -- cgit v1.2.3 From c86c61bfbab809d55b8d1a53e4a2b47505317720 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 25 Dec 2019 23:45:57 -0800 Subject: Use package name instead of relative path for the renderer --- docs/quick_tour/logging/hello_world/views/default.py | 2 +- docs/quick_tour/logging/hello_world/views/notfound.py | 2 +- docs/quick_tour/package/hello_world/views/default.py | 2 +- docs/quick_tour/package/hello_world/views/notfound.py | 2 +- docs/quick_tour/sessions/hello_world/views/default.py | 2 +- docs/quick_tour/sessions/hello_world/views/notfound.py | 2 +- docs/quick_tour/sqla_demo/sqla_demo/views/default.py | 2 +- docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'docs') diff --git a/docs/quick_tour/logging/hello_world/views/default.py b/docs/quick_tour/logging/hello_world/views/default.py index bbb99d78c..4bbc01e11 100644 --- a/docs/quick_tour/logging/hello_world/views/default.py +++ b/docs/quick_tour/logging/hello_world/views/default.py @@ -3,7 +3,7 @@ from pyramid.view import view_config import logging log = logging.getLogger(__name__) -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='hello_world:templates/mytemplate.jinja2') def my_view(request): log.debug('Some Message') return {'project': 'hello_world'} diff --git a/docs/quick_tour/logging/hello_world/views/notfound.py b/docs/quick_tour/logging/hello_world/views/notfound.py index 69d6e2804..6d0ff4193 100644 --- a/docs/quick_tour/logging/hello_world/views/notfound.py +++ b/docs/quick_tour/logging/hello_world/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='hello_world:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/package/hello_world/views/default.py b/docs/quick_tour/package/hello_world/views/default.py index 7458da006..000a66e2e 100644 --- a/docs/quick_tour/package/hello_world/views/default.py +++ b/docs/quick_tour/package/hello_world/views/default.py @@ -1,6 +1,6 @@ from pyramid.view import view_config -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='hello_world:templates/mytemplate.jinja2') def my_view(request): return {'project': 'hello_world'} diff --git a/docs/quick_tour/package/hello_world/views/notfound.py b/docs/quick_tour/package/hello_world/views/notfound.py index 69d6e2804..6d0ff4193 100644 --- a/docs/quick_tour/package/hello_world/views/notfound.py +++ b/docs/quick_tour/package/hello_world/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='hello_world:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/sessions/hello_world/views/default.py b/docs/quick_tour/sessions/hello_world/views/default.py index 33b8d8ded..52e002cf5 100644 --- a/docs/quick_tour/sessions/hello_world/views/default.py +++ b/docs/quick_tour/sessions/hello_world/views/default.py @@ -3,7 +3,7 @@ from pyramid.view import view_config import logging log = logging.getLogger(__name__) -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='hello_world:templates/mytemplate.jinja2') def my_view(request): log.debug('Some Message') session = request.session diff --git a/docs/quick_tour/sessions/hello_world/views/notfound.py b/docs/quick_tour/sessions/hello_world/views/notfound.py index 69d6e2804..6d0ff4193 100644 --- a/docs/quick_tour/sessions/hello_world/views/notfound.py +++ b/docs/quick_tour/sessions/hello_world/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='hello_world:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py index a6b05c558..3aadb905f 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/views/default.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/views/default.py @@ -6,7 +6,7 @@ from sqlalchemy.exc import DBAPIError from .. import models -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='sqla_demo:templates/mytemplate.jinja2') def my_view(request): try: query = request.dbsession.query(models.MyModel) diff --git a/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py b/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py index 69d6e2804..3e088ab15 100644 --- a/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py +++ b/docs/quick_tour/sqla_demo/sqla_demo/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='sqla_demo:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From f61a292939d2a41598f45fc8f908343eb8859e23 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 02:47:04 -0800 Subject: Update tests.py with 100% coverage --- docs/quick_tour/logging/hello_world/tests.py | 10 ++++++++++ docs/quick_tour/package/hello_world/tests.py | 10 ++++++++++ docs/quick_tour/sessions/hello_world/tests.py | 10 ++++++++++ 3 files changed, 30 insertions(+) (limited to 'docs') diff --git a/docs/quick_tour/logging/hello_world/tests.py b/docs/quick_tour/logging/hello_world/tests.py index f01ae2a3c..b747e7679 100644 --- a/docs/quick_tour/logging/hello_world/tests.py +++ b/docs/quick_tour/logging/hello_world/tests.py @@ -16,6 +16,12 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'hello_world') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/package/hello_world/tests.py b/docs/quick_tour/package/hello_world/tests.py index f01ae2a3c..b747e7679 100644 --- a/docs/quick_tour/package/hello_world/tests.py +++ b/docs/quick_tour/package/hello_world/tests.py @@ -16,6 +16,12 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'hello_world') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sessions/hello_world/tests.py b/docs/quick_tour/sessions/hello_world/tests.py index f01ae2a3c..b747e7679 100644 --- a/docs/quick_tour/sessions/hello_world/tests.py +++ b/docs/quick_tour/sessions/hello_world/tests.py @@ -16,6 +16,12 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'hello_world') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) -- cgit v1.2.3 From 1ca5432b80167f2da57c54e5050b977da9e191ed Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 04:01:17 -0800 Subject: Update project.rst and its cookiecutter project files - Update output to reflect current cookiecutter - Fix minor typos - Use new links to PyPA for MANIFEST.in description and usage - Add missing keyword "keywords" to setup.py whirlwind description - Flip order of `install_requires` and `extras_require` to align with order in setup.py - Update line numbers and code references - Add watchman under hupper and rewrite paragraph @mmerickel should review --- docs/narr/myproject/README.txt | 4 +- docs/narr/myproject/myproject/tests.py | 12 +++- docs/narr/myproject/myproject/views/default.py | 2 +- docs/narr/myproject/myproject/views/notfound.py | 2 +- docs/narr/myproject/pytest.ini | 2 +- docs/narr/myproject/setup.py | 2 +- docs/narr/project.rst | 80 +++++++++++++------------ 7 files changed, 58 insertions(+), 46 deletions(-) (limited to 'docs') diff --git a/docs/narr/myproject/README.txt b/docs/narr/myproject/README.txt index 2ffc0acba..6c5a0fee0 100644 --- a/docs/narr/myproject/README.txt +++ b/docs/narr/myproject/README.txt @@ -1,4 +1,4 @@ -MyProject +myproject ========= Getting Started @@ -6,7 +6,7 @@ Getting Started - Change directory into your newly created project. - cd MyProject + cd myproject - Create a Python virtual environment. diff --git a/docs/narr/myproject/myproject/tests.py b/docs/narr/myproject/myproject/tests.py index 05ccadcfb..48f0095ad 100644 --- a/docs/narr/myproject/myproject/tests.py +++ b/docs/narr/myproject/myproject/tests.py @@ -14,7 +14,13 @@ class ViewTests(unittest.TestCase): from .views.default import my_view request = testing.DummyRequest() info = my_view(request) - self.assertEqual(info['project'], 'MyProject') + self.assertEqual(info['project'], 'myproject') + + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) class FunctionalTests(unittest.TestCase): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/narr/myproject/myproject/views/default.py b/docs/narr/myproject/myproject/views/default.py index 8324cfe32..619ce1c0f 100644 --- a/docs/narr/myproject/myproject/views/default.py +++ b/docs/narr/myproject/myproject/views/default.py @@ -1,6 +1,6 @@ from pyramid.view import view_config -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='myproject:templates/mytemplate.jinja2') def my_view(request): return {'project': 'myproject'} diff --git a/docs/narr/myproject/myproject/views/notfound.py b/docs/narr/myproject/myproject/views/notfound.py index 69d6e2804..5abebb277 100644 --- a/docs/narr/myproject/myproject/views/notfound.py +++ b/docs/narr/myproject/myproject/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='myproject:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/narr/myproject/pytest.ini b/docs/narr/myproject/pytest.ini index b1b5f4c38..332cf0d04 100644 --- a/docs/narr/myproject/pytest.ini +++ b/docs/narr/myproject/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = myproject -python_files = *.py +python_files = test*.py diff --git a/docs/narr/myproject/setup.py b/docs/narr/myproject/setup.py index 1ee272270..40aa2c53b 100644 --- a/docs/narr/myproject/setup.py +++ b/docs/narr/myproject/setup.py @@ -25,7 +25,7 @@ tests_require = [ setup( name='myproject', version='0.0', - description='MyProject', + description='myproject', long_description=README + '\n\n' + CHANGES, classifiers=[ 'Programming Language :: Python', diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 58bef5701..480f9b63d 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -117,7 +117,7 @@ On Unix: # Create a new virtual environment... python3 -m venv $VENV # ...where we upgrade packaging tools. - env/bin/pip install --upgrade pip setuptools + $VENV/bin/pip install --upgrade pip setuptools Or on Windows: @@ -208,11 +208,12 @@ Elided output from a run of this command on Unix is shown below: .. code-block:: bash Running setup.py develop for myproject - Successfully installed Jinja2-2.8 Mako-1.0.6 MarkupSafe-0.23 \ - PasteDeploy-1.5.2 Pygments-2.1.3 WebOb-1.7.0 myproject pyramid-1.7.3 \ - pyramid-debugtoolbar-3.0.5 pyramid-jinja2-2.7 pyramid-mako-1.0.2 \ - repoze.lru-0.6 translationstring-1.3 venusian-1.0 waitress-1.0.1 \ - zope.deprecation-4.2.0 zope.interface-4.3.3 + Successfully installed Jinja2-2.10.3 Mako-1.1.0 MarkupSafe-1.1.1 \ + PasteDeploy-2.0.1 Pygments-2.5.2 hupper-1.9.1 myproject plaster-1.0 \ + plaster-pastedeploy-0.7 pyramid-1.10.4 pyramid-debugtoolbar-4.5.1 \ + pyramid-jinja2-2.8 pyramid-mako-1.1.0 repoze.lru-0.7 \ + translationstring-1.3 venusian-3.0.0 waitress-1.4.1 webob-1.8.5 \ + zope.deprecation-4.4.0 zope.interface-4.7.1 This will install a :term:`distribution` representing your project into the virtual environment interpreter's library set so it can be found by ``import`` @@ -263,9 +264,9 @@ Here's sample output from a test run on Unix: $VENV/bin/pytest -q .. - 2 passed in 0.47 seconds + 4 passed in 0.45 seconds -The tests themselves are found in the ``tests.py`` module in your ``cookiecutter``-generated project. Within a project generated by the ``pyramid-cookiecutter-starter`` cookiecutter, only two sample tests exist. +The tests themselves are found in the ``tests.py`` module in your ``cookiecutter``-generated project. Within this project generated by the ``pyramid-cookiecutter-starter`` cookiecutter, only a few sample tests exist. .. note:: @@ -402,8 +403,8 @@ For example, on Unix: .. code-block:: text $VENV/bin/pserve development.ini --reload - Starting subprocess with file monitor - Starting server in PID 16601. + Starting monitor for PID 36224. + Starting server in PID 36224. Serving on http://localhost:6543 Serving on http://localhost:6543 @@ -412,9 +413,10 @@ files, you'll see the server restart automatically: .. code-block:: text - development.ini changed; reloading... - -------------------- Restarting -------------------- - Starting server in PID 16602. + /file-path-to/myproject/development.ini changed; reloading ... + Gracefully killing the server. + Starting monitor for PID 36286. + Starting server in PID 36286. Serving on http://localhost:6543 Serving on http://localhost:6543 @@ -462,7 +464,7 @@ browsing from a system that does not have debugging access. By default, for security reasons, only a browser originating from ``localhost`` (``127.0.0.1``) can see the debug toolbar. To allow your browser on a remote system to access the server, add a line within the ``[app:main]`` section of the -``development.ini`` file in the form ``debugtoolbar.hosts = X .X.X.X``. For +``development.ini`` file in the form ``debugtoolbar.hosts = X.X.X.X``. For example, if your Pyramid application is running on a remote system, and you're browsing from a host with the IP address ``192.168.1.1``, you'd add something like this to enable the toolbar when your system contacts Pyramid: @@ -470,7 +472,7 @@ like this to enable the toolbar when your system contacts Pyramid: .. code-block:: ini [app:main] - # .. other settings ... + # ... other settings ... debugtoolbar.hosts = 192.168.1.1 For more information about what the debug toolbar allows you to do, see the @@ -701,9 +703,8 @@ specifies the non-Python files that should be included when a setup.py sdist``. Due to the information contained in the default ``MANIFEST.in``, an sdist of your Pyramid project will include ``.txt`` files, ``.ini`` files, ``.rst`` files, graphics files, and template files, as well as -``.py`` files. See -https://docs.python.org/2/distutils/sourcedist.html#the-manifest-in-template -for more information about the syntax and usage of ``MANIFEST.in``. +``.py`` files. +See the Python Packaging Authority's Python Packaging User Guide `Including files in source distributions with MANIFEST.in `_ for more information about the syntax and usage of ``MANIFEST.in``. Without the presence of a ``MANIFEST.in`` file or without checking your source code into a version control repository, ``setup.py sdist`` places only *Python @@ -720,9 +721,8 @@ like ``*.pt``, ``*.css`` and ``*.js`` in the generated tarball. If you include files with extensions other than the files named in the project's ``MANIFEST.in`` and you don't make use of a Setuptools-compatible version control system, you'll need to edit the ``MANIFEST.in`` file and include the -statements necessary to include your new files. See -https://docs.python.org/2/distutils/sourcedist.html#principle for more -information about how to do this. +statements necessary to include your new files. +In the aforementioned Python Packaging User Guide, see `MANIFEST.in commands `_ for more information about how to do this. You can also delete ``MANIFEST.in`` from your project and rely on a :term:`Setuptools` feature which simply causes all files checked into a version control system to @@ -775,15 +775,17 @@ together. The ``classifiers`` field is a list of `Trove classifiers `_ describing your application. ``author`` and ``author_email`` are text fields which probably don't need any description. ``url`` is a field that should point at your -application project's URL (if any). ``packages=find_packages()`` causes all +application project's URL (if any). +``keywords`` are keywords that describe your project. +``packages=find_packages()`` causes all packages within the project to be found when packaging the application. ``include_package_data`` will include non-Python files when the application is packaged if those files are checked into version control. ``zip_safe=False`` indicates that this package is not safe to use as a zipped egg; instead it will -always unpack as a directory, which is more convenient. ``install_requires`` -indicates that this package depends on the ``pyramid`` package. -``extras_require`` is a Python dictionary that defines what is required to be -installed for running tests. We examined ``entry_points`` in our discussion of +always unpack as a directory, which is more convenient. +``extras_require`` is a Python dictionary that defines what is required to be installed for running tests. +``install_requires`` indicates that this package depends on the ``pyramid`` package. +We examined ``entry_points`` in our discussion of the ``development.ini`` file; this file defines the ``main`` entry point that represents our project's application. @@ -817,7 +819,7 @@ The ``myproject`` :term:`package` lives inside the ``myproject`` #. A ``templates`` directory, which contains :term:`Jinja2` (or other types of) templates. -#. A ``tests.py`` module, which contains unit test code for the application. +#. A ``tests.py`` module, which contains unit and functional test code for the application. #. A ``routes.py`` module, which contains routing code for the application. @@ -850,7 +852,7 @@ also informs Python that the directory which contains it is a *package*. #. Line 1 imports the :term:`Configurator` class from :mod:`pyramid.config` that we use later. -#. Lines 4-12 define a function named ``main`` that returns a :app:`Pyramid` +#. Lines 4-11 define a function named ``main`` that returns a :app:`Pyramid` WSGI application. This function is meant to be called by the :term:`PasteDeploy` framework as a result of running ``pserve``. @@ -924,11 +926,13 @@ route named ``home`` to the URL pattern ``/``, this route will match when a visitor visits the root URL. The view_config decorator also names a ``renderer``, which in this case is a template that will be used to render the result of the view callable. This particular view declaration points at -``../templates/mytemplate.jinja2``, which is an :term:`asset specification` that +``myproject:templates/mytemplate.jinja2``, which is an :term:`asset specification` that specifies the ``mytemplate.jinja2`` file within the ``templates`` directory of the -``myproject`` package. The asset specification could have also been specified -as ``myproject:templates/mytemplate.jinja2``; the leading package name and colon is -optional. The template file pointed to is a :term:`Jinja2` template +``myproject`` package. +There is a second form of asset specification: a relative asset specification. +Instead of using an "absolute" asset specification which includes the package name, in certain circumstances you can omit the package name from the specification. +For example, you might be able to use ``../templates/mytemplate.jinja2``. +The template file pointed to is a :term:`Jinja2` template file (``templates/mytemplate.jinja2``). This view callable function is handed a single piece of information: the @@ -949,7 +953,7 @@ Now let's look at ``notfound.py``. :linenos: This file is similar to ``default.py``. -It merely returns a ``404`` response status and an empty dictionary to the template at ``../templates/404.jinja2``. +It merely returns a ``404`` response status and an empty dictionary to the template at ``myproject:templates/404.jinja2``. .. note:: When the application is run with the cookiecutter's :ref:`default development.ini ` configuration, :ref:`logging is set up @@ -1048,7 +1052,7 @@ The ``tests.py`` module includes tests for your application. :language: python :linenos: -This sample ``tests.py`` file has one unit test and one functional test defined +This sample ``tests.py`` file has two unit tests and two functional tests defined within it. These tests are executed when you run ``pytest -q``. You may add more tests here as you build your application. You are not required to write tests to use :app:`Pyramid`. This file is simply provided for convenience and @@ -1159,11 +1163,9 @@ inotify support ~~~~~~~~~~~~~~~ By default ``hupper`` will poll the filesystem for changes to all Python -code. This can be pretty inefficient in larger projects. To be nicer to your -hard drive, you should install the -`watchdog `_ package in development. -``hupper`` will automatically use ``watchdog`` to more efficiently poll the -filesystem. +code. This can be pretty inefficient in larger projects. +To be nicer to your hard drive, you should install either the `watchman `_ or `watchdog `_ package in development. +``hupper`` will use, in order of preference for efficiency, if available, ``watchman``, ``watchdog``, then finally ``inotify`` to poll the filesystem. Monitoring Custom Files ~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.3 From f179c23c705afc20026c26bd02d6ae64b8295935 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 14:39:58 -0800 Subject: Update quick_tutorial/cookiecutters.rst and related files --- docs/quick_tutorial/cookiecutters.rst | 4 ++-- docs/quick_tutorial/cookiecutters/cc_starter/tests.py | 10 ++++++++++ docs/quick_tutorial/cookiecutters/cc_starter/views/default.py | 2 +- docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py | 2 +- docs/quick_tutorial/cookiecutters/pytest.ini | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) (limited to 'docs') diff --git a/docs/quick_tutorial/cookiecutters.rst b/docs/quick_tutorial/cookiecutters.rst index e4a585a33..a1d60c181 100644 --- a/docs/quick_tutorial/cookiecutters.rst +++ b/docs/quick_tutorial/cookiecutters.rst @@ -73,8 +73,8 @@ Steps .. code-block:: text - Starting subprocess with file monitor - Starting server in PID 73732. + Starting monitor for PID 60461. + Starting server in PID 60461. Serving on http://localhost:6543 Serving on http://localhost:6543 diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py index f3886be84..0891a3c51 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py @@ -16,6 +16,12 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'cc_starter') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + class FunctionalTests(unittest.TestCase): def setUp(self): @@ -27,3 +33,7 @@ class FunctionalTests(unittest.TestCase): def test_root(self): res = self.testapp.get('/', status=200) self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py index 47af359b5..21c30e0b2 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/views/default.py @@ -1,6 +1,6 @@ from pyramid.view import view_config -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='cc_starter:templates/mytemplate.jinja2') def my_view(request): return {'project': 'cc_starter'} diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py b/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py index 69d6e2804..e8b8f26f3 100644 --- a/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py +++ b/docs/quick_tutorial/cookiecutters/cc_starter/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='cc_starter:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/quick_tutorial/cookiecutters/pytest.ini b/docs/quick_tutorial/cookiecutters/pytest.ini index a7bd797f0..326c14fbc 100644 --- a/docs/quick_tutorial/cookiecutters/pytest.ini +++ b/docs/quick_tutorial/cookiecutters/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = cc_starter -python_files = *.py +python_files = test*.py -- cgit v1.2.3 From 452487d4c8422b56bbf0f7ce27b919532054d364 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 21:15:25 -0800 Subject: 4 tests require 4 dots --- docs/narr/project.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/narr/project.rst b/docs/narr/project.rst index 480f9b63d..e0f0be1f3 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -263,7 +263,7 @@ Here's sample output from a test run on Unix: .. code-block:: bash $VENV/bin/pytest -q - .. + .... 4 passed in 0.45 seconds The tests themselves are found in the ``tests.py`` module in your ``cookiecutter``-generated project. Within this project generated by the ``pyramid-cookiecutter-starter`` cookiecutter, only a few sample tests exist. -- cgit v1.2.3 From 5157b14655d7ff2b3780715ea38217125dd93003 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 21:26:19 -0800 Subject: Update docs/tutorials/wiki/installation.rst and related files --- docs/tutorials/wiki/installation.rst | 55 +++++++++++----------- .../src/installation/tutorial/templates/layout.pt | 2 +- .../wiki/src/installation/tutorial/tests.py | 6 +++ .../src/installation/tutorial/views/default.py | 2 +- .../src/installation/tutorial/views/notfound.py | 2 +- 5 files changed, 37 insertions(+), 30 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst index cfa021540..7c21ec02c 100644 --- a/docs/tutorials/wiki/installation.rst +++ b/docs/tutorials/wiki/installation.rst @@ -185,18 +185,20 @@ The console will show ``pip`` checking for packages and installing missing packa .. code-block:: bash - Successfully installed BTrees-4.5.1 Chameleon-3.5 Mako-1.0.7 \ - MarkupSafe-1.1.0 PasteDeploy-1.5.2 Pygments-2.2.0 WebTest-2.0.32 \ - ZConfig-3.3.0 ZEO-5.2.0 ZODB-5.5.1 ZODB3-3.11.0 atomicwrites-1.2.1 \ - attrs-18.2.0 beautifulsoup4-4.6.3 coverage-4.5.2 hupper-1.4.1 \ - more-itertools-4.3.0 persistent-4.4.3 plaster-1.0 plaster-pastedeploy-0.6 \ - pluggy-0.8.0 py-1.7.0 pyramid-1.10.1 pyramid-chameleon-0.3 \ - pyramid-debugtoolbar-4.5 pyramid-mako-1.0.2 pyramid-retry-1.0 \ - pyramid-tm-2.2.1 pyramid-zodbconn-0.8.1 pytest-4.0.0 pytest-cov-2.6.0 \ - repoze.lru-0.7 six-1.11.0 transaction-2.4.0 translationstring-1.3 \ - tutorial venusian-1.1.0 waitress-1.1.0 webob-1.8.4 zc.lockfile-1.4 \ - zdaemon-4.3 zodbpickle-1.0.2 zodburi-2.3.0 zope.deprecation-4.3.0 \ - zope.interface-4.6.0 + Successfully installed BTrees-4.6.1 Chameleon-3.6.2 Mako-1.1.0 \ + MarkupSafe-1.1.1 PasteDeploy-2.0.1 Pygments-2.5.2 WebTest-2.0.33 \ + ZConfig-3.5.0 ZEO-5.2.1 ZODB-5.5.1 ZODB3-3.11.0 attrs-19.3.0 \ + beautifulsoup4-4.8.2 cffi-1.13.2 coverage-5.0.1 hupper-1.9.1 \ + importlib-metadata-1.3.0 more-itertools-8.0.2 packaging-19.2 \ + persistent-4.5.1 plaster-1.0 plaster-pastedeploy-0.7 pluggy-0.13.1 \ + py-1.8.1 pycparser-2.19 pyparsing-2.4.6 pyramid-1.10.4 \ + pyramid-chameleon-0.3 pyramid-debugtoolbar-4.5.1 pyramid-mako-1.1.0 \ + pyramid-retry-2.1 pyramid-tm-2.3 pyramid-zodbconn-0.8.1 pytest-5.3.2 \ + pytest-cov-2.8.1 repoze.lru-0.7 six-1.13.0 soupsieve-1.9.5 \ + transaction-3.0.0 translationstring-1.3 tutorial venusian-3.0.0 \ + waitress-1.4.1 wcwidth-0.1.7 webob-1.8.5 zc.lockfile-2.0 zdaemon-4.3 \ + zipp-0.6.0 zodbpickle-2.0.0 zodburi-2.4.0 zope.deprecation-4.4.0 \ + zope.interface-4.7.1 Testing requirements are defined in our project's ``setup.py`` file, in the ``tests_require`` and ``extras_require`` stanzas. @@ -241,8 +243,8 @@ For a successful test run, you should see output that ends like this: .. code-block:: bash - . - 1 passed in 0.24 seconds + .. + 2 passed in 0.49 seconds Expose test coverage information @@ -274,29 +276,28 @@ If successful, you will see output something like this: .. code-block:: bash ======================== test session starts ========================= - platform darwin -- Python 3.7.0, pytest-4.0.0, py-1.7.0, pluggy-0.8.0 - rootdir: /Users/stevepiercy/projects/hack-on-pyramid/tutorial, inifile: pytest.ini - plugins: cov-2.6.0 - collected 1 item + platform darwin -- Python 3.7.3, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 + rootdir: /filepath/tutorial, inifile: pytest.ini, testpaths: tutorial + plugins: cov-2.8.1 + collected 2 items + + tutorial/tests.py .. [100%] - tutorial/tests.py . - [100%] ---------- coverage: platform darwin, python 3.7.0-final-0 ----------- Name Stmts Miss Cover Missing ----------------------------------------------------------- - tutorial/__init__.py 17 12 29% 7-8, 14-23 + tutorial/__init__.py 16 11 31% 7-8, 14-22 tutorial/models/__init__.py 8 4 50% 9-12 tutorial/pshell.py 6 6 0% 1-12 tutorial/routes.py 2 2 0% 1-2 tutorial/views/__init__.py 0 0 100% tutorial/views/default.py 4 0 100% - tutorial/views/notfound.py 4 4 0% 1-7 + tutorial/views/notfound.py 4 0 100% ----------------------------------------------------------- - TOTAL 41 28 32% - + TOTAL 40 23 42% - ===================== 1 passed in 0.31 seconds ======================= + ===================== 2 passed in 0.55 seconds ======================= Our package doesn't quite have 100% test coverage. @@ -365,8 +366,8 @@ If successful, you will see something like this on your console: .. code-block:: text - Starting subprocess with file monitor - Starting server in PID 44078. + Starting monitor for PID 65233. + Starting server in PID 65233. Serving on http://localhost:6543 Serving on http://localhost:6543 diff --git a/docs/tutorials/wiki/src/installation/tutorial/templates/layout.pt b/docs/tutorials/wiki/src/installation/tutorial/templates/layout.pt index 9fdaef00f..9ca01382b 100644 --- a/docs/tutorials/wiki/src/installation/tutorial/templates/layout.pt +++ b/docs/tutorials/wiki/src/installation/tutorial/templates/layout.pt @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/wiki/src/installation/tutorial/tests.py b/docs/tutorials/wiki/src/installation/tutorial/tests.py index 6279d9f66..aa5641cdd 100644 --- a/docs/tutorials/wiki/src/installation/tutorial/tests.py +++ b/docs/tutorials/wiki/src/installation/tutorial/tests.py @@ -16,3 +16,9 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'myproj') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/installation/tutorial/views/default.py b/docs/tutorials/wiki/src/installation/tutorial/views/default.py index 5d708d15c..51ec5ed98 100644 --- a/docs/tutorials/wiki/src/installation/tutorial/views/default.py +++ b/docs/tutorials/wiki/src/installation/tutorial/views/default.py @@ -3,6 +3,6 @@ from pyramid.view import view_config from ..models import MyModel -@view_config(context=MyModel, renderer='../templates/mytemplate.pt') +@view_config(context=MyModel, renderer='tutorial:templates/mytemplate.pt') def my_view(request): return {'project': 'myproj'} diff --git a/docs/tutorials/wiki/src/installation/tutorial/views/notfound.py b/docs/tutorials/wiki/src/installation/tutorial/views/notfound.py index 728791d0a..59a37280e 100644 --- a/docs/tutorials/wiki/src/installation/tutorial/views/notfound.py +++ b/docs/tutorials/wiki/src/installation/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.pt') +@notfound_view_config(renderer='tutorial:templates/404.pt') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 2e73919835c6480b6c5eb57dfb368812d6df9d43 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 27 Dec 2019 22:12:44 -0800 Subject: Update docs/tutorials/wiki/basiclayout.rst and related files --- docs/tutorials/wiki/basiclayout.rst | 18 ++++++++++++------ .../wiki/src/basiclayout/tutorial/templates/layout.pt | 2 +- docs/tutorials/wiki/src/basiclayout/tutorial/tests.py | 6 ++++++ .../wiki/src/basiclayout/tutorial/views/default.py | 2 +- .../wiki/src/basiclayout/tutorial/views/notfound.py | 2 +- 5 files changed, 21 insertions(+), 9 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki/basiclayout.rst b/docs/tutorials/wiki/basiclayout.rst index 52d3f4670..4eb5c4283 100644 --- a/docs/tutorials/wiki/basiclayout.rst +++ b/docs/tutorials/wiki/basiclayout.rst @@ -107,6 +107,12 @@ Next include routes from the ``.routes`` module. :lineno-match: :language: py +The included module contains the following function. + +.. literalinclude:: src/basiclayout/tutorial/routes.py + :linenos: + :language: py + This registers a "static view" using the :meth:`pyramid.config.Configurator.add_static_view` method. This view answers requests whose URL path starts with ``/static``. This statement registers a view that will serve up static assets, such as CSS and image files. @@ -121,7 +127,7 @@ Alternatively the cookiecutter could have used an *absolute* asset specification The third argument is an optional ``cache_max_age`` which specifies the number of seconds the static asset will be HTTP-cached. -Next perform a :term:`scan`. +Back into our ``__init__.py``, next perform a :term:`scan`. .. literalinclude:: src/basiclayout/tutorial/__init__.py :lines: 21 @@ -208,12 +214,12 @@ Let's try to understand the components in this module: The ``context`` argument signifies that the decorated view callable ``my_view`` should only be run when :term:`traversal` finds the ``tutorial.models.MyModel`` :term:`resource` as the :term:`context` of a request. In English this means that when the URL ``/`` is visited, and because ``MyModel`` is the root model, this view callable will be invoked. - The ``renderer`` argument names an :term:`asset specification` of ``templates/mytemplate.pt``. + The ``renderer`` argument names an :term:`asset specification` of ``tutorial:templates/mytemplate.pt``. This asset specification points at a :term:`Chameleon` template which lives in the ``mytemplate.pt`` file within the ``templates`` directory of the ``tutorial`` package. And indeed if you look in the ``templates`` directory of this package, you will see a ``mytemplate.pt`` template file This template renders the default home page of the generated project. - This asset specification is *relative* to the ``views`` package. - Alternatively we could have used the absolute asset specification ``tutorial:templates/mytemplate.pt``. + This asset specification is *absolute* to the ``views`` package. + Alternatively we could have used the relative asset specification ``../templates/mytemplate.pt``. Since this call to ``@view_config`` doesn't pass a ``name`` argument, the ``my_view`` function which it decorates represents the "default" view callable used when the context is of the type ``MyModel``. @@ -225,7 +231,7 @@ Let's try to understand the components in this module: The function returns the dictionary ``{'project': 'myproj'}``. This dictionary is used by the template named by the ``mytemplate.pt`` asset specification to fill in certain values on the page. -Let us open ``tutorial/views/default.py`` in the ``views`` package to look at the second view. +Let us open ``tutorial/views/notfound.py`` in the ``views`` package to look at the second view. .. literalinclude:: src/basiclayout/tutorial/views/notfound.py :linenos: @@ -237,7 +243,7 @@ Without repeating ourselves, we will point out the differences between this view The ``notfound_view`` function is decorated with ``@notfound_view_config``. This decorator registers a :term:`Not Found View` using :meth:`pyramid.config.Configurator.add_notfound_view`. - The ``renderer`` argument names an :term:`asset specification` of ``templates/404.pt``. + The ``renderer`` argument names an :term:`asset specification` of ``tutorial:templates/404.pt``. #. *Lines 5-7*. A :term:`view callable` named ``notfound_view`` is defined, which is decorated in the step above. diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/templates/layout.pt b/docs/tutorials/wiki/src/basiclayout/tutorial/templates/layout.pt index 9fdaef00f..9ca01382b 100644 --- a/docs/tutorials/wiki/src/basiclayout/tutorial/templates/layout.pt +++ b/docs/tutorials/wiki/src/basiclayout/tutorial/templates/layout.pt @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py b/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py index 6279d9f66..aa5641cdd 100644 --- a/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py +++ b/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py @@ -16,3 +16,9 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'myproj') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/views/default.py b/docs/tutorials/wiki/src/basiclayout/tutorial/views/default.py index 5d708d15c..51ec5ed98 100644 --- a/docs/tutorials/wiki/src/basiclayout/tutorial/views/default.py +++ b/docs/tutorials/wiki/src/basiclayout/tutorial/views/default.py @@ -3,6 +3,6 @@ from pyramid.view import view_config from ..models import MyModel -@view_config(context=MyModel, renderer='../templates/mytemplate.pt') +@view_config(context=MyModel, renderer='tutorial:templates/mytemplate.pt') def my_view(request): return {'project': 'myproj'} diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/views/notfound.py b/docs/tutorials/wiki/src/basiclayout/tutorial/views/notfound.py index 728791d0a..59a37280e 100644 --- a/docs/tutorials/wiki/src/basiclayout/tutorial/views/notfound.py +++ b/docs/tutorials/wiki/src/basiclayout/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.pt') +@notfound_view_config(renderer='tutorial:templates/404.pt') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 57fe1b6cb76717404ccc1777f2f3a4e6bf6b37a4 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 00:21:57 -0800 Subject: Update docs/tutorials/wiki/definingviews.rst and related src files, and models src files --- docs/tutorials/wiki/definingviews.rst | 4 ++-- docs/tutorials/wiki/src/models/tutorial/templates/layout.pt | 2 +- docs/tutorials/wiki/src/models/tutorial/tests.py | 6 ++++++ docs/tutorials/wiki/src/models/tutorial/views/default.py | 2 +- docs/tutorials/wiki/src/models/tutorial/views/notfound.py | 2 +- docs/tutorials/wiki/src/views/tutorial/templates/layout.pt | 2 +- docs/tutorials/wiki/src/views/tutorial/tests.py | 6 ++++++ docs/tutorials/wiki/src/views/tutorial/views/default.py | 6 +++--- docs/tutorials/wiki/src/views/tutorial/views/notfound.py | 2 +- 9 files changed, 22 insertions(+), 10 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki/definingviews.rst b/docs/tutorials/wiki/definingviews.rst index bd8dc6ecf..2e4d009a1 100644 --- a/docs/tutorials/wiki/definingviews.rst +++ b/docs/tutorials/wiki/definingviews.rst @@ -73,7 +73,7 @@ Success executing this command will end with a line to the console similar to th .. code-block:: text - Successfully installed docutils-0.14 tutorial + Successfully installed docutils-0.15.2 tutorial Adding view functions in the ``views`` package @@ -356,7 +356,7 @@ Our templates name static assets, including CSS and images. We don't need to create these files within our package's ``static`` directory because they were provided by the cookiecutter at the time we created the project. As an example, the CSS file will be accessed via ``http://localhost:6543/static/theme.css`` by virtue of the call to the ``add_static_view`` directive in the ``routes.py`` file. -Any number and type of static assets can be placed in this directory (or subdirectories) +Any number and type of static assets can be placed in this directory (or subdirectories). They are referred to by either URL or using the convenience method ``static_url``, for example ``request.static_url(':static/foo.css')``, within templates. diff --git a/docs/tutorials/wiki/src/models/tutorial/templates/layout.pt b/docs/tutorials/wiki/src/models/tutorial/templates/layout.pt index 9fdaef00f..9ca01382b 100644 --- a/docs/tutorials/wiki/src/models/tutorial/templates/layout.pt +++ b/docs/tutorials/wiki/src/models/tutorial/templates/layout.pt @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/wiki/src/models/tutorial/tests.py b/docs/tutorials/wiki/src/models/tutorial/tests.py index 6279d9f66..aa5641cdd 100644 --- a/docs/tutorials/wiki/src/models/tutorial/tests.py +++ b/docs/tutorials/wiki/src/models/tutorial/tests.py @@ -16,3 +16,9 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'myproj') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/models/tutorial/views/default.py b/docs/tutorials/wiki/src/models/tutorial/views/default.py index 5d708d15c..51ec5ed98 100644 --- a/docs/tutorials/wiki/src/models/tutorial/views/default.py +++ b/docs/tutorials/wiki/src/models/tutorial/views/default.py @@ -3,6 +3,6 @@ from pyramid.view import view_config from ..models import MyModel -@view_config(context=MyModel, renderer='../templates/mytemplate.pt') +@view_config(context=MyModel, renderer='tutorial:templates/mytemplate.pt') def my_view(request): return {'project': 'myproj'} diff --git a/docs/tutorials/wiki/src/models/tutorial/views/notfound.py b/docs/tutorials/wiki/src/models/tutorial/views/notfound.py index 728791d0a..59a37280e 100644 --- a/docs/tutorials/wiki/src/models/tutorial/views/notfound.py +++ b/docs/tutorials/wiki/src/models/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.pt') +@notfound_view_config(renderer='tutorial:templates/404.pt') def notfound_view(request): request.response.status = 404 return {} diff --git a/docs/tutorials/wiki/src/views/tutorial/templates/layout.pt b/docs/tutorials/wiki/src/views/tutorial/templates/layout.pt index b606e8dad..06a3c8157 100644 --- a/docs/tutorials/wiki/src/views/tutorial/templates/layout.pt +++ b/docs/tutorials/wiki/src/views/tutorial/templates/layout.pt @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/wiki/src/views/tutorial/tests.py b/docs/tutorials/wiki/src/views/tutorial/tests.py index 6279d9f66..aa5641cdd 100644 --- a/docs/tutorials/wiki/src/views/tutorial/tests.py +++ b/docs/tutorials/wiki/src/views/tutorial/tests.py @@ -16,3 +16,9 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'myproj') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/views/tutorial/views/default.py b/docs/tutorials/wiki/src/views/tutorial/views/default.py index b4b65a49b..e7921cf2f 100644 --- a/docs/tutorials/wiki/src/views/tutorial/views/default.py +++ b/docs/tutorials/wiki/src/views/tutorial/views/default.py @@ -15,7 +15,7 @@ def view_wiki(context, request): return HTTPFound(location=request.resource_url(context, 'FrontPage')) -@view_config(context='..models.Page', renderer='../templates/view.pt') +@view_config(context='..models.Page', renderer='tutorial:templates/view.pt') def view_page(context, request): wiki = context.__parent__ @@ -36,7 +36,7 @@ def view_page(context, request): @view_config(name='add_page', context='..models.Wiki', - renderer='../templates/edit.pt') + renderer='tutorial:templates/edit.pt') def add_page(context, request): pagename = request.subpath[0] if 'form.submitted' in request.params: @@ -54,7 +54,7 @@ def add_page(context, request): @view_config(name='edit_page', context='..models.Page', - renderer='../templates/edit.pt') + renderer='tutorial:templates/edit.pt') def edit_page(context, request): if 'form.submitted' in request.params: context.data = request.params['body'] diff --git a/docs/tutorials/wiki/src/views/tutorial/views/notfound.py b/docs/tutorials/wiki/src/views/tutorial/views/notfound.py index d44b4d0e6..dd0b00488 100644 --- a/docs/tutorials/wiki/src/views/tutorial/views/notfound.py +++ b/docs/tutorials/wiki/src/views/tutorial/views/notfound.py @@ -3,7 +3,7 @@ from pyramid.view import notfound_view_config from ..models import Page -@notfound_view_config(renderer='../templates/404.pt') +@notfound_view_config(renderer='tutorial:templates/404.pt') def notfound_view(request): request.response.status = 404 pagename = request.path -- cgit v1.2.3 From a5f0644e08cea5b896135c7441d63d9ee7ed1c30 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 00:36:56 -0800 Subject: Update docs/tutorials/wiki/authorization.rst and related src files --- docs/tutorials/wiki/authorization.rst | 10 +++++----- .../wiki/src/authorization/tutorial/templates/layout.pt | 2 +- docs/tutorials/wiki/src/authorization/tutorial/tests.py | 6 ++++++ .../tutorials/wiki/src/authorization/tutorial/views/default.py | 10 +++++----- .../wiki/src/authorization/tutorial/views/notfound.py | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki/authorization.rst b/docs/tutorials/wiki/authorization.rst index ef914cab5..2ff9deb31 100644 --- a/docs/tutorials/wiki/authorization.rst +++ b/docs/tutorials/wiki/authorization.rst @@ -99,7 +99,7 @@ Here we use "dummy" data to represent user and groups sources. Add an ACL ~~~~~~~~~~ -Open ``tutorial/models.py`` and add the following import statement near the top: +Open ``tutorial/models/__init__.py`` and add the following import statement near the top: .. literalinclude:: src/authorization/tutorial/models/__init__.py :lines: 4-8 @@ -179,7 +179,7 @@ Open ``tutorial/views/default.py`` and add a ``permission='edit'`` parameter to :language: python .. literalinclude:: src/authorization/tutorial/views/default.py - :lines: 68-70 + :lines: 69-71 :emphasize-lines: 2-3 :language: python @@ -191,12 +191,12 @@ Add a ``permission='view'`` parameter to the ``@view_config`` decorator for ``view_wiki()`` and ``view_page()`` as follows: .. literalinclude:: src/authorization/tutorial/views/default.py - :lines: 23-24 + :lines: 21-22 :emphasize-lines: 1-2 :language: python .. literalinclude:: src/authorization/tutorial/views/default.py - :lines: 28-29 + :lines: 27-28 :emphasize-lines: 1-2 :language: python @@ -318,7 +318,7 @@ Our ``tutorial/__init__.py`` will look like this when we are done: Only the highlighted lines need to be added or edited. -Our ``tutorial/models.py`` will look like this when we are done: +Our ``tutorial/models/__init__.py`` will look like this when we are done: .. literalinclude:: src/authorization/tutorial/models/__init__.py :linenos: diff --git a/docs/tutorials/wiki/src/authorization/tutorial/templates/layout.pt b/docs/tutorials/wiki/src/authorization/tutorial/templates/layout.pt index b606e8dad..06a3c8157 100644 --- a/docs/tutorials/wiki/src/authorization/tutorial/templates/layout.pt +++ b/docs/tutorials/wiki/src/authorization/tutorial/templates/layout.pt @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/wiki/src/authorization/tutorial/tests.py b/docs/tutorials/wiki/src/authorization/tutorial/tests.py index 6279d9f66..aa5641cdd 100644 --- a/docs/tutorials/wiki/src/authorization/tutorial/tests.py +++ b/docs/tutorials/wiki/src/authorization/tutorial/tests.py @@ -16,3 +16,9 @@ class ViewTests(unittest.TestCase): info = my_view(request) self.assertEqual(info['project'], 'myproj') + def test_notfound_view(self): + from .views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/authorization/tutorial/views/default.py b/docs/tutorials/wiki/src/authorization/tutorial/views/default.py index 3a3b170e2..7ba99c65b 100644 --- a/docs/tutorials/wiki/src/authorization/tutorial/views/default.py +++ b/docs/tutorials/wiki/src/authorization/tutorial/views/default.py @@ -24,7 +24,7 @@ def view_wiki(context, request): return HTTPFound(location=request.resource_url(context, 'FrontPage')) -@view_config(context='..models.Page', renderer='../templates/view.pt', +@view_config(context='..models.Page', renderer='tutorial:templates/view.pt', permission='view') def view_page(context, request): wiki = context.__parent__ @@ -47,7 +47,7 @@ def view_page(context, request): @view_config(name='add_page', context='..models.Wiki', - renderer='../templates/edit.pt', + renderer='tutorial:templates/edit.pt', permission='edit') def add_page(context, request): pagename = request.subpath[0] @@ -67,7 +67,7 @@ def add_page(context, request): @view_config(name='edit_page', context='..models.Page', - renderer='../templates/edit.pt', + renderer='tutorial:templates/edit.pt', permission='edit') def edit_page(context, request): if 'form.submitted' in request.params: @@ -80,8 +80,8 @@ def edit_page(context, request): @view_config(context='..models.Wiki', name='login', - renderer='../templates/login.pt') -@forbidden_view_config(renderer='../templates/login.pt') + renderer='tutorial:templates/login.pt') +@forbidden_view_config(renderer='tutorial:templates/login.pt') def login(request): login_url = request.resource_url(request.context, 'login') referrer = request.url diff --git a/docs/tutorials/wiki/src/authorization/tutorial/views/notfound.py b/docs/tutorials/wiki/src/authorization/tutorial/views/notfound.py index d44b4d0e6..dd0b00488 100644 --- a/docs/tutorials/wiki/src/authorization/tutorial/views/notfound.py +++ b/docs/tutorials/wiki/src/authorization/tutorial/views/notfound.py @@ -3,7 +3,7 @@ from pyramid.view import notfound_view_config from ..models import Page -@notfound_view_config(renderer='../templates/404.pt') +@notfound_view_config(renderer='tutorial:templates/404.pt') def notfound_view(request): request.response.status = 404 pagename = request.path -- cgit v1.2.3 From fdf5bc0829d266bcee303ec725e76a1e7ec54d73 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 00:39:07 -0800 Subject: Update src files for tests --- docs/tutorials/wiki/src/tests/tutorial/templates/layout.pt | 2 +- docs/tutorials/wiki/src/tests/tutorial/views/default.py | 10 +++++----- docs/tutorials/wiki/src/tests/tutorial/views/notfound.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki/src/tests/tutorial/templates/layout.pt b/docs/tutorials/wiki/src/tests/tutorial/templates/layout.pt index b606e8dad..06a3c8157 100644 --- a/docs/tutorials/wiki/src/tests/tutorial/templates/layout.pt +++ b/docs/tutorials/wiki/src/tests/tutorial/templates/layout.pt @@ -1,5 +1,5 @@ - + diff --git a/docs/tutorials/wiki/src/tests/tutorial/views/default.py b/docs/tutorials/wiki/src/tests/tutorial/views/default.py index 3a3b170e2..7ba99c65b 100644 --- a/docs/tutorials/wiki/src/tests/tutorial/views/default.py +++ b/docs/tutorials/wiki/src/tests/tutorial/views/default.py @@ -24,7 +24,7 @@ def view_wiki(context, request): return HTTPFound(location=request.resource_url(context, 'FrontPage')) -@view_config(context='..models.Page', renderer='../templates/view.pt', +@view_config(context='..models.Page', renderer='tutorial:templates/view.pt', permission='view') def view_page(context, request): wiki = context.__parent__ @@ -47,7 +47,7 @@ def view_page(context, request): @view_config(name='add_page', context='..models.Wiki', - renderer='../templates/edit.pt', + renderer='tutorial:templates/edit.pt', permission='edit') def add_page(context, request): pagename = request.subpath[0] @@ -67,7 +67,7 @@ def add_page(context, request): @view_config(name='edit_page', context='..models.Page', - renderer='../templates/edit.pt', + renderer='tutorial:templates/edit.pt', permission='edit') def edit_page(context, request): if 'form.submitted' in request.params: @@ -80,8 +80,8 @@ def edit_page(context, request): @view_config(context='..models.Wiki', name='login', - renderer='../templates/login.pt') -@forbidden_view_config(renderer='../templates/login.pt') + renderer='tutorial:templates/login.pt') +@forbidden_view_config(renderer='tutorial:templates/login.pt') def login(request): login_url = request.resource_url(request.context, 'login') referrer = request.url diff --git a/docs/tutorials/wiki/src/tests/tutorial/views/notfound.py b/docs/tutorials/wiki/src/tests/tutorial/views/notfound.py index d44b4d0e6..dd0b00488 100644 --- a/docs/tutorials/wiki/src/tests/tutorial/views/notfound.py +++ b/docs/tutorials/wiki/src/tests/tutorial/views/notfound.py @@ -3,7 +3,7 @@ from pyramid.view import notfound_view_config from ..models import Page -@notfound_view_config(renderer='../templates/404.pt') +@notfound_view_config(renderer='tutorial:templates/404.pt') def notfound_view(request): request.response.status = 404 pagename = request.path -- cgit v1.2.3 From 0db88c72bb3c444ca0f6fbe2cda50ca02c1bc011 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 01:02:08 -0800 Subject: Update docs/tutorials/wiki2/installation.rst and related src files --- docs/tutorials/wiki2/installation.rst | 119 +++++++-------------- .../wiki2/src/installation/development.ini | 7 +- .../wiki2/src/installation/production.ini | 7 +- docs/tutorials/wiki2/src/installation/setup.py | 10 +- .../wiki2/src/installation/tutorial/__init__.py | 2 +- .../installation/tutorial/alembic/script.py.mako | 2 - .../tutorial/alembic/versions/README.txt | 2 +- .../wiki2/src/installation/tutorial/pshell.py | 1 + .../src/installation/tutorial/templates/404.jinja2 | 2 +- .../installation/tutorial/templates/layout.jinja2 | 2 +- .../tutorial/templates/mytemplate.jinja2 | 4 +- .../wiki2/src/installation/tutorial/tests.py | 3 +- .../src/installation/tutorial/views/default.py | 6 +- .../src/installation/tutorial/views/notfound.py | 2 +- 14 files changed, 66 insertions(+), 103 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 705979065..384584da7 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -177,26 +177,30 @@ The console will show ``pip`` checking for packages and installing missing packa .. code-block:: bash - Successfully installed Jinja2-2.8 Mako-1.0.6 MarkupSafe-0.23 \ - PasteDeploy-1.5.2 Pygments-2.1.3 SQLAlchemy-1.1.4 WebOb-1.6.3 \ - WebTest-2.0.24 beautifulsoup4-4.5.1 coverage-4.2 py-1.4.32 pyramid-1.7.3 \ - pyramid-debugtoolbar-3.0.5 pyramid-jinja2-2.7 pyramid-mako-1.0.2 \ - pyramid-tm-1.1.1 pytest-3.0.5 pytest-cov-2.4.0 repoze.lru-0.6 six-1.10.0 \ - transaction-2.0.3 translationstring-1.3 tutorial venusian-1.0 \ - waitress-1.0.1 zope.deprecation-4.2.0 zope.interface-4.3.3 \ - zope.sqlalchemy-0.7.7 + Successfully installed Jinja2-2.10.3 Mako-1.1.0 MarkupSafe-1.1.1 \ + PasteDeploy-2.0.1 Pygments-2.5.2 SQLAlchemy-1.3.12 WebTest-2.0.33 \ + alembic-1.3.2 attrs-19.3.0 beautifulsoup4-4.8.2 coverage-5.0.1 \ + hupper-1.9.1 importlib-metadata-1.3.0 more-itertools-8.0.2 packaging-19.2 \ + plaster-1.0 plaster-pastedeploy-0.7 pluggy-0.13.1 py-1.8.1 \ + pyparsing-2.4.6 pyramid-1.10.4 pyramid-debugtoolbar-4.5.1 \ + pyramid-jinja2-2.8 pyramid-mako-1.1.0 pyramid-retry-2.1 pyramid-tm-2.3 \ + pytest-5.3.2 pytest-cov-2.8.1 python-dateutil-2.8.1 python-editor-1.0.4 \ + repoze.lru-0.7 six-1.13.0 soupsieve-1.9.5 transaction-3.0.0 \ + translationstring-1.3 tutorial venusian-3.0.0 waitress-1.4.1 \ + wcwidth-0.1.7 webob-1.8.5 zipp-0.6.0 zope.deprecation-4.4.0 \ + zope.interface-4.7.1 zope.sqlalchemy-1.2 Testing requirements are defined in our project's ``setup.py`` file, in the ``tests_require`` and ``extras_require`` stanzas. .. literalinclude:: src/installation/setup.py :language: python :lineno-match: - :lines: 24-28 + :lines: 25-29 .. literalinclude:: src/installation/setup.py :language: python :lineno-match: - :lines: 48-50 + :lines: 49-51 .. _initialize_db_wiki2: @@ -226,26 +230,11 @@ The output to your console should be something like this: .. code-block:: text - 2018-06-22 17:57:31,587 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2018-06-22 17:57:31,587 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-22 17:57:31,588 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2018-06-22 17:57:31,588 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-22 17:57:31,589 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("alembic_version") - 2018-06-22 17:57:31,589 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:31,590 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("alembic_version") - 2018-06-22 17:57:31,590 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:31,590 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] - CREATE TABLE alembic_version ( - version_num VARCHAR(32) NOT NULL, - CONSTRAINT alembic_version_pkc PRIMARY KEY (version_num) - ) - - - 2018-06-22 17:57:31,591 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:31,591 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-22 17:57:31,594 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT name FROM sqlite_master WHERE type='table' ORDER BY name - 2018-06-22 17:57:31,594 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - Generating //tutorial/alembic/versions/20180622_bab5a278ce04.py ... done + 2019-12-28 00:46:03,850 INFO [alembic.runtime.migration:154][MainThread] Context impl SQLiteImpl. + 2019-12-28 00:46:03,850 INFO [alembic.runtime.migration:161][MainThread] Will assume non-transactional DDL. + 2019-12-28 00:46:03,853 INFO [alembic.autogenerate.compare:134][MainThread] Detected added table 'models' + 2019-12-28 00:46:03,853 INFO [alembic.autogenerate.compare:586][MainThread] Detected added index 'my_index' on '['name']' + Generating /tutorial/tutorial/alembic/versions/20191228_a8e203c3ce9c.py ... done Upgrade to that revision. @@ -267,34 +256,9 @@ The output to your console should be something like this: .. code-block:: text - 2018-06-22 17:57:37,814 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2018-06-22 17:57:37,814 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-22 17:57:37,814 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2018-06-22 17:57:37,814 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-22 17:57:37,816 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("alembic_version") - 2018-06-22 17:57:37,816 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:37,817 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT alembic_version.version_num - FROM alembic_version - 2018-06-22 17:57:37,817 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:37,817 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("alembic_version") - 2018-06-22 17:57:37,817 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:37,819 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] - CREATE TABLE models ( - id INTEGER NOT NULL, - name TEXT, - value INTEGER, - CONSTRAINT pk_models PRIMARY KEY (id) - ) - - - 2018-06-22 17:57:37,820 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:37,822 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-22 17:57:37,824 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] CREATE UNIQUE INDEX my_index ON models (name) - 2018-06-22 17:57:37,824 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:37,825 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-22 17:57:37,825 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] INSERT INTO alembic_version (version_num) VALUES ('bab5a278ce04') - 2018-06-22 17:57:37,825 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-22 17:57:37,825 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT + 2019-12-28 00:52:12,158 INFO [alembic.runtime.migration:154][MainThread] Context impl SQLiteImpl. + 2019-12-28 00:52:12,158 INFO [alembic.runtime.migration:161][MainThread] Will assume non-transactional DDL. + 2019-12-28 00:52:12,160 INFO [alembic.runtime.migration:513][MainThread] Running upgrade -> a8e203c3ce9c, init .. _load_data_wiki2: @@ -318,22 +282,9 @@ On Windows %VENV%\Scripts\initialize_tutorial_db development.ini -The output to your console should be something like this: - -.. code-block:: bash - - 2018-06-22 17:57:46,241 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2018-06-22 17:57:46,241 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-22 17:57:46,242 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2018-06-22 17:57:46,242 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-22 17:57:46,243 INFO [sqlalchemy.engine.base.Engine:682][MainThread] BEGIN (implicit) - 2018-06-22 17:57:46,244 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] INSERT INTO models (name, value) VALUES (?, ?) - 2018-06-22 17:57:46,245 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] ('one', 1) - 2018-06-22 17:57:46,246 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - -Success! You should now have a ``tutorial.sqlite`` file in your current -working directory. This is an SQLite database with a single table defined in it -(``models``) and single record inside of that. +There should be no output to your console. +You should now have a ``tutorial.sqlite`` file in your current working directory. +This is an SQLite database with three tables defined in it, ``alembic_version``, ``models``, and ``master``, where the first two tables each have single record inside of them. .. _sql_running_tests: @@ -398,29 +349,31 @@ If successful, you will see output something like this: .. code-block:: bash ======================== test session starts ======================== - platform Python 3.6.5, pytest-3.6.2, py-1.5.3, pluggy-0.6.0 - rootdir: //tutorial, inifile: pytest.ini - plugins: cov-2.5.1 + platform -- Python 3.7.3, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 + rootdir: /tutorial, inifile: pytest.ini, testpaths: tutorial + plugins: cov-2.8.1 collected 2 items tutorial/tests.py .. - ------------------ coverage: platform Python 3.6.5 ------------------ + + ------------------ coverage: platform Python 3.7.3 ------------------ Name Stmts Miss Cover Missing ----------------------------------------------------------------- tutorial/__init__.py 8 6 25% 7-12 tutorial/models/__init__.py 24 0 100% tutorial/models/meta.py 5 0 100% tutorial/models/mymodel.py 8 0 100% + tutorial/pshell.py 7 7 0% 1-13 tutorial/routes.py 3 3 0% 1-3 tutorial/scripts/__init__.py 0 0 100% - tutorial/scripts/initialize_db.py 24 24 0% 1-34 + tutorial/scripts/initialize_db.py 22 22 0% 1-38 tutorial/views/__init__.py 0 0 100% tutorial/views/default.py 12 0 100% tutorial/views/notfound.py 4 4 0% 1-7 ----------------------------------------------------------------- - TOTAL 88 37 58% + TOTAL 93 42 55% - ===================== 2 passed in 0.57 seconds ====================== + ===================== 2 passed in 0.64 seconds ====================== Our package doesn't quite have 100% test coverage. @@ -489,8 +442,8 @@ If successful, you will see something like this on your console: .. code-block:: text - Starting subprocess with file monitor - Starting server in PID 44078. + Starting monitor for PID 68932. + Starting server in PID 68932. Serving on http://localhost:6543 Serving on http://localhost:6543 diff --git a/docs/tutorials/wiki2/src/installation/development.ini b/docs/tutorials/wiki2/src/installation/development.ini index 564aefb56..f02c4b1b6 100644 --- a/docs/tutorials/wiki2/src/installation/development.ini +++ b/docs/tutorials/wiki2/src/installation/development.ini @@ -45,7 +45,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -70,6 +70,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/installation/production.ini b/docs/tutorials/wiki2/src/installation/production.ini index 29cdda1e1..f8e83f21f 100644 --- a/docs/tutorials/wiki2/src/installation/production.ini +++ b/docs/tutorials/wiki2/src/installation/production.ini @@ -39,7 +39,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -64,6 +64,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/installation/setup.py b/docs/tutorials/wiki2/src/installation/setup.py index 746012a74..a0efdea6d 100644 --- a/docs/tutorials/wiki2/src/installation/setup.py +++ b/docs/tutorials/wiki2/src/installation/setup.py @@ -9,17 +9,17 @@ with open(os.path.join(here, 'CHANGES.txt')) as f: CHANGES = f.read() requires = [ - 'alembic', 'plaster_pastedeploy', - 'pyramid >= 1.9', - 'pyramid_debugtoolbar', + 'pyramid', 'pyramid_jinja2', + 'pyramid_debugtoolbar', + 'waitress', + 'alembic', 'pyramid_retry', 'pyramid_tm', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', - 'waitress', ] tests_require = [ @@ -55,7 +55,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/__init__.py b/docs/tutorials/wiki2/src/installation/tutorial/__init__.py index 28bd1f80d..5c2ba5cc0 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/installation/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.scan() return config.make_wsgi_app() diff --git a/docs/tutorials/wiki2/src/installation/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/installation/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/installation/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/installation/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/installation/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/installation/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/installation/tutorial/pshell.py b/docs/tutorials/wiki2/src/installation/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/installation/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/installation/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/installation/tutorial/templates/404.jinja2 index 1917f83c7..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/installation/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy scaffold

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 b/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 index 5d4313fe2..f5a086f0e 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 +++ b/docs/tutorials/wiki2/src/installation/tutorial/templates/layout.jinja2 @@ -8,7 +8,7 @@ - Cookiecutter Alchemy project for the Pyramid Web Framework + Cookiecutter Starter project for the Pyramid Web Framework diff --git a/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 b/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 index d8b0a4232..f2e7283f8 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 +++ b/docs/tutorials/wiki2/src/installation/tutorial/templates/mytemplate.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy project

+

Pyramid Starter project

Welcome to {{project}}, a Pyramid application generated by
Cookiecutter.

-{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/docs/tutorials/wiki2/src/installation/tutorial/tests.py b/docs/tutorials/wiki2/src/installation/tutorial/tests.py index ce650ca7c..47990669e 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/installation/tutorial/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/views/default.py b/docs/tutorials/wiki2/src/installation/tutorial/views/default.py index ef69ff895..094b2f303 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/installation/tutorial/views/default.py @@ -1,12 +1,12 @@ -from pyramid.response import Response from pyramid.view import view_config +from pyramid.response import Response from sqlalchemy.exc import DBAPIError from .. import models -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='tutorial:templates/mytemplate.jinja2') def my_view(request): try: query = request.dbsession.query(models.MyModel) @@ -21,7 +21,7 @@ Pyramid is having a problem using your SQL database. The problem might be caused by one of the following things: 1. You may need to initialize your database tables with `alembic`. - Check your README.txt for description and try to run it. + Check your README.txt for descriptions and try to run it. 2. Your database server may not be running. Check that the database server referred to by the "sqlalchemy.url" setting in diff --git a/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/installation/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 87e90486fb17254be7805fc6f984f43c85f3506b Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 01:46:20 -0800 Subject: Update docs/tutorials/wiki2/basiclayout.rst and related src files --- docs/tutorials/wiki2/basiclayout.rst | 27 ++++++++++++++++++---- .../wiki2/src/basiclayout/development.ini | 7 +++++- .../tutorials/wiki2/src/basiclayout/production.ini | 7 +++++- docs/tutorials/wiki2/src/basiclayout/setup.py | 10 ++++---- .../wiki2/src/basiclayout/tutorial/__init__.py | 2 +- .../basiclayout/tutorial/alembic/script.py.mako | 2 -- .../tutorial/alembic/versions/README.txt | 2 +- .../wiki2/src/basiclayout/tutorial/pshell.py | 1 + .../src/basiclayout/tutorial/templates/404.jinja2 | 2 +- .../basiclayout/tutorial/templates/layout.jinja2 | 2 +- .../tutorial/templates/mytemplate.jinja2 | 4 ++-- .../wiki2/src/basiclayout/tutorial/tests.py | 3 ++- .../src/basiclayout/tutorial/views/default.py | 6 ++--- .../src/basiclayout/tutorial/views/notfound.py | 2 +- 14 files changed, 53 insertions(+), 24 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/basiclayout.rst b/docs/tutorials/wiki2/basiclayout.rst index f3a9db223..ae58d80a5 100644 --- a/docs/tutorials/wiki2/basiclayout.rst +++ b/docs/tutorials/wiki2/basiclayout.rst @@ -58,16 +58,16 @@ dictionary of settings parsed from the ``.ini`` file, which contains deployment-related values, such as ``pyramid.reload_templates``, ``sqlalchemy.url``, and so on. -Next include :term:`Jinja2` templating bindings so that we can use renderers -with the ``.jinja2`` extension within our project. +Next include the package ``models`` using a dotted Python path. The exact +setup of the models will be covered later. .. literalinclude:: src/basiclayout/tutorial/__init__.py :lines: 8 :lineno-match: :language: py -Next include the package ``models`` using a dotted Python path. The exact -setup of the models will be covered later. +Next include :term:`Jinja2` templating bindings so that we can use renderers +with the ``.jinja2`` extension within our project. .. literalinclude:: src/basiclayout/tutorial/__init__.py :lines: 9 @@ -184,6 +184,25 @@ database and provide an alternate error response. That response will include the text shown at the end of the file, which will be displayed in the browser to inform the user about possible actions to take to solve the problem. +Open ``tutorial/views/notfound.py`` in the ``views`` package to look at the second view. + +.. literalinclude:: src/basiclayout/tutorial/views/notfound.py + :linenos: + :language: python + +Without repeating ourselves, we will point out the differences between this view and the previous. + +#. *Line 4*. + The ``notfound_view`` function is decorated with ``@notfound_view_config``. + This decorator registers a :term:`Not Found View` using :meth:`pyramid.config.Configurator.add_notfound_view`. + + The ``renderer`` argument names an :term:`asset specification` of ``tutorial:templates/404.jinja2``. + +#. *Lines 5-7*. + A :term:`view callable` named ``notfound_view`` is defined, which is decorated in the step above. + It sets the HTTP response status code to ``404``. + The function returns an empty dictionary to the template ``404.jinja2``, which accepts no parameters anyway. + Content models with the ``models`` package ------------------------------------------ diff --git a/docs/tutorials/wiki2/src/basiclayout/development.ini b/docs/tutorials/wiki2/src/basiclayout/development.ini index 564aefb56..f02c4b1b6 100644 --- a/docs/tutorials/wiki2/src/basiclayout/development.ini +++ b/docs/tutorials/wiki2/src/basiclayout/development.ini @@ -45,7 +45,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -70,6 +70,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/basiclayout/production.ini b/docs/tutorials/wiki2/src/basiclayout/production.ini index 29cdda1e1..f8e83f21f 100644 --- a/docs/tutorials/wiki2/src/basiclayout/production.ini +++ b/docs/tutorials/wiki2/src/basiclayout/production.ini @@ -39,7 +39,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -64,6 +64,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/basiclayout/setup.py b/docs/tutorials/wiki2/src/basiclayout/setup.py index 746012a74..a0efdea6d 100644 --- a/docs/tutorials/wiki2/src/basiclayout/setup.py +++ b/docs/tutorials/wiki2/src/basiclayout/setup.py @@ -9,17 +9,17 @@ with open(os.path.join(here, 'CHANGES.txt')) as f: CHANGES = f.read() requires = [ - 'alembic', 'plaster_pastedeploy', - 'pyramid >= 1.9', - 'pyramid_debugtoolbar', + 'pyramid', 'pyramid_jinja2', + 'pyramid_debugtoolbar', + 'waitress', + 'alembic', 'pyramid_retry', 'pyramid_tm', 'SQLAlchemy', 'transaction', 'zope.sqlalchemy', - 'waitress', ] tests_require = [ @@ -55,7 +55,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py index 28bd1f80d..5c2ba5cc0 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.scan() return config.make_wsgi_app() diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/pshell.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/404.jinja2 index 1917f83c7..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy scaffold

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 index 5d4313fe2..f5a086f0e 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/layout.jinja2 @@ -8,7 +8,7 @@ - Cookiecutter Alchemy project for the Pyramid Web Framework + Cookiecutter Starter project for the Pyramid Web Framework diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.jinja2 b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.jinja2 index d8b0a4232..f2e7283f8 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.jinja2 +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/templates/mytemplate.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy project

+

Pyramid Starter project

Welcome to {{project}}, a Pyramid application generated by
Cookiecutter.

-{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py index ce650ca7c..47990669e 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/views/default.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/views/default.py index ef69ff895..094b2f303 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/views/default.py @@ -1,12 +1,12 @@ -from pyramid.response import Response from pyramid.view import view_config +from pyramid.response import Response from sqlalchemy.exc import DBAPIError from .. import models -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='tutorial:templates/mytemplate.jinja2') def my_view(request): try: query = request.dbsession.query(models.MyModel) @@ -21,7 +21,7 @@ Pyramid is having a problem using your SQL database. The problem might be caused by one of the following things: 1. You may need to initialize your database tables with `alembic`. - Check your README.txt for description and try to run it. + Check your README.txt for descriptions and try to run it. 2. Your database server may not be running. Check that the database server referred to by the "sqlalchemy.url" setting in diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/basiclayout/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 49f8e03861fbcb3a4d02a53bf5793aaee8757bfd Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:13:03 -0800 Subject: Update docs/tutorials/wiki2/definingmodels.rst and related src files --- docs/tutorials/wiki2/definingmodels.rst | 126 +++++---------------- docs/tutorials/wiki2/src/models/development.ini | 7 +- docs/tutorials/wiki2/src/models/production.ini | 7 +- docs/tutorials/wiki2/src/models/setup.py | 4 +- .../wiki2/src/models/tutorial/__init__.py | 2 +- .../src/models/tutorial/alembic/script.py.mako | 2 - .../models/tutorial/alembic/versions/README.txt | 2 +- docs/tutorials/wiki2/src/models/tutorial/pshell.py | 1 + .../wiki2/src/models/tutorial/templates/404.jinja2 | 2 +- .../src/models/tutorial/templates/layout.jinja2 | 2 +- .../models/tutorial/templates/mytemplate.jinja2 | 4 +- docs/tutorials/wiki2/src/models/tutorial/tests.py | 3 +- .../wiki2/src/models/tutorial/views/default.py | 6 +- .../wiki2/src/models/tutorial/views/notfound.py | 2 +- 14 files changed, 56 insertions(+), 114 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/definingmodels.rst b/docs/tutorials/wiki2/definingmodels.rst index 6624e4cdc..516fd66cf 100644 --- a/docs/tutorials/wiki2/definingmodels.rst +++ b/docs/tutorials/wiki2/definingmodels.rst @@ -33,10 +33,12 @@ Open ``tutorial/setup.py`` and edit it to look like the following: .. literalinclude:: src/models/setup.py :linenos: - :emphasize-lines: 13 + :emphasize-lines: 11-24 :language: python -Only the highlighted line needs to be added. +It is a good practice to sort packages alphabetically to make them easier to find. +Our cookiecutter does not have its packages sorted because it merely tacks on additional packages depending on our selections. +After adding ``bcrypt`` and sorting packages, we should have the above ``requires`` list. .. note:: @@ -70,7 +72,7 @@ like the following. .. code-block:: text - Successfully installed bcrypt-3.1.4 cffi-1.11.5 pycparser-2.18 tutorial + Successfully installed bcrypt-3.1.7 cffi-1.13.2 pycparser-2.19 tutorial Remove ``mymodel.py`` @@ -185,86 +187,19 @@ Success executing these commands will generate output similar to the following. .. code-block:: text - 2018-06-29 01:28:42,407 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2018-06-29 01:28:42,407 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-29 01:28:42,408 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2018-06-29 01:28:42,408 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-29 01:28:42,409 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("alembic_version") - 2018-06-29 01:28:42,409 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,410 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT alembic_version.version_num - FROM alembic_version - 2018-06-29 01:28:42,410 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,411 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT name FROM sqlite_master WHERE type='table' ORDER BY name - 2018-06-29 01:28:42,412 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,413 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("models") - 2018-06-29 01:28:42,413 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,414 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE name = 'models' AND type = 'table' - 2018-06-29 01:28:42,414 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,414 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA foreign_key_list("models") - 2018-06-29 01:28:42,414 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,414 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE name = 'models' AND type = 'table' - 2018-06-29 01:28:42,415 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,416 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA index_list("models") - 2018-06-29 01:28:42,416 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,416 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA index_info("my_index") - 2018-06-29 01:28:42,416 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,417 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA index_list("models") - 2018-06-29 01:28:42,417 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,417 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA index_info("my_index") - 2018-06-29 01:28:42,417 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:28:42,417 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT sql FROM (SELECT * FROM sqlite_master UNION ALL SELECT * FROM sqlite_temp_master) WHERE name = 'models' AND type = 'table' - 2018-06-29 01:28:42,417 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - Generating //tutorial/tutorial/alembic/versions/20180629_23e9f8eb6c28.py ... done + 2019-12-28 02:02:31,841 INFO [alembic.runtime.migration:154][MainThread] Context impl SQLiteImpl. + 2019-12-28 02:02:31,841 INFO [alembic.runtime.migration:161][MainThread] Will assume non-transactional DDL. + 2019-12-28 02:02:31,844 INFO [alembic.autogenerate.compare:134][MainThread] Detected added table 'users' + 2019-12-28 02:02:31,845 INFO [alembic.autogenerate.compare:134][MainThread] Detected added table 'pages' + 2019-12-28 02:02:31,853 INFO [alembic.autogenerate.compare:621][MainThread] Detected removed index 'my_index' on 'models' + 2019-12-28 02:02:31,853 INFO [alembic.autogenerate.compare:176][MainThread] Detected removed table 'models' + Generating /tutorial/tutorial/alembic/versions/20191228_226a73ffaeef.py ... done .. code-block:: text - 2018-06-29 01:29:37,957 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2018-06-29 01:29:37,958 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-29 01:29:37,958 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2018-06-29 01:29:37,958 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-29 01:29:37,960 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] PRAGMA table_info("alembic_version") - 2018-06-29 01:29:37,960 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,960 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] SELECT alembic_version.version_num - FROM alembic_version - 2018-06-29 01:29:37,960 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,963 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] - CREATE TABLE users ( - id INTEGER NOT NULL, - name TEXT NOT NULL, - role TEXT NOT NULL, - password_hash TEXT, - CONSTRAINT pk_users PRIMARY KEY (id), - CONSTRAINT uq_users_name UNIQUE (name) - ) - - - 2018-06-29 01:29:37,963 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,966 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-29 01:29:37,968 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] - CREATE TABLE pages ( - id INTEGER NOT NULL, - name TEXT NOT NULL, - data TEXT NOT NULL, - creator_id INTEGER NOT NULL, - CONSTRAINT pk_pages PRIMARY KEY (id), - CONSTRAINT fk_pages_creator_id_users FOREIGN KEY(creator_id) REFERENCES users (id), - CONSTRAINT uq_pages_name UNIQUE (name) - ) - - - 2018-06-29 01:29:37,968 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,969 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-29 01:29:37,969 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] - DROP INDEX my_index - 2018-06-29 01:29:37,969 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,970 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-29 01:29:37,970 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] - DROP TABLE models - 2018-06-29 01:29:37,970 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,971 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT - 2018-06-29 01:29:37,972 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] UPDATE alembic_version SET version_num='23e9f8eb6c28' WHERE alembic_version.version_num = 'b6b22ae3e628' - 2018-06-29 01:29:37,972 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] () - 2018-06-29 01:29:37,972 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT + 2019-12-28 02:03:15,390 INFO [alembic.runtime.migration:154][MainThread] Context impl SQLiteImpl. + 2019-12-28 02:03:15,391 INFO [alembic.runtime.migration:161][MainThread] Will assume non-transactional DDL. + 2019-12-28 02:03:15,393 INFO [alembic.runtime.migration:513][MainThread] Running upgrade a8e203c3ce9c -> 226a73ffaeef, use new models Page and User .. _wiki2_alembic_overview: @@ -318,26 +253,23 @@ Only the highlighted lines need to be changed. Populating the database ======================= -Because our model has changed, and to repopulate the database, we -need to rerun the ``initialize_tutorial_db`` command to pick up the changes -we've made to the initialize_db.py file. See :ref:`initialize_db_wiki2` for instructions. +Because our model has changed, and to repopulate the database, we need to rerun the ``initialize_tutorial_db`` command to pick up the changes we've made to the ``initialize_db.py`` file. -Success will look something like this: +On Unix +^^^^^^^ -.. code-block:: text +.. code-block:: bash + + $VENV/bin/initialize_tutorial_db development.ini + +On Windows +^^^^^^^^^^ + +.. code-block:: doscon + + %VENV%\Scripts\initialize_tutorial_db development.ini - 2018-06-29 01:30:39,326 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test plain returns' AS VARCHAR(60)) AS anon_1 - 2018-06-29 01:30:39,326 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-29 01:30:39,327 INFO [sqlalchemy.engine.base.Engine:1254][MainThread] SELECT CAST('test unicode returns' AS VARCHAR(60)) AS anon_1 - 2018-06-29 01:30:39,327 INFO [sqlalchemy.engine.base.Engine:1255][MainThread] () - 2018-06-29 01:30:39,328 INFO [sqlalchemy.engine.base.Engine:682][MainThread] BEGIN (implicit) - 2018-06-29 01:30:39,329 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] INSERT INTO users (name, role, password_hash) VALUES (?, ?, ?) - 2018-06-29 01:30:39,329 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] ('editor', 'editor', '$2b$12$PlaJSN7goVbyx8OFs8yAju9n5gHGdI6PZ2QRJGM2jDCiEU4ItUNxy') - 2018-06-29 01:30:39,330 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] INSERT INTO users (name, role, password_hash) VALUES (?, ?, ?) - 2018-06-29 01:30:39,330 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] ('basic', 'basic', '$2b$12$MvXdM8jlkbjEyPZ6uXzRg.yatZZK8jCwfPaM7kFkmVJiJjRoCCvmW') - 2018-06-29 01:30:39,331 INFO [sqlalchemy.engine.base.Engine:1151][MainThread] INSERT INTO pages (name, data, creator_id) VALUES (?, ?, ?) - 2018-06-29 01:30:39,331 INFO [sqlalchemy.engine.base.Engine:1154][MainThread] ('FrontPage', 'This is the front page', 1) - 2018-06-29 01:30:39,332 INFO [sqlalchemy.engine.base.Engine:722][MainThread] COMMIT +There should be no output to your console to indicate success. View the application in a browser diff --git a/docs/tutorials/wiki2/src/models/development.ini b/docs/tutorials/wiki2/src/models/development.ini index 564aefb56..f02c4b1b6 100644 --- a/docs/tutorials/wiki2/src/models/development.ini +++ b/docs/tutorials/wiki2/src/models/development.ini @@ -45,7 +45,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -70,6 +70,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/models/production.ini b/docs/tutorials/wiki2/src/models/production.ini index 29cdda1e1..f8e83f21f 100644 --- a/docs/tutorials/wiki2/src/models/production.ini +++ b/docs/tutorials/wiki2/src/models/production.ini @@ -39,7 +39,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -64,6 +64,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/models/setup.py b/docs/tutorials/wiki2/src/models/setup.py index b9dc9d93f..da99411a0 100644 --- a/docs/tutorials/wiki2/src/models/setup.py +++ b/docs/tutorials/wiki2/src/models/setup.py @@ -12,7 +12,7 @@ requires = [ 'alembic', 'bcrypt', 'plaster_pastedeploy', - 'pyramid >= 1.9', + 'pyramid', 'pyramid_debugtoolbar', 'pyramid_jinja2', 'pyramid_retry', @@ -56,7 +56,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/models/tutorial/__init__.py b/docs/tutorials/wiki2/src/models/tutorial/__init__.py index 28bd1f80d..5c2ba5cc0 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/models/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.scan() return config.make_wsgi_app() diff --git a/docs/tutorials/wiki2/src/models/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/models/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/models/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/models/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/models/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/models/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/models/tutorial/pshell.py b/docs/tutorials/wiki2/src/models/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/models/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/models/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/models/tutorial/templates/404.jinja2 index 1917f83c7..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/models/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy scaffold

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/models/tutorial/templates/layout.jinja2 b/docs/tutorials/wiki2/src/models/tutorial/templates/layout.jinja2 index 5d4313fe2..f5a086f0e 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/templates/layout.jinja2 +++ b/docs/tutorials/wiki2/src/models/tutorial/templates/layout.jinja2 @@ -8,7 +8,7 @@ - Cookiecutter Alchemy project for the Pyramid Web Framework + Cookiecutter Starter project for the Pyramid Web Framework diff --git a/docs/tutorials/wiki2/src/models/tutorial/templates/mytemplate.jinja2 b/docs/tutorials/wiki2/src/models/tutorial/templates/mytemplate.jinja2 index d8b0a4232..f2e7283f8 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/templates/mytemplate.jinja2 +++ b/docs/tutorials/wiki2/src/models/tutorial/templates/mytemplate.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid Alchemy project

+

Pyramid Starter project

Welcome to {{project}}, a Pyramid application generated by
Cookiecutter.

-{% endblock content %} \ No newline at end of file +{% endblock content %} diff --git a/docs/tutorials/wiki2/src/models/tutorial/tests.py b/docs/tutorials/wiki2/src/models/tutorial/tests.py index ce650ca7c..47990669e 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/models/tutorial/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/tutorials/wiki2/src/models/tutorial/views/default.py b/docs/tutorials/wiki2/src/models/tutorial/views/default.py index ef69ff895..094b2f303 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/models/tutorial/views/default.py @@ -1,12 +1,12 @@ -from pyramid.response import Response from pyramid.view import view_config +from pyramid.response import Response from sqlalchemy.exc import DBAPIError from .. import models -@view_config(route_name='home', renderer='../templates/mytemplate.jinja2') +@view_config(route_name='home', renderer='tutorial:templates/mytemplate.jinja2') def my_view(request): try: query = request.dbsession.query(models.MyModel) @@ -21,7 +21,7 @@ Pyramid is having a problem using your SQL database. The problem might be caused by one of the following things: 1. You may need to initialize your database tables with `alembic`. - Check your README.txt for description and try to run it. + Check your README.txt for descriptions and try to run it. 2. Your database server may not be running. Check that the database server referred to by the "sqlalchemy.url" setting in diff --git a/docs/tutorials/wiki2/src/models/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/models/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/models/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/models/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 24f21b5ff957c0bef319cb5927ee892ce0f36b60 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:24:21 -0800 Subject: Update docs/tutorials/wiki2/definingviews.rst and related src files --- docs/tutorials/wiki2/src/views/development.ini | 7 ++++++- docs/tutorials/wiki2/src/views/production.ini | 7 ++++++- docs/tutorials/wiki2/src/views/setup.py | 4 ++-- docs/tutorials/wiki2/src/views/tutorial/__init__.py | 2 +- docs/tutorials/wiki2/src/views/tutorial/alembic/script.py.mako | 2 -- .../tutorials/wiki2/src/views/tutorial/alembic/versions/README.txt | 2 +- docs/tutorials/wiki2/src/views/tutorial/pshell.py | 1 + docs/tutorials/wiki2/src/views/tutorial/templates/404.jinja2 | 2 +- docs/tutorials/wiki2/src/views/tutorial/tests.py | 3 ++- docs/tutorials/wiki2/src/views/tutorial/views/default.py | 6 +++--- docs/tutorials/wiki2/src/views/tutorial/views/notfound.py | 2 +- 11 files changed, 24 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/src/views/development.ini b/docs/tutorials/wiki2/src/views/development.ini index 564aefb56..f02c4b1b6 100644 --- a/docs/tutorials/wiki2/src/views/development.ini +++ b/docs/tutorials/wiki2/src/views/development.ini @@ -45,7 +45,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -70,6 +70,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/views/production.ini b/docs/tutorials/wiki2/src/views/production.ini index 29cdda1e1..f8e83f21f 100644 --- a/docs/tutorials/wiki2/src/views/production.ini +++ b/docs/tutorials/wiki2/src/views/production.ini @@ -39,7 +39,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -64,6 +64,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/views/setup.py b/docs/tutorials/wiki2/src/views/setup.py index f71998afc..a99793c15 100644 --- a/docs/tutorials/wiki2/src/views/setup.py +++ b/docs/tutorials/wiki2/src/views/setup.py @@ -13,7 +13,7 @@ requires = [ 'bcrypt', 'docutils', 'plaster_pastedeploy', - 'pyramid >= 1.9', + 'pyramid', 'pyramid_debugtoolbar', 'pyramid_jinja2', 'pyramid_retry', @@ -57,7 +57,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/views/tutorial/__init__.py b/docs/tutorials/wiki2/src/views/tutorial/__init__.py index 28bd1f80d..5c2ba5cc0 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/views/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.scan() return config.make_wsgi_app() diff --git a/docs/tutorials/wiki2/src/views/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/views/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/views/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/views/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/views/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/views/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/views/tutorial/pshell.py b/docs/tutorials/wiki2/src/views/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/views/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/views/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/views/tutorial/templates/404.jinja2 index 37b0a16b6..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/views/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid tutorial wiki (based on TurboGears 20-Minute Wiki)

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/views/tutorial/tests.py b/docs/tutorials/wiki2/src/views/tutorial/tests.py index ce650ca7c..47990669e 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/views/tutorial/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/tutorials/wiki2/src/views/tutorial/views/default.py b/docs/tutorials/wiki2/src/views/tutorial/views/default.py index 5e28b64fd..867ba3f6c 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/views/tutorial/views/default.py @@ -19,7 +19,7 @@ def view_wiki(request): next_url = request.route_url('view_page', pagename='FrontPage') return HTTPFound(location=next_url) -@view_config(route_name='view_page', renderer='../templates/view.jinja2') +@view_config(route_name='view_page', renderer='tutorial:templates/view.jinja2') def view_page(request): pagename = request.matchdict['pagename'] page = request.dbsession.query(models.Page).filter_by(name=pagename).first() @@ -41,7 +41,7 @@ def view_page(request): edit_url = request.route_url('edit_page', pagename=page.name) return dict(page=page, content=content, edit_url=edit_url) -@view_config(route_name='edit_page', renderer='../templates/edit.jinja2') +@view_config(route_name='edit_page', renderer='tutorial:templates/edit.jinja2') def edit_page(request): pagename = request.matchdict['pagename'] page = request.dbsession.query(models.Page).filter_by(name=pagename).one() @@ -55,7 +55,7 @@ def edit_page(request): save_url=request.route_url('edit_page', pagename=page.name), ) -@view_config(route_name='add_page', renderer='../templates/edit.jinja2') +@view_config(route_name='add_page', renderer='tutorial:templates/edit.jinja2') def add_page(request): pagename = request.matchdict['pagename'] if request.dbsession.query(models.Page).filter_by(name=pagename).count() > 0: diff --git a/docs/tutorials/wiki2/src/views/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/views/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/views/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/views/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 585fb508bc08f517ce296b115b3e1d20241f1fab Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:31:33 -0800 Subject: Update authentication src files --- docs/tutorials/wiki2/src/authentication/development.ini | 7 ++++++- docs/tutorials/wiki2/src/authentication/production.ini | 7 ++++++- docs/tutorials/wiki2/src/authentication/setup.py | 4 ++-- docs/tutorials/wiki2/src/authentication/tutorial/__init__.py | 2 +- .../wiki2/src/authentication/tutorial/alembic/script.py.mako | 2 -- .../wiki2/src/authentication/tutorial/alembic/versions/README.txt | 2 +- docs/tutorials/wiki2/src/authentication/tutorial/pshell.py | 1 + .../wiki2/src/authentication/tutorial/templates/404.jinja2 | 2 +- docs/tutorials/wiki2/src/authentication/tutorial/tests.py | 3 ++- docs/tutorials/wiki2/src/authentication/tutorial/views/default.py | 6 +++--- docs/tutorials/wiki2/src/authentication/tutorial/views/notfound.py | 2 +- 11 files changed, 24 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/src/authentication/development.ini b/docs/tutorials/wiki2/src/authentication/development.ini index 8fbb5fd38..7fda4cb7b 100644 --- a/docs/tutorials/wiki2/src/authentication/development.ini +++ b/docs/tutorials/wiki2/src/authentication/development.ini @@ -47,7 +47,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -72,6 +72,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/authentication/production.ini b/docs/tutorials/wiki2/src/authentication/production.ini index 9fef64f83..8e878a707 100644 --- a/docs/tutorials/wiki2/src/authentication/production.ini +++ b/docs/tutorials/wiki2/src/authentication/production.ini @@ -41,7 +41,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -66,6 +66,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/authentication/setup.py b/docs/tutorials/wiki2/src/authentication/setup.py index f71998afc..a99793c15 100644 --- a/docs/tutorials/wiki2/src/authentication/setup.py +++ b/docs/tutorials/wiki2/src/authentication/setup.py @@ -13,7 +13,7 @@ requires = [ 'bcrypt', 'docutils', 'plaster_pastedeploy', - 'pyramid >= 1.9', + 'pyramid', 'pyramid_debugtoolbar', 'pyramid_jinja2', 'pyramid_retry', @@ -57,7 +57,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/__init__.py b/docs/tutorials/wiki2/src/authentication/tutorial/__init__.py index 5d4bae3d7..ce2e9f12a 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/authentication/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.include('.security') config.scan() diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/authentication/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/authentication/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/authentication/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/authentication/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/pshell.py b/docs/tutorials/wiki2/src/authentication/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/authentication/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/authentication/tutorial/templates/404.jinja2 index 37b0a16b6..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/authentication/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid tutorial wiki (based on TurboGears 20-Minute Wiki)

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/tests.py b/docs/tutorials/wiki2/src/authentication/tutorial/tests.py index ce650ca7c..47990669e 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/authentication/tutorial/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/views/default.py b/docs/tutorials/wiki2/src/authentication/tutorial/views/default.py index 2f0210255..d1c429950 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/authentication/tutorial/views/default.py @@ -20,7 +20,7 @@ def view_wiki(request): next_url = request.route_url('view_page', pagename='FrontPage') return HTTPFound(location=next_url) -@view_config(route_name='view_page', renderer='../templates/view.jinja2') +@view_config(route_name='view_page', renderer='tutorial:templates/view.jinja2') def view_page(request): pagename = request.matchdict['pagename'] page = request.dbsession.query(models.Page).filter_by(name=pagename).first() @@ -42,7 +42,7 @@ def view_page(request): edit_url = request.route_url('edit_page', pagename=page.name) return dict(page=page, content=content, edit_url=edit_url) -@view_config(route_name='edit_page', renderer='../templates/edit.jinja2') +@view_config(route_name='edit_page', renderer='tutorial:templates/edit.jinja2') def edit_page(request): pagename = request.matchdict['pagename'] page = request.dbsession.query(models.Page).filter_by(name=pagename).one() @@ -59,7 +59,7 @@ def edit_page(request): save_url=request.route_url('edit_page', pagename=page.name), ) -@view_config(route_name='add_page', renderer='../templates/edit.jinja2') +@view_config(route_name='add_page', renderer='tutorial:templates/edit.jinja2') def add_page(request): user = request.user if user is None or user.role not in ('editor', 'basic'): diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/authentication/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/authentication/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From ccf632a1ff478c0bd6db0ab1ab6d9695018aa564 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:38:13 -0800 Subject: Update authorization src files --- docs/tutorials/wiki2/src/authorization/development.ini | 7 ++++++- docs/tutorials/wiki2/src/authorization/production.ini | 7 ++++++- docs/tutorials/wiki2/src/authorization/setup.py | 4 ++-- docs/tutorials/wiki2/src/authorization/tutorial/__init__.py | 2 +- .../wiki2/src/authorization/tutorial/alembic/script.py.mako | 2 -- .../wiki2/src/authorization/tutorial/alembic/versions/README.txt | 2 +- docs/tutorials/wiki2/src/authorization/tutorial/pshell.py | 1 + .../wiki2/src/authorization/tutorial/templates/404.jinja2 | 2 +- docs/tutorials/wiki2/src/authorization/tutorial/tests.py | 3 ++- docs/tutorials/wiki2/src/authorization/tutorial/views/default.py | 6 +++--- docs/tutorials/wiki2/src/authorization/tutorial/views/notfound.py | 2 +- 11 files changed, 24 insertions(+), 14 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/src/authorization/development.ini b/docs/tutorials/wiki2/src/authorization/development.ini index 8fbb5fd38..7fda4cb7b 100644 --- a/docs/tutorials/wiki2/src/authorization/development.ini +++ b/docs/tutorials/wiki2/src/authorization/development.ini @@ -47,7 +47,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -72,6 +72,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/authorization/production.ini b/docs/tutorials/wiki2/src/authorization/production.ini index 9fef64f83..8e878a707 100644 --- a/docs/tutorials/wiki2/src/authorization/production.ini +++ b/docs/tutorials/wiki2/src/authorization/production.ini @@ -41,7 +41,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -66,6 +66,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/authorization/setup.py b/docs/tutorials/wiki2/src/authorization/setup.py index f71998afc..a99793c15 100644 --- a/docs/tutorials/wiki2/src/authorization/setup.py +++ b/docs/tutorials/wiki2/src/authorization/setup.py @@ -13,7 +13,7 @@ requires = [ 'bcrypt', 'docutils', 'plaster_pastedeploy', - 'pyramid >= 1.9', + 'pyramid', 'pyramid_debugtoolbar', 'pyramid_jinja2', 'pyramid_retry', @@ -57,7 +57,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py b/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py index 5d4bae3d7..ce2e9f12a 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.include('.security') config.scan() diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/authorization/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/authorization/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/authorization/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/authorization/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/pshell.py b/docs/tutorials/wiki2/src/authorization/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/authorization/tutorial/templates/404.jinja2 index 37b0a16b6..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/authorization/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid tutorial wiki (based on TurboGears 20-Minute Wiki)

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py index ce650ca7c..47990669e 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py @@ -1,8 +1,9 @@ import unittest -import transaction from pyramid import testing +import transaction + def dummy_request(dbsession): return testing.DummyRequest(dbsession=dbsession) diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/views/default.py b/docs/tutorials/wiki2/src/authorization/tutorial/views/default.py index ad8491b7b..de0bcd816 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/views/default.py @@ -15,7 +15,7 @@ def view_wiki(request): next_url = request.route_url('view_page', pagename='FrontPage') return HTTPFound(location=next_url) -@view_config(route_name='view_page', renderer='../templates/view.jinja2', +@view_config(route_name='view_page', renderer='tutorial:templates/view.jinja2', permission='view') def view_page(request): page = request.context.page @@ -35,7 +35,7 @@ def view_page(request): edit_url = request.route_url('edit_page', pagename=page.name) return dict(page=page, content=content, edit_url=edit_url) -@view_config(route_name='edit_page', renderer='../templates/edit.jinja2', +@view_config(route_name='edit_page', renderer='tutorial:templates/edit.jinja2', permission='edit') def edit_page(request): page = request.context.page @@ -49,7 +49,7 @@ def edit_page(request): save_url=request.route_url('edit_page', pagename=page.name), ) -@view_config(route_name='add_page', renderer='../templates/edit.jinja2', +@view_config(route_name='add_page', renderer='tutorial:templates/edit.jinja2', permission='create') def add_page(request): pagename = request.context.pagename diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/authorization/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From bfde9a92438fe4c34742d1114d144658aad7ad25 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:40:49 -0800 Subject: Update tests src files --- docs/tutorials/wiki2/src/tests/development.ini | 7 ++++++- docs/tutorials/wiki2/src/tests/production.ini | 7 ++++++- docs/tutorials/wiki2/src/tests/setup.py | 4 ++-- docs/tutorials/wiki2/src/tests/tutorial/__init__.py | 2 +- docs/tutorials/wiki2/src/tests/tutorial/alembic/script.py.mako | 2 -- .../tutorials/wiki2/src/tests/tutorial/alembic/versions/README.txt | 2 +- docs/tutorials/wiki2/src/tests/tutorial/pshell.py | 1 + docs/tutorials/wiki2/src/tests/tutorial/templates/404.jinja2 | 2 +- docs/tutorials/wiki2/src/tests/tutorial/views/default.py | 6 +++--- docs/tutorials/wiki2/src/tests/tutorial/views/notfound.py | 2 +- 10 files changed, 22 insertions(+), 13 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/src/tests/development.ini b/docs/tutorials/wiki2/src/tests/development.ini index 8fbb5fd38..7fda4cb7b 100644 --- a/docs/tutorials/wiki2/src/tests/development.ini +++ b/docs/tutorials/wiki2/src/tests/development.ini @@ -47,7 +47,7 @@ listen = localhost:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -72,6 +72,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = INFO +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/tests/production.ini b/docs/tutorials/wiki2/src/tests/production.ini index 9fef64f83..8e878a707 100644 --- a/docs/tutorials/wiki2/src/tests/production.ini +++ b/docs/tutorials/wiki2/src/tests/production.ini @@ -41,7 +41,7 @@ listen = *:6543 ### [loggers] -keys = root, tutorial, sqlalchemy +keys = root, tutorial, sqlalchemy, alembic [handlers] keys = console @@ -66,6 +66,11 @@ qualname = sqlalchemy.engine # "level = DEBUG" logs SQL queries and results. # "level = WARN" logs neither. (Recommended for production systems.) +[logger_alembic] +level = WARN +handlers = +qualname = alembic + [handler_console] class = StreamHandler args = (sys.stderr,) diff --git a/docs/tutorials/wiki2/src/tests/setup.py b/docs/tutorials/wiki2/src/tests/setup.py index f71998afc..a99793c15 100644 --- a/docs/tutorials/wiki2/src/tests/setup.py +++ b/docs/tutorials/wiki2/src/tests/setup.py @@ -13,7 +13,7 @@ requires = [ 'bcrypt', 'docutils', 'plaster_pastedeploy', - 'pyramid >= 1.9', + 'pyramid', 'pyramid_debugtoolbar', 'pyramid_jinja2', 'pyramid_retry', @@ -57,7 +57,7 @@ setup( 'main = tutorial:main', ], 'console_scripts': [ - 'initialize_tutorial_db = tutorial.scripts.initialize_db:main', + 'initialize_tutorial_db=tutorial.scripts.initialize_db:main', ], }, ) diff --git a/docs/tutorials/wiki2/src/tests/tutorial/__init__.py b/docs/tutorials/wiki2/src/tests/tutorial/__init__.py index 5d4bae3d7..ce2e9f12a 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/__init__.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/__init__.py @@ -5,8 +5,8 @@ def main(global_config, **settings): """ This function returns a Pyramid WSGI application. """ with Configurator(settings=settings) as config: - config.include('pyramid_jinja2') config.include('.models') + config.include('pyramid_jinja2') config.include('.routes') config.include('.security') config.scan() diff --git a/docs/tutorials/wiki2/src/tests/tutorial/alembic/script.py.mako b/docs/tutorials/wiki2/src/tests/tutorial/alembic/script.py.mako index 2c0156303..535780d13 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/alembic/script.py.mako +++ b/docs/tutorials/wiki2/src/tests/tutorial/alembic/script.py.mako @@ -15,10 +15,8 @@ down_revision = ${repr(down_revision)} branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} - def upgrade(): ${upgrades if upgrades else "pass"} - def downgrade(): ${downgrades if downgrades else "pass"} diff --git a/docs/tutorials/wiki2/src/tests/tutorial/alembic/versions/README.txt b/docs/tutorials/wiki2/src/tests/tutorial/alembic/versions/README.txt index 09ed32c8d..b0d704d6a 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/alembic/versions/README.txt +++ b/docs/tutorials/wiki2/src/tests/tutorial/alembic/versions/README.txt @@ -1 +1 @@ -Placeholder for alembic versions \ No newline at end of file +Placeholder for alembic versions diff --git a/docs/tutorials/wiki2/src/tests/tutorial/pshell.py b/docs/tutorials/wiki2/src/tests/tutorial/pshell.py index 108c04d5e..b0847ee90 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/pshell.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/pshell.py @@ -1,5 +1,6 @@ from . import models + def setup(env): request = env['request'] diff --git a/docs/tutorials/wiki2/src/tests/tutorial/templates/404.jinja2 b/docs/tutorials/wiki2/src/tests/tutorial/templates/404.jinja2 index 37b0a16b6..aaf12413f 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/templates/404.jinja2 +++ b/docs/tutorials/wiki2/src/tests/tutorial/templates/404.jinja2 @@ -2,7 +2,7 @@ {% block content %}
-

Pyramid tutorial wiki (based on TurboGears 20-Minute Wiki)

+

Pyramid Starter project

404 Page Not Found

{% endblock content %} diff --git a/docs/tutorials/wiki2/src/tests/tutorial/views/default.py b/docs/tutorials/wiki2/src/tests/tutorial/views/default.py index ad8491b7b..de0bcd816 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/views/default.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/views/default.py @@ -15,7 +15,7 @@ def view_wiki(request): next_url = request.route_url('view_page', pagename='FrontPage') return HTTPFound(location=next_url) -@view_config(route_name='view_page', renderer='../templates/view.jinja2', +@view_config(route_name='view_page', renderer='tutorial:templates/view.jinja2', permission='view') def view_page(request): page = request.context.page @@ -35,7 +35,7 @@ def view_page(request): edit_url = request.route_url('edit_page', pagename=page.name) return dict(page=page, content=content, edit_url=edit_url) -@view_config(route_name='edit_page', renderer='../templates/edit.jinja2', +@view_config(route_name='edit_page', renderer='tutorial:templates/edit.jinja2', permission='edit') def edit_page(request): page = request.context.page @@ -49,7 +49,7 @@ def edit_page(request): save_url=request.route_url('edit_page', pagename=page.name), ) -@view_config(route_name='add_page', renderer='../templates/edit.jinja2', +@view_config(route_name='add_page', renderer='tutorial:templates/edit.jinja2', permission='create') def add_page(request): pagename = request.context.pagename diff --git a/docs/tutorials/wiki2/src/tests/tutorial/views/notfound.py b/docs/tutorials/wiki2/src/tests/tutorial/views/notfound.py index 69d6e2804..740712d9f 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/views/notfound.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/views/notfound.py @@ -1,7 +1,7 @@ from pyramid.view import notfound_view_config -@notfound_view_config(renderer='../templates/404.jinja2') +@notfound_view_config(renderer='tutorial:templates/404.jinja2') def notfound_view(request): request.response.status = 404 return {} -- cgit v1.2.3 From 48ad0860bee87c71cddea76de841dd91a16cd0fe Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:49:14 -0800 Subject: Unwrap paragraph to one line per sentence --- docs/narr/paste.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/narr/paste.rst b/docs/narr/paste.rst index fe2846dd3..e198176d4 100644 --- a/docs/narr/paste.rst +++ b/docs/narr/paste.rst @@ -95,4 +95,6 @@ application's ``main`` function as ``global_config`` (see the reference to the Alternative Configuration File Formats -------------------------------------- -It is possible to use different file formats with :app:`Pyramid` if you do not like :term:`PasteDeploy`. Under the hood all command-line scripts such as ``pserve`` and ``pshell`` pass the ``config_uri`` (e.g. ``development.ini`` or ``production.ini``) to the :term:`plaster` library which performs a lookup for an appropriate parser. For ``.ini`` files it uses PasteDeploy but you can register your own configuration formats that plaster will find instead. +It is possible to use different file formats with :app:`Pyramid` if you do not like :term:`PasteDeploy`. +Under the hood all command-line scripts such as ``pserve`` and ``pshell`` pass the ``config_uri`` (e.g., ``development.ini`` or ``production.ini``) to the :term:`plaster` library which performs a lookup for an appropriate parser. +For ``.ini`` files it uses PasteDeploy but you can register your own configuration formats that plaster will find instead. -- cgit v1.2.3 From 4ca67df229426972ff9a785abc060b4a33dfe953 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 02:57:30 -0800 Subject: Update reference to tests in testing.rst --- docs/narr/testing.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/narr/testing.rst b/docs/narr/testing.rst index 2182082a8..ec2d1fad1 100644 --- a/docs/narr/testing.rst +++ b/docs/narr/testing.rst @@ -411,9 +411,8 @@ The following example functional test demonstrates invoking the above :pyobject: FunctionalTests :language: python -When this test is run, each test method creates a "real" :term:`WSGI` -application using the ``main`` function in your ``myproject.__init__`` module, -using :term:`WebTest` to wrap that WSGI application. It assigns the result to +When these tests are run, each test method creates a "real" :term:`WSGI` application using the ``main`` function in your ``myproject.__init__`` module, using :term:`WebTest` to wrap that WSGI application. +It assigns the result to ``self.testapp``. In the test named ``test_root``, the ``TestApp``'s ``GET`` method is used to invoke the root URL. Finally, an assertion is made that the returned HTML contains the text ``Pyramid``. -- cgit v1.2.3 From 8b2bb44114e3a724d66035e76051a6910e14657e Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sat, 28 Dec 2019 03:03:43 -0800 Subject: Fix heading levels --- docs/tutorials/wiki2/definingmodels.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/definingmodels.rst b/docs/tutorials/wiki2/definingmodels.rst index 516fd66cf..4b80e09ac 100644 --- a/docs/tutorials/wiki2/definingmodels.rst +++ b/docs/tutorials/wiki2/definingmodels.rst @@ -256,14 +256,14 @@ Populating the database Because our model has changed, and to repopulate the database, we need to rerun the ``initialize_tutorial_db`` command to pick up the changes we've made to the ``initialize_db.py`` file. On Unix -^^^^^^^ +------- .. code-block:: bash $VENV/bin/initialize_tutorial_db development.ini On Windows -^^^^^^^^^^ +---------- .. code-block:: doscon -- cgit v1.2.3 From 80e9923262fee4892a750d0d6366b193cb4204ba Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 17:40:46 -0800 Subject: Resync through Quick Tour after moving tests directory --- docs/quick_tour.rst | 52 ++++++++++++----------- docs/quick_tour/logging/MANIFEST.in | 3 ++ docs/quick_tour/logging/pytest.ini | 2 +- docs/quick_tour/logging/tests/__init__.py | 0 docs/quick_tour/logging/tests/test_it.py | 39 +++++++++++++++++ docs/quick_tour/package/MANIFEST.in | 3 ++ docs/quick_tour/package/pytest.ini | 2 +- docs/quick_tour/package/tests/__init__.py | 0 docs/quick_tour/package/tests/test_it.py | 39 +++++++++++++++++ docs/quick_tour/sessions/MANIFEST.in | 3 ++ docs/quick_tour/sessions/pytest.ini | 2 +- docs/quick_tour/sessions/tests/__init__.py | 0 docs/quick_tour/sessions/tests/test_it.py | 39 +++++++++++++++++ docs/quick_tour/sqla_demo/MANIFEST.in | 3 ++ docs/quick_tour/sqla_demo/pytest.ini | 7 ++- docs/quick_tour/sqla_demo/tests/__init__.py | 0 docs/quick_tour/sqla_demo/tests/test_it.py | 66 +++++++++++++++++++++++++++++ 17 files changed, 230 insertions(+), 30 deletions(-) create mode 100644 docs/quick_tour/logging/tests/__init__.py create mode 100644 docs/quick_tour/logging/tests/test_it.py create mode 100644 docs/quick_tour/package/tests/__init__.py create mode 100644 docs/quick_tour/package/tests/test_it.py create mode 100644 docs/quick_tour/sessions/tests/__init__.py create mode 100644 docs/quick_tour/sessions/tests/test_it.py create mode 100644 docs/quick_tour/sqla_demo/tests/__init__.py create mode 100644 docs/quick_tour/sqla_demo/tests/test_it.py (limited to 'docs') diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index e6914337f..b6e456d2b 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -676,15 +676,15 @@ the relevant ``.ini`` configuration file. :ref:`Quick Tutorial pyramid_debugtoolbar ` and :ref:`pyramid_debugtoolbar ` -Unit tests and ``pytest`` -========================= +Unit and functional tests and ``pytest`` +======================================== Yikes! We got this far and we haven't yet discussed tests. This is particularly egregious, as Pyramid has had a deep commitment to full test coverage since before its release. -Our ``pyramid-cookiecutter-starter`` cookiecutter generated a ``tests.py`` module with -one unit test and one functional test in it. It also configured ``setup.py`` with test requirements: +Our ``pyramid-cookiecutter-starter`` cookiecutter generated a ``test_it.py`` module inside the ``tests`` package with two unit tests and two functional tests in it. +It also configured ``setup.py`` with test requirements: ``pytest`` as the test runner, ``WebTest`` for running view tests, and the ``pytest-cov`` tool which yells at us for code that isn't tested: @@ -709,33 +709,35 @@ This yields the following output. .. code-block:: text =========================== test session starts =========================== - platform darwin -- Python 3.6.0, pytest-3.0.5, py-1.4.32, pluggy-0.4.0 - rootdir: /Users/stevepiercy/hello_world, inifile: pytest.ini - plugins: cov-2.4.0 - collected 2 items - - hello_world/tests.py .. - - ------------- coverage: platform darwin, python 3.6.0-final-0 ------------- - Name Stmts Miss Cover Missing - ----------------------------------------------------------------------- - hello_world/__init__.py 8 0 100% - hello_world/views.py 3 0 100% - ----------------------------------------------------------------------- - TOTAL 11 0 100% - - - ========================= 2 passed in 1.37 seconds ========================= + platform darwin -- Python 3.7.3, pytest-5.3.2, py-1.8.1, pluggy-0.13.1 + rootdir: //hello_world, inifile: pytest.ini, testpaths: hello_world, tests + plugins: cov-2.8.1 + collected 4 items + + tests/test_it.py .... [100%] + + ---------- coverage: platform darwin, python 3.7.3-final-0 ----------- + Name Stmts Miss Cover Missing + ------------------------------------------------------------- + hello_world/__init__.py 7 0 100% + hello_world/routes.py 3 0 100% + hello_world/views/__init__.py 0 0 100% + hello_world/views/default.py 3 0 100% + hello_world/views/notfound.py 4 0 100% + ------------------------------------------------------------- + TOTAL 17 0 100% + + ======================== 4 passed in 0.65 seconds ========================= Our tests passed, and its coverage is complete. What did our test look like? -.. literalinclude:: quick_tour/package/hello_world/tests.py +.. literalinclude:: quick_tour/package/hello_world/tests/test_it.py :language: python :linenos: -Pyramid supplies helpers for test writing, which we use in the test setup and -teardown. Our first test imports the view, makes a dummy request, and sees if the -view returns what we expected. Our second test verifies that the response body from a request to the web root contains what we expected. +Pyramid supplies helpers for test writing, which we use in the test setup and teardown. +Our view tests import the view, make a dummy request, and sees if the view returns what we expected. +Our functional tests verify that the response body from a request to the web root contains what we expected and that the expected response code for making a request to ``/badurl`` results in ``404``. .. seealso:: See also: :ref:`Quick Tutorial Unit Testing `, :ref:`Quick diff --git a/docs/quick_tour/logging/MANIFEST.in b/docs/quick_tour/logging/MANIFEST.in index a75da6dad..7a73762f7 100644 --- a/docs/quick_tour/logging/MANIFEST.in +++ b/docs/quick_tour/logging/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/logging/pytest.ini b/docs/quick_tour/logging/pytest.ini index b419855e1..f707d54e4 100644 --- a/docs/quick_tour/logging/pytest.ini +++ b/docs/quick_tour/logging/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = hello_world -python_files = test*.py +python_files = *.py diff --git a/docs/quick_tour/logging/tests/__init__.py b/docs/quick_tour/logging/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/quick_tour/logging/tests/test_it.py b/docs/quick_tour/logging/tests/test_it.py new file mode 100644 index 000000000..90c6302fe --- /dev/null +++ b/docs/quick_tour/logging/tests/test_it.py @@ -0,0 +1,39 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from hello_world.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'hello_world') + + def test_notfound_view(self): + from hello_world.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + + +class FunctionalTests(unittest.TestCase): + def setUp(self): + from hello_world import main + app = main({}) + from webtest import TestApp + self.testapp = TestApp(app) + + def test_root(self): + res = self.testapp.get('/', status=200) + self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/package/MANIFEST.in b/docs/quick_tour/package/MANIFEST.in index a75da6dad..7a73762f7 100644 --- a/docs/quick_tour/package/MANIFEST.in +++ b/docs/quick_tour/package/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/package/pytest.ini b/docs/quick_tour/package/pytest.ini index b419855e1..f707d54e4 100644 --- a/docs/quick_tour/package/pytest.ini +++ b/docs/quick_tour/package/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = hello_world -python_files = test*.py +python_files = *.py diff --git a/docs/quick_tour/package/tests/__init__.py b/docs/quick_tour/package/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/quick_tour/package/tests/test_it.py b/docs/quick_tour/package/tests/test_it.py new file mode 100644 index 000000000..90c6302fe --- /dev/null +++ b/docs/quick_tour/package/tests/test_it.py @@ -0,0 +1,39 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from hello_world.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'hello_world') + + def test_notfound_view(self): + from hello_world.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + + +class FunctionalTests(unittest.TestCase): + def setUp(self): + from hello_world import main + app = main({}) + from webtest import TestApp + self.testapp = TestApp(app) + + def test_root(self): + res = self.testapp.get('/', status=200) + self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sessions/MANIFEST.in b/docs/quick_tour/sessions/MANIFEST.in index a75da6dad..7a73762f7 100644 --- a/docs/quick_tour/sessions/MANIFEST.in +++ b/docs/quick_tour/sessions/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include hello_world *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/sessions/pytest.ini b/docs/quick_tour/sessions/pytest.ini index b419855e1..f707d54e4 100644 --- a/docs/quick_tour/sessions/pytest.ini +++ b/docs/quick_tour/sessions/pytest.ini @@ -1,3 +1,3 @@ [pytest] testpaths = hello_world -python_files = test*.py +python_files = *.py diff --git a/docs/quick_tour/sessions/tests/__init__.py b/docs/quick_tour/sessions/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/quick_tour/sessions/tests/test_it.py b/docs/quick_tour/sessions/tests/test_it.py new file mode 100644 index 000000000..90c6302fe --- /dev/null +++ b/docs/quick_tour/sessions/tests/test_it.py @@ -0,0 +1,39 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from hello_world.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'hello_world') + + def test_notfound_view(self): + from hello_world.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + + +class FunctionalTests(unittest.TestCase): + def setUp(self): + from hello_world import main + app = main({}) + from webtest import TestApp + self.testapp = TestApp(app) + + def test_root(self): + res = self.testapp.get('/', status=200) + self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sqla_demo/MANIFEST.in b/docs/quick_tour/sqla_demo/MANIFEST.in index e079655f9..13a26726d 100644 --- a/docs/quick_tour/sqla_demo/MANIFEST.in +++ b/docs/quick_tour/sqla_demo/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include sqla_demo *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tour/sqla_demo/pytest.ini b/docs/quick_tour/sqla_demo/pytest.ini index b4b690a0f..e7fd17682 100644 --- a/docs/quick_tour/sqla_demo/pytest.ini +++ b/docs/quick_tour/sqla_demo/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = sqla_demo -python_files = test*.py +addopts = --strict + +testpaths = + sqla_demo + tests diff --git a/docs/quick_tour/sqla_demo/tests/__init__.py b/docs/quick_tour/sqla_demo/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/quick_tour/sqla_demo/tests/test_it.py b/docs/quick_tour/sqla_demo/tests/test_it.py new file mode 100644 index 000000000..c79e05022 --- /dev/null +++ b/docs/quick_tour/sqla_demo/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('sqla_demo.models') + settings = self.config.get_settings() + + from sqla_demo.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from sqla_demo.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from sqla_demo.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from sqla_demo.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from sqla_demo.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'sqla_demo') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from sqla_demo.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) -- cgit v1.2.3 From 3157775a08ff9e48b0fff8057f4482d78d266f01 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 18:16:30 -0800 Subject: Resync through Quick Tour after moving tests directory, removing tests.py file --- docs/quick_tour/logging/hello_world/tests.py | 39 ---------------- docs/quick_tour/package/hello_world/tests.py | 39 ---------------- docs/quick_tour/sessions/hello_world/tests.py | 39 ---------------- docs/quick_tour/sqla_demo/sqla_demo/tests.py | 66 --------------------------- 4 files changed, 183 deletions(-) delete mode 100644 docs/quick_tour/logging/hello_world/tests.py delete mode 100644 docs/quick_tour/package/hello_world/tests.py delete mode 100644 docs/quick_tour/sessions/hello_world/tests.py delete mode 100644 docs/quick_tour/sqla_demo/sqla_demo/tests.py (limited to 'docs') diff --git a/docs/quick_tour/logging/hello_world/tests.py b/docs/quick_tour/logging/hello_world/tests.py deleted file mode 100644 index b747e7679..000000000 --- a/docs/quick_tour/logging/hello_world/tests.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'hello_world') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - - -class FunctionalTests(unittest.TestCase): - def setUp(self): - from hello_world import main - app = main({}) - from webtest import TestApp - self.testapp = TestApp(app) - - def test_root(self): - res = self.testapp.get('/', status=200) - self.assertTrue(b'Pyramid' in res.body) - - def test_notfound(self): - res = self.testapp.get('/badurl', status=404) - self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/package/hello_world/tests.py b/docs/quick_tour/package/hello_world/tests.py deleted file mode 100644 index b747e7679..000000000 --- a/docs/quick_tour/package/hello_world/tests.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'hello_world') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - - -class FunctionalTests(unittest.TestCase): - def setUp(self): - from hello_world import main - app = main({}) - from webtest import TestApp - self.testapp = TestApp(app) - - def test_root(self): - res = self.testapp.get('/', status=200) - self.assertTrue(b'Pyramid' in res.body) - - def test_notfound(self): - res = self.testapp.get('/badurl', status=404) - self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sessions/hello_world/tests.py b/docs/quick_tour/sessions/hello_world/tests.py deleted file mode 100644 index b747e7679..000000000 --- a/docs/quick_tour/sessions/hello_world/tests.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'hello_world') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - - -class FunctionalTests(unittest.TestCase): - def setUp(self): - from hello_world import main - app = main({}) - from webtest import TestApp - self.testapp = TestApp(app) - - def test_root(self): - res = self.testapp.get('/', status=200) - self.assertTrue(b'Pyramid' in res.body) - - def test_notfound(self): - res = self.testapp.get('/badurl', status=404) - self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tour/sqla_demo/sqla_demo/tests.py b/docs/quick_tour/sqla_demo/sqla_demo/tests.py deleted file mode 100644 index df9b58780..000000000 --- a/docs/quick_tour/sqla_demo/sqla_demo/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'sqla_demo') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) -- cgit v1.2.3 From dece4d25b136a493dfeeeb516487d4d756bc69e9 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 18:27:30 -0800 Subject: Resync through project.rst after moving tests directory --- docs/narr/myproject/MANIFEST.in | 3 ++ docs/narr/myproject/myproject/tests.py | 39 ---------------------- docs/narr/myproject/pytest.ini | 7 ++-- docs/narr/myproject/tests/__init__.py | 0 docs/narr/myproject/tests/test_it.py | 39 ++++++++++++++++++++++ docs/narr/project.rst | 61 ++++++++++++++++++---------------- 6 files changed, 79 insertions(+), 70 deletions(-) delete mode 100644 docs/narr/myproject/myproject/tests.py create mode 100644 docs/narr/myproject/tests/__init__.py create mode 100644 docs/narr/myproject/tests/test_it.py (limited to 'docs') diff --git a/docs/narr/myproject/MANIFEST.in b/docs/narr/myproject/MANIFEST.in index 1c24b8c0c..f516697f5 100644 --- a/docs/narr/myproject/MANIFEST.in +++ b/docs/narr/myproject/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include myproject *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/narr/myproject/myproject/tests.py b/docs/narr/myproject/myproject/tests.py deleted file mode 100644 index 48f0095ad..000000000 --- a/docs/narr/myproject/myproject/tests.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'myproject') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - - -class FunctionalTests(unittest.TestCase): - def setUp(self): - from myproject import main - app = main({}) - from webtest import TestApp - self.testapp = TestApp(app) - - def test_root(self): - res = self.testapp.get('/', status=200) - self.assertTrue(b'Pyramid' in res.body) - - def test_notfound(self): - res = self.testapp.get('/badurl', status=404) - self.assertTrue(res.status_code == 404) diff --git a/docs/narr/myproject/pytest.ini b/docs/narr/myproject/pytest.ini index 332cf0d04..5c8c59068 100644 --- a/docs/narr/myproject/pytest.ini +++ b/docs/narr/myproject/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = myproject -python_files = test*.py +addopts = --strict + +testpaths = + myproject + tests diff --git a/docs/narr/myproject/tests/__init__.py b/docs/narr/myproject/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/narr/myproject/tests/test_it.py b/docs/narr/myproject/tests/test_it.py new file mode 100644 index 000000000..b300da34d --- /dev/null +++ b/docs/narr/myproject/tests/test_it.py @@ -0,0 +1,39 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from myproject.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'myproject') + + def test_notfound_view(self): + from myproject.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + + +class FunctionalTests(unittest.TestCase): + def setUp(self): + from myproject import main + app = main({}) + from webtest import TestApp + self.testapp = TestApp(app) + + def test_root(self): + res = self.testapp.get('/', status=200) + self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) diff --git a/docs/narr/project.rst b/docs/narr/project.rst index e0f0be1f3..fc5cfd056 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -266,7 +266,8 @@ Here's sample output from a test run on Unix: .... 4 passed in 0.45 seconds -The tests themselves are found in the ``tests.py`` module in your ``cookiecutter``-generated project. Within this project generated by the ``pyramid-cookiecutter-starter`` cookiecutter, only a few sample tests exist. +The tests themselves are found in the ``test_it.py`` module in the ``tests`` package in your ``cookiecutter``-generated project. +Within this project generated by the ``pyramid-cookiecutter-starter`` cookiecutter, only a few sample tests exist. .. note:: @@ -288,7 +289,7 @@ path to the module on which we want to run tests and coverage. .. code-block:: bash - $VENV/bin/pytest --cov=myproject myproject/tests.py -q + $VENV/bin/pytest --cov=myproject myproject tests -q .. seealso:: See ``pytest``'s documentation for :ref:`pytest:usage` or invoke ``pytest -h`` to see its full set of options. @@ -535,6 +536,8 @@ The ``myproject`` project we've generated has the following directory structure: ├── .gitignore ├── CHANGES.txt ├── MANIFEST.in + ├── README.txt + ├── development.ini ├── myproject │   ├── __init__.py │   ├── routes.py @@ -546,16 +549,37 @@ The ``myproject`` project we've generated has the following directory structure: │   │   ├── 404.jinja2 │   │   ├── layout.jinja2 │   │   └── mytemplate.jinja2 - │   ├── tests.py │   └── views │   ├── __init__.py │   ├── default.py │   └── notfound.py - ├── README.txt - ├── development.ini ├── production.ini ├── pytest.ini - └── setup.py + ├── setup.py + └── tests + ├── __init__.py + └── test_it.py + + +.. index:: + single: tests + +``test_it.py`` +~~~~~~~~~~~~~~ + +The ``test_it.py`` module in the ``tests`` package includes tests for your application. + +.. literalinclude:: myproject/tests/test_it.py + :language: python + :linenos: + +This sample ``test_it.py`` file has two unit tests and two functional tests defined within it. +These tests are executed when you run ``pytest -q``. +You may add more tests here as you build your application. +You are not required to write tests to use :app:`Pyramid`. +This file is simply provided for convenience and example. + +See :ref:`testing_chapter` for more information about writing :app:`Pyramid` unit tests. The ``myproject`` :term:`Project` @@ -591,6 +615,8 @@ describe, run, and test your application. #. ``setup.py`` is the file you'll use to test and distribute your application. It is a standard :term:`Setuptools` ``setup.py`` file. +#. ``tests`` package which contains unit and functional test code for the application. + .. index:: single: PasteDeploy single: ini file @@ -819,8 +845,6 @@ The ``myproject`` :term:`package` lives inside the ``myproject`` #. A ``templates`` directory, which contains :term:`Jinja2` (or other types of) templates. -#. A ``tests.py`` module, which contains unit and functional test code for the application. - #. A ``routes.py`` module, which contains routing code for the application. #. A ``views`` package, which contains view code for the application. @@ -1040,27 +1064,6 @@ It inherits the HTML provided by ``layout.jinja2``, replacing the content block :linenos: -.. index:: - single: tests.py - -``tests.py`` -~~~~~~~~~~~~ - -The ``tests.py`` module includes tests for your application. - -.. literalinclude:: myproject/myproject/tests.py - :language: python - :linenos: - -This sample ``tests.py`` file has two unit tests and two functional tests defined -within it. These tests are executed when you run ``pytest -q``. You may add -more tests here as you build your application. You are not required to write -tests to use :app:`Pyramid`. This file is simply provided for convenience and -example. - -See :ref:`testing_chapter` for more information about writing :app:`Pyramid` -unit tests. - .. index:: pair: modifying; package structure -- cgit v1.2.3 From f2320a274a7168916aeb40cdbc094c4911e5e747 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 19:21:59 -0800 Subject: Resync quick_tutorial/cookiecutters.rst and related files after moving tests directory --- docs/quick_tutorial/cookiecutters/MANIFEST.in | 3 ++ .../cookiecutters/cc_starter/tests.py | 39 ---------------------- docs/quick_tutorial/cookiecutters/pytest.ini | 7 ++-- 3 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 docs/quick_tutorial/cookiecutters/cc_starter/tests.py (limited to 'docs') diff --git a/docs/quick_tutorial/cookiecutters/MANIFEST.in b/docs/quick_tutorial/cookiecutters/MANIFEST.in index 79c7ec16c..4071776f9 100644 --- a/docs/quick_tutorial/cookiecutters/MANIFEST.in +++ b/docs/quick_tutorial/cookiecutters/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include cc_starter *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py b/docs/quick_tutorial/cookiecutters/cc_starter/tests.py deleted file mode 100644 index 0891a3c51..000000000 --- a/docs/quick_tutorial/cookiecutters/cc_starter/tests.py +++ /dev/null @@ -1,39 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'cc_starter') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - - -class FunctionalTests(unittest.TestCase): - def setUp(self): - from cc_starter import main - app = main({}) - from webtest import TestApp - self.testapp = TestApp(app) - - def test_root(self): - res = self.testapp.get('/', status=200) - self.assertTrue(b'Pyramid' in res.body) - - def test_notfound(self): - res = self.testapp.get('/badurl', status=404) - self.assertTrue(res.status_code == 404) diff --git a/docs/quick_tutorial/cookiecutters/pytest.ini b/docs/quick_tutorial/cookiecutters/pytest.ini index 326c14fbc..515cc3cf0 100644 --- a/docs/quick_tutorial/cookiecutters/pytest.ini +++ b/docs/quick_tutorial/cookiecutters/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = cc_starter -python_files = test*.py +addopts = --strict + +testpaths = + cc_starter + tests -- cgit v1.2.3 From f929eace7ec1843712fb1831b834a7966330d43e Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 19:22:43 -0800 Subject: Resync quick_tutorial/cookiecutters.rst and related files after moving tests directory, including tests package --- .../quick_tutorial/cookiecutters/tests/__init__.py | 0 docs/quick_tutorial/cookiecutters/tests/test_it.py | 39 ++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docs/quick_tutorial/cookiecutters/tests/__init__.py create mode 100644 docs/quick_tutorial/cookiecutters/tests/test_it.py (limited to 'docs') diff --git a/docs/quick_tutorial/cookiecutters/tests/__init__.py b/docs/quick_tutorial/cookiecutters/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/quick_tutorial/cookiecutters/tests/test_it.py b/docs/quick_tutorial/cookiecutters/tests/test_it.py new file mode 100644 index 000000000..634abfdf2 --- /dev/null +++ b/docs/quick_tutorial/cookiecutters/tests/test_it.py @@ -0,0 +1,39 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from cc_starter.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'cc_starter') + + def test_notfound_view(self): + from cc_starter.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + + +class FunctionalTests(unittest.TestCase): + def setUp(self): + from cc_starter import main + app = main({}) + from webtest import TestApp + self.testapp = TestApp(app) + + def test_root(self): + res = self.testapp.get('/', status=200) + self.assertTrue(b'Pyramid' in res.body) + + def test_notfound(self): + res = self.testapp.get('/badurl', status=404) + self.assertTrue(res.status_code == 404) -- cgit v1.2.3 From dcdb9168aece7afd03194c11554d4a7e1bc32d06 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 19:59:29 -0800 Subject: Fix broken literalinclude paths --- docs/narr/testing.rst | 2 +- docs/quick_tour.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/narr/testing.rst b/docs/narr/testing.rst index ec2d1fad1..d89a4d3aa 100644 --- a/docs/narr/testing.rst +++ b/docs/narr/testing.rst @@ -406,7 +406,7 @@ function ``my_view`` that returns an HTML body when the root URL is invoked: The following example functional test demonstrates invoking the above :term:`view`: - .. literalinclude:: myproject/myproject/tests.py + .. literalinclude:: myproject/tests/test_it.py :linenos: :pyobject: FunctionalTests :language: python diff --git a/docs/quick_tour.rst b/docs/quick_tour.rst index b6e456d2b..062693d24 100644 --- a/docs/quick_tour.rst +++ b/docs/quick_tour.rst @@ -731,7 +731,7 @@ This yields the following output. Our tests passed, and its coverage is complete. What did our test look like? -.. literalinclude:: quick_tour/package/hello_world/tests/test_it.py +.. literalinclude:: quick_tour/package/tests/test_it.py :language: python :linenos: -- cgit v1.2.3 From 6175ff659c2523974072b404636911ebb89c2d42 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 20:15:20 -0800 Subject: Resync wiki/*.rst and related files after moving tests directory --- docs/tutorials/wiki/installation.rst | 4 +- docs/tutorials/wiki/src/authorization/MANIFEST.in | 3 + docs/tutorials/wiki/src/authorization/pytest.ini | 7 +- .../wiki/src/authorization/tests/__init__.py | 0 .../wiki/src/authorization/tests/test_it.py | 24 +++ .../wiki/src/authorization/tutorial/tests.py | 24 --- docs/tutorials/wiki/src/basiclayout/MANIFEST.in | 3 + docs/tutorials/wiki/src/basiclayout/pytest.ini | 7 +- .../wiki/src/basiclayout/tests/__init__.py | 0 .../wiki/src/basiclayout/tests/test_it.py | 24 +++ .../wiki/src/basiclayout/tutorial/tests.py | 24 --- docs/tutorials/wiki/src/installation/MANIFEST.in | 3 + docs/tutorials/wiki/src/installation/pytest.ini | 7 +- .../wiki/src/installation/tests/__init__.py | 0 .../wiki/src/installation/tests/test_it.py | 24 +++ .../wiki/src/installation/tutorial/tests.py | 24 --- docs/tutorials/wiki/src/models/MANIFEST.in | 3 + docs/tutorials/wiki/src/models/pytest.ini | 7 +- docs/tutorials/wiki/src/models/tests/__init__.py | 0 docs/tutorials/wiki/src/models/tests/test_it.py | 24 +++ docs/tutorials/wiki/src/models/tutorial/tests.py | 24 --- docs/tutorials/wiki/src/tests/MANIFEST.in | 3 + docs/tutorials/wiki/src/tests/pytest.ini | 7 +- docs/tutorials/wiki/src/tests/tests/__init__.py | 0 docs/tutorials/wiki/src/tests/tests/test_it.py | 232 +++++++++++++++++++++ docs/tutorials/wiki/src/tests/tutorial/tests.py | 232 --------------------- docs/tutorials/wiki/src/views/MANIFEST.in | 3 + docs/tutorials/wiki/src/views/pytest.ini | 7 +- docs/tutorials/wiki/src/views/tests/__init__.py | 0 docs/tutorials/wiki/src/views/tests/test_it.py | 24 +++ docs/tutorials/wiki/src/views/tutorial/tests.py | 24 --- docs/tutorials/wiki/tests.rst | 16 +- 32 files changed, 410 insertions(+), 374 deletions(-) create mode 100644 docs/tutorials/wiki/src/authorization/tests/__init__.py create mode 100644 docs/tutorials/wiki/src/authorization/tests/test_it.py delete mode 100644 docs/tutorials/wiki/src/authorization/tutorial/tests.py create mode 100644 docs/tutorials/wiki/src/basiclayout/tests/__init__.py create mode 100644 docs/tutorials/wiki/src/basiclayout/tests/test_it.py delete mode 100644 docs/tutorials/wiki/src/basiclayout/tutorial/tests.py create mode 100644 docs/tutorials/wiki/src/installation/tests/__init__.py create mode 100644 docs/tutorials/wiki/src/installation/tests/test_it.py delete mode 100644 docs/tutorials/wiki/src/installation/tutorial/tests.py create mode 100644 docs/tutorials/wiki/src/models/tests/__init__.py create mode 100644 docs/tutorials/wiki/src/models/tests/test_it.py delete mode 100644 docs/tutorials/wiki/src/models/tutorial/tests.py create mode 100644 docs/tutorials/wiki/src/tests/tests/__init__.py create mode 100644 docs/tutorials/wiki/src/tests/tests/test_it.py delete mode 100644 docs/tutorials/wiki/src/tests/tutorial/tests.py create mode 100644 docs/tutorials/wiki/src/views/tests/__init__.py create mode 100644 docs/tutorials/wiki/src/views/tests/test_it.py delete mode 100644 docs/tutorials/wiki/src/views/tutorial/tests.py (limited to 'docs') diff --git a/docs/tutorials/wiki/installation.rst b/docs/tutorials/wiki/installation.rst index 7c21ec02c..6088f577d 100644 --- a/docs/tutorials/wiki/installation.rst +++ b/docs/tutorials/wiki/installation.rst @@ -317,14 +317,14 @@ On Unix .. code-block:: bash - $VENV/bin/pytest --cov=tutorial tutorial/tests.py -q + $VENV/bin/pytest --cov=tutorial tests.py -q On Windows ^^^^^^^^^^ .. code-block:: doscon - %VENV%\Scripts\pytest --cov=tutorial tutorial\tests.py -q + %VENV%\Scripts\pytest --cov=tutorial tests -q ``pytest`` follows :ref:`conventions for Python test discovery `. diff --git a/docs/tutorials/wiki/src/authorization/MANIFEST.in b/docs/tutorials/wiki/src/authorization/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki/src/authorization/MANIFEST.in +++ b/docs/tutorials/wiki/src/authorization/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki/src/authorization/pytest.ini b/docs/tutorials/wiki/src/authorization/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki/src/authorization/pytest.ini +++ b/docs/tutorials/wiki/src/authorization/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki/src/authorization/tests/__init__.py b/docs/tutorials/wiki/src/authorization/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki/src/authorization/tests/test_it.py b/docs/tutorials/wiki/src/authorization/tests/test_it.py new file mode 100644 index 000000000..6c72bcc62 --- /dev/null +++ b/docs/tutorials/wiki/src/authorization/tests/test_it.py @@ -0,0 +1,24 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from tutorial.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'myproj') + + def test_notfound_view(self): + from tutorial.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/authorization/tutorial/tests.py b/docs/tutorials/wiki/src/authorization/tutorial/tests.py deleted file mode 100644 index aa5641cdd..000000000 --- a/docs/tutorials/wiki/src/authorization/tutorial/tests.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'myproj') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - diff --git a/docs/tutorials/wiki/src/basiclayout/MANIFEST.in b/docs/tutorials/wiki/src/basiclayout/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki/src/basiclayout/MANIFEST.in +++ b/docs/tutorials/wiki/src/basiclayout/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki/src/basiclayout/pytest.ini b/docs/tutorials/wiki/src/basiclayout/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki/src/basiclayout/pytest.ini +++ b/docs/tutorials/wiki/src/basiclayout/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki/src/basiclayout/tests/__init__.py b/docs/tutorials/wiki/src/basiclayout/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki/src/basiclayout/tests/test_it.py b/docs/tutorials/wiki/src/basiclayout/tests/test_it.py new file mode 100644 index 000000000..6c72bcc62 --- /dev/null +++ b/docs/tutorials/wiki/src/basiclayout/tests/test_it.py @@ -0,0 +1,24 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from tutorial.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'myproj') + + def test_notfound_view(self): + from tutorial.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py b/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py deleted file mode 100644 index aa5641cdd..000000000 --- a/docs/tutorials/wiki/src/basiclayout/tutorial/tests.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'myproj') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - diff --git a/docs/tutorials/wiki/src/installation/MANIFEST.in b/docs/tutorials/wiki/src/installation/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki/src/installation/MANIFEST.in +++ b/docs/tutorials/wiki/src/installation/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki/src/installation/pytest.ini b/docs/tutorials/wiki/src/installation/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki/src/installation/pytest.ini +++ b/docs/tutorials/wiki/src/installation/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki/src/installation/tests/__init__.py b/docs/tutorials/wiki/src/installation/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki/src/installation/tests/test_it.py b/docs/tutorials/wiki/src/installation/tests/test_it.py new file mode 100644 index 000000000..6c72bcc62 --- /dev/null +++ b/docs/tutorials/wiki/src/installation/tests/test_it.py @@ -0,0 +1,24 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from tutorial.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'myproj') + + def test_notfound_view(self): + from tutorial.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/installation/tutorial/tests.py b/docs/tutorials/wiki/src/installation/tutorial/tests.py deleted file mode 100644 index aa5641cdd..000000000 --- a/docs/tutorials/wiki/src/installation/tutorial/tests.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'myproj') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - diff --git a/docs/tutorials/wiki/src/models/MANIFEST.in b/docs/tutorials/wiki/src/models/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki/src/models/MANIFEST.in +++ b/docs/tutorials/wiki/src/models/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki/src/models/pytest.ini b/docs/tutorials/wiki/src/models/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki/src/models/pytest.ini +++ b/docs/tutorials/wiki/src/models/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki/src/models/tests/__init__.py b/docs/tutorials/wiki/src/models/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki/src/models/tests/test_it.py b/docs/tutorials/wiki/src/models/tests/test_it.py new file mode 100644 index 000000000..6c72bcc62 --- /dev/null +++ b/docs/tutorials/wiki/src/models/tests/test_it.py @@ -0,0 +1,24 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from tutorial.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'myproj') + + def test_notfound_view(self): + from tutorial.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/models/tutorial/tests.py b/docs/tutorials/wiki/src/models/tutorial/tests.py deleted file mode 100644 index aa5641cdd..000000000 --- a/docs/tutorials/wiki/src/models/tutorial/tests.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'myproj') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - diff --git a/docs/tutorials/wiki/src/tests/MANIFEST.in b/docs/tutorials/wiki/src/tests/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki/src/tests/MANIFEST.in +++ b/docs/tutorials/wiki/src/tests/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki/src/tests/pytest.ini b/docs/tutorials/wiki/src/tests/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki/src/tests/pytest.ini +++ b/docs/tutorials/wiki/src/tests/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki/src/tests/tests/__init__.py b/docs/tutorials/wiki/src/tests/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki/src/tests/tests/test_it.py b/docs/tutorials/wiki/src/tests/tests/test_it.py new file mode 100644 index 000000000..e45380e6f --- /dev/null +++ b/docs/tutorials/wiki/src/tests/tests/test_it.py @@ -0,0 +1,232 @@ +import unittest + +from pyramid import testing + +class PageModelTests(unittest.TestCase): + + def _getTargetClass(self): + from tutorial.models import Page + return Page + + def _makeOne(self, data='some data'): + return self._getTargetClass()(data=data) + + def test_constructor(self): + instance = self._makeOne() + self.assertEqual(instance.data, 'some data') + +class WikiModelTests(unittest.TestCase): + + def _getTargetClass(self): + from tutorial.models import Wiki + return Wiki + + def _makeOne(self): + return self._getTargetClass()() + + def test_it(self): + wiki = self._makeOne() + self.assertEqual(wiki.__parent__, None) + self.assertEqual(wiki.__name__, None) + +class AppmakerTests(unittest.TestCase): + + def _callFUT(self, zodb_root): + from tutorial.models import appmaker + return appmaker(zodb_root) + + def test_it(self): + root = {} + self._callFUT(root) + self.assertEqual(root['app_root']['FrontPage'].data, + 'This is the front page') + +class ViewWikiTests(unittest.TestCase): + def test_it(self): + from tutorial.views.default import view_wiki + context = testing.DummyResource() + request = testing.DummyRequest() + response = view_wiki(context, request) + self.assertEqual(response.location, 'http://example.com/FrontPage') + +class ViewPageTests(unittest.TestCase): + def _callFUT(self, context, request): + from tutorial.views.default import view_page + return view_page(context, request) + + def test_it(self): + wiki = testing.DummyResource() + wiki['IDoExist'] = testing.DummyResource() + context = testing.DummyResource(data='Hello CruelWorld IDoExist') + context.__parent__ = wiki + context.__name__ = 'thepage' + request = testing.DummyRequest() + info = self._callFUT(context, request) + self.assertEqual(info['page'], context) + self.assertEqual( + info['page_text'], + '
\n' + '

Hello ' + 'CruelWorld ' + '' + 'IDoExist' + '

\n
\n') + self.assertEqual(info['edit_url'], + 'http://example.com/thepage/edit_page') + + +class AddPageTests(unittest.TestCase): + def _callFUT(self, context, request): + from tutorial.views.default import add_page + return add_page(context, request) + + def test_it_notsubmitted(self): + context = testing.DummyResource() + request = testing.DummyRequest() + request.subpath = ['AnotherPage'] + info = self._callFUT(context, request) + self.assertEqual(info['page'].data,'') + self.assertEqual( + info['save_url'], + request.resource_url(context, 'add_page', 'AnotherPage')) + + def test_it_submitted(self): + context = testing.DummyResource() + request = testing.DummyRequest({'form.submitted':True, + 'body':'Hello yo!'}) + request.subpath = ['AnotherPage'] + self._callFUT(context, request) + page = context['AnotherPage'] + self.assertEqual(page.data, 'Hello yo!') + self.assertEqual(page.__name__, 'AnotherPage') + self.assertEqual(page.__parent__, context) + +class EditPageTests(unittest.TestCase): + def _callFUT(self, context, request): + from tutorial.views.default import edit_page + return edit_page(context, request) + + def test_it_notsubmitted(self): + context = testing.DummyResource() + request = testing.DummyRequest() + info = self._callFUT(context, request) + self.assertEqual(info['page'], context) + self.assertEqual(info['save_url'], + request.resource_url(context, 'edit_page')) + + def test_it_submitted(self): + context = testing.DummyResource() + request = testing.DummyRequest({'form.submitted':True, + 'body':'Hello yo!'}) + response = self._callFUT(context, request) + self.assertEqual(response.location, 'http://example.com/') + self.assertEqual(context.data, 'Hello yo!') + +class SecurityTests(unittest.TestCase): + def test_hashing(self): + from tutorial.security import hash_password, check_password + password = 'secretpassword' + hashed_password = hash_password(password) + self.assertTrue(check_password(hashed_password, password)) + + self.assertFalse(check_password(hashed_password, 'attackerpassword')) + + self.assertFalse(check_password(None, password)) + +class FunctionalTests(unittest.TestCase): + + viewer_login = '/login?login=viewer&password=viewer' \ + '&came_from=FrontPage&form.submitted=Login' + viewer_wrong_login = '/login?login=viewer&password=incorrect' \ + '&came_from=FrontPage&form.submitted=Login' + editor_login = '/login?login=editor&password=editor' \ + '&came_from=FrontPage&form.submitted=Login' + + def setUp(self): + import tempfile + import os.path + from tutorial import main + self.tmpdir = tempfile.mkdtemp() + + dbpath = os.path.join( self.tmpdir, 'test.db') + uri = 'file://' + dbpath + settings = { 'zodbconn.uri' : uri , + 'pyramid.includes': ['pyramid_zodbconn', 'pyramid_tm'] } + + app = main({}, **settings) + self.db = app.registry._zodb_databases[''] + from webtest import TestApp + self.testapp = TestApp(app) + + def tearDown(self): + import shutil + self.db.close() + shutil.rmtree( self.tmpdir ) + + def test_root(self): + res = self.testapp.get('/', status=302) + self.assertEqual(res.location, 'http://localhost/FrontPage') + + def test_FrontPage(self): + res = self.testapp.get('/FrontPage', status=200) + self.assertTrue(b'FrontPage' in res.body) + + def test_unexisting_page(self): + res = self.testapp.get('/SomePage', status=404) + self.assertTrue(b'Not Found' in res.body) + + def test_referrer_is_login(self): + res = self.testapp.get('/login', status=200) + self.assertTrue(b'name="came_from" value="/"' in res.body) + + def test_successful_log_in(self): + res = self.testapp.get( self.viewer_login, status=302) + self.assertEqual(res.location, 'http://localhost/FrontPage') + + def test_failed_log_in(self): + res = self.testapp.get( self.viewer_wrong_login, status=200) + self.assertTrue(b'login' in res.body) + + def test_logout_link_present_when_logged_in(self): + res = self.testapp.get( self.viewer_login, status=302) + res = self.testapp.get('/FrontPage', status=200) + self.assertTrue(b'Logout' in res.body) + + def test_logout_link_not_present_after_logged_out(self): + res = self.testapp.get( self.viewer_login, status=302) + res = self.testapp.get('/FrontPage', status=200) + res = self.testapp.get('/logout', status=302) + self.assertTrue(b'Logout' not in res.body) + + def test_anonymous_user_cannot_edit(self): + res = self.testapp.get('/FrontPage/edit_page', status=200) + self.assertTrue(b'Login' in res.body) + + def test_anonymous_user_cannot_add(self): + res = self.testapp.get('/add_page/NewPage', status=200) + self.assertTrue(b'Login' in res.body) + + def test_viewer_user_cannot_edit(self): + res = self.testapp.get( self.viewer_login, status=302) + res = self.testapp.get('/FrontPage/edit_page', status=200) + self.assertTrue(b'Login' in res.body) + + def test_viewer_user_cannot_add(self): + res = self.testapp.get( self.viewer_login, status=302) + res = self.testapp.get('/add_page/NewPage', status=200) + self.assertTrue(b'Login' in res.body) + + def test_editors_member_user_can_edit(self): + res = self.testapp.get( self.editor_login, status=302) + res = self.testapp.get('/FrontPage/edit_page', status=200) + self.assertTrue(b'Editing' in res.body) + + def test_editors_member_user_can_add(self): + res = self.testapp.get( self.editor_login, status=302) + res = self.testapp.get('/add_page/NewPage', status=200) + self.assertTrue(b'Editing' in res.body) + + def test_editors_member_user_can_view(self): + res = self.testapp.get( self.editor_login, status=302) + res = self.testapp.get('/FrontPage', status=200) + self.assertTrue(b'FrontPage' in res.body) diff --git a/docs/tutorials/wiki/src/tests/tutorial/tests.py b/docs/tutorials/wiki/src/tests/tutorial/tests.py deleted file mode 100644 index ff1c07b7c..000000000 --- a/docs/tutorials/wiki/src/tests/tutorial/tests.py +++ /dev/null @@ -1,232 +0,0 @@ -import unittest - -from pyramid import testing - -class PageModelTests(unittest.TestCase): - - def _getTargetClass(self): - from .models import Page - return Page - - def _makeOne(self, data='some data'): - return self._getTargetClass()(data=data) - - def test_constructor(self): - instance = self._makeOne() - self.assertEqual(instance.data, 'some data') - -class WikiModelTests(unittest.TestCase): - - def _getTargetClass(self): - from .models import Wiki - return Wiki - - def _makeOne(self): - return self._getTargetClass()() - - def test_it(self): - wiki = self._makeOne() - self.assertEqual(wiki.__parent__, None) - self.assertEqual(wiki.__name__, None) - -class AppmakerTests(unittest.TestCase): - - def _callFUT(self, zodb_root): - from .models import appmaker - return appmaker(zodb_root) - - def test_it(self): - root = {} - self._callFUT(root) - self.assertEqual(root['app_root']['FrontPage'].data, - 'This is the front page') - -class ViewWikiTests(unittest.TestCase): - def test_it(self): - from .views.default import view_wiki - context = testing.DummyResource() - request = testing.DummyRequest() - response = view_wiki(context, request) - self.assertEqual(response.location, 'http://example.com/FrontPage') - -class ViewPageTests(unittest.TestCase): - def _callFUT(self, context, request): - from .views.default import view_page - return view_page(context, request) - - def test_it(self): - wiki = testing.DummyResource() - wiki['IDoExist'] = testing.DummyResource() - context = testing.DummyResource(data='Hello CruelWorld IDoExist') - context.__parent__ = wiki - context.__name__ = 'thepage' - request = testing.DummyRequest() - info = self._callFUT(context, request) - self.assertEqual(info['page'], context) - self.assertEqual( - info['page_text'], - '
\n' - '

Hello ' - 'CruelWorld ' - '' - 'IDoExist' - '

\n
\n') - self.assertEqual(info['edit_url'], - 'http://example.com/thepage/edit_page') - - -class AddPageTests(unittest.TestCase): - def _callFUT(self, context, request): - from .views.default import add_page - return add_page(context, request) - - def test_it_notsubmitted(self): - context = testing.DummyResource() - request = testing.DummyRequest() - request.subpath = ['AnotherPage'] - info = self._callFUT(context, request) - self.assertEqual(info['page'].data,'') - self.assertEqual( - info['save_url'], - request.resource_url(context, 'add_page', 'AnotherPage')) - - def test_it_submitted(self): - context = testing.DummyResource() - request = testing.DummyRequest({'form.submitted':True, - 'body':'Hello yo!'}) - request.subpath = ['AnotherPage'] - self._callFUT(context, request) - page = context['AnotherPage'] - self.assertEqual(page.data, 'Hello yo!') - self.assertEqual(page.__name__, 'AnotherPage') - self.assertEqual(page.__parent__, context) - -class EditPageTests(unittest.TestCase): - def _callFUT(self, context, request): - from .views.default import edit_page - return edit_page(context, request) - - def test_it_notsubmitted(self): - context = testing.DummyResource() - request = testing.DummyRequest() - info = self._callFUT(context, request) - self.assertEqual(info['page'], context) - self.assertEqual(info['save_url'], - request.resource_url(context, 'edit_page')) - - def test_it_submitted(self): - context = testing.DummyResource() - request = testing.DummyRequest({'form.submitted':True, - 'body':'Hello yo!'}) - response = self._callFUT(context, request) - self.assertEqual(response.location, 'http://example.com/') - self.assertEqual(context.data, 'Hello yo!') - -class SecurityTests(unittest.TestCase): - def test_hashing(self): - from .security import hash_password, check_password - password = 'secretpassword' - hashed_password = hash_password(password) - self.assertTrue(check_password(hashed_password, password)) - - self.assertFalse(check_password(hashed_password, 'attackerpassword')) - - self.assertFalse(check_password(None, password)) - -class FunctionalTests(unittest.TestCase): - - viewer_login = '/login?login=viewer&password=viewer' \ - '&came_from=FrontPage&form.submitted=Login' - viewer_wrong_login = '/login?login=viewer&password=incorrect' \ - '&came_from=FrontPage&form.submitted=Login' - editor_login = '/login?login=editor&password=editor' \ - '&came_from=FrontPage&form.submitted=Login' - - def setUp(self): - import tempfile - import os.path - from . import main - self.tmpdir = tempfile.mkdtemp() - - dbpath = os.path.join( self.tmpdir, 'test.db') - uri = 'file://' + dbpath - settings = { 'zodbconn.uri' : uri , - 'pyramid.includes': ['pyramid_zodbconn', 'pyramid_tm'] } - - app = main({}, **settings) - self.db = app.registry._zodb_databases[''] - from webtest import TestApp - self.testapp = TestApp(app) - - def tearDown(self): - import shutil - self.db.close() - shutil.rmtree( self.tmpdir ) - - def test_root(self): - res = self.testapp.get('/', status=302) - self.assertEqual(res.location, 'http://localhost/FrontPage') - - def test_FrontPage(self): - res = self.testapp.get('/FrontPage', status=200) - self.assertTrue(b'FrontPage' in res.body) - - def test_unexisting_page(self): - res = self.testapp.get('/SomePage', status=404) - self.assertTrue(b'Not Found' in res.body) - - def test_referrer_is_login(self): - res = self.testapp.get('/login', status=200) - self.assertTrue(b'name="came_from" value="/"' in res.body) - - def test_successful_log_in(self): - res = self.testapp.get( self.viewer_login, status=302) - self.assertEqual(res.location, 'http://localhost/FrontPage') - - def test_failed_log_in(self): - res = self.testapp.get( self.viewer_wrong_login, status=200) - self.assertTrue(b'login' in res.body) - - def test_logout_link_present_when_logged_in(self): - res = self.testapp.get( self.viewer_login, status=302) - res = self.testapp.get('/FrontPage', status=200) - self.assertTrue(b'Logout' in res.body) - - def test_logout_link_not_present_after_logged_out(self): - res = self.testapp.get( self.viewer_login, status=302) - res = self.testapp.get('/FrontPage', status=200) - res = self.testapp.get('/logout', status=302) - self.assertTrue(b'Logout' not in res.body) - - def test_anonymous_user_cannot_edit(self): - res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue(b'Login' in res.body) - - def test_anonymous_user_cannot_add(self): - res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue(b'Login' in res.body) - - def test_viewer_user_cannot_edit(self): - res = self.testapp.get( self.viewer_login, status=302) - res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue(b'Login' in res.body) - - def test_viewer_user_cannot_add(self): - res = self.testapp.get( self.viewer_login, status=302) - res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue(b'Login' in res.body) - - def test_editors_member_user_can_edit(self): - res = self.testapp.get( self.editor_login, status=302) - res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue(b'Editing' in res.body) - - def test_editors_member_user_can_add(self): - res = self.testapp.get( self.editor_login, status=302) - res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue(b'Editing' in res.body) - - def test_editors_member_user_can_view(self): - res = self.testapp.get( self.editor_login, status=302) - res = self.testapp.get('/FrontPage', status=200) - self.assertTrue(b'FrontPage' in res.body) diff --git a/docs/tutorials/wiki/src/views/MANIFEST.in b/docs/tutorials/wiki/src/views/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki/src/views/MANIFEST.in +++ b/docs/tutorials/wiki/src/views/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki/src/views/pytest.ini b/docs/tutorials/wiki/src/views/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki/src/views/pytest.ini +++ b/docs/tutorials/wiki/src/views/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki/src/views/tests/__init__.py b/docs/tutorials/wiki/src/views/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki/src/views/tests/test_it.py b/docs/tutorials/wiki/src/views/tests/test_it.py new file mode 100644 index 000000000..6c72bcc62 --- /dev/null +++ b/docs/tutorials/wiki/src/views/tests/test_it.py @@ -0,0 +1,24 @@ +import unittest + +from pyramid import testing + + +class ViewTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + + def tearDown(self): + testing.tearDown() + + def test_my_view(self): + from tutorial.views.default import my_view + request = testing.DummyRequest() + info = my_view(request) + self.assertEqual(info['project'], 'myproj') + + def test_notfound_view(self): + from tutorial.views.notfound import notfound_view + request = testing.DummyRequest() + info = notfound_view(request) + self.assertEqual(info, {}) + diff --git a/docs/tutorials/wiki/src/views/tutorial/tests.py b/docs/tutorials/wiki/src/views/tutorial/tests.py deleted file mode 100644 index aa5641cdd..000000000 --- a/docs/tutorials/wiki/src/views/tutorial/tests.py +++ /dev/null @@ -1,24 +0,0 @@ -import unittest - -from pyramid import testing - - -class ViewTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - - def tearDown(self): - testing.tearDown() - - def test_my_view(self): - from .views.default import my_view - request = testing.DummyRequest() - info = my_view(request) - self.assertEqual(info['project'], 'myproj') - - def test_notfound_view(self): - from .views.notfound import notfound_view - request = testing.DummyRequest() - info = notfound_view(request) - self.assertEqual(info, {}) - diff --git a/docs/tutorials/wiki/tests.rst b/docs/tutorials/wiki/tests.rst index 9dacc5f96..f710b3b10 100644 --- a/docs/tutorials/wiki/tests.rst +++ b/docs/tutorials/wiki/tests.rst @@ -4,7 +4,7 @@ Adding Tests ============ -We will now add tests for the models and the views and a few functional tests in ``tests.py``. +We will now add tests for the models and the views and a few functional tests in ``tests/test_it.py``. Tests ensure that an application works, and that it continues to work when changes are made in the future. @@ -12,10 +12,9 @@ Test the models =============== We write tests for the ``model`` classes and the ``appmaker``. -Changing ``tests.py``, we will write a separate test class for each ``model`` class +We will modify our ``test_it.py`` file, writing a separate test class for each ``model`` class. We will also write a test class for the ``appmaker``. -To do so, we will retain the ``tutorial.tests.ViewTests`` class that was generated from choosing the ``zodb`` backend option. We will add three test classes, one for each of the following: - the ``Page`` model named ``PageModelTests`` @@ -26,7 +25,7 @@ We will add three test classes, one for each of the following: Test the views ============== -We will modify our ``tests.py`` file, adding tests for each view function that we added previously. +We will modify our ``test_it.py`` file, adding tests for each view function that we added previously. As a result, we will delete the ``ViewTests`` class that the ``zodb`` backend option provided, and add four other test classes: ``ViewWikiTests``, ``ViewPageTests``, ``AddPageTests``, and ``EditPageTests``. These test the ``view_wiki``, ``view_page``, ``add_page``, and ``edit_page`` views. @@ -35,14 +34,15 @@ Functional tests ================ We will test the whole application, covering security aspects that are not tested in the unit tests, such as logging in, logging out, checking that the ``viewer`` user cannot add or edit pages, but the ``editor`` user can, and so on. +As a result we will add two test classes, ``SecurityTests`` and ``FunctionalTests``. -View the results of all our edits to ``tests.py`` -================================================= +View the results of all our edits to ``tests/test_it.py`` +========================================================= -Open the ``tutorial/tests.py`` module, and edit it such that it appears as follows: +Open the ``tests/test_it.py`` module, and edit it such that it appears as follows: -.. literalinclude:: src/tests/tutorial/tests.py +.. literalinclude:: src/tests/tests/test_it.py :linenos: :language: python -- cgit v1.2.3 From bd42bcaee1176ee5bb0cc7bf311e8e91070eea88 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 21:21:25 -0800 Subject: Resync wiki2/*.rst and related files after moving tests directory --- docs/tutorials/wiki2/installation.rst | 2 +- .../tutorials/wiki2/src/authentication/MANIFEST.in | 3 + docs/tutorials/wiki2/src/authentication/pytest.ini | 7 +- .../wiki2/src/authentication/tests/__init__.py | 0 .../wiki2/src/authentication/tests/test_it.py | 66 ++++++++ .../wiki2/src/authentication/tutorial/tests.py | 66 -------- docs/tutorials/wiki2/src/authorization/MANIFEST.in | 3 + docs/tutorials/wiki2/src/authorization/pytest.ini | 7 +- .../wiki2/src/authorization/tests/__init__.py | 0 .../wiki2/src/authorization/tests/test_it.py | 66 ++++++++ .../wiki2/src/authorization/tutorial/tests.py | 66 -------- docs/tutorials/wiki2/src/basiclayout/MANIFEST.in | 3 + docs/tutorials/wiki2/src/basiclayout/pytest.ini | 7 +- .../wiki2/src/basiclayout/tests/__init__.py | 0 .../wiki2/src/basiclayout/tests/test_it.py | 66 ++++++++ .../wiki2/src/basiclayout/tutorial/tests.py | 66 -------- docs/tutorials/wiki2/src/installation/MANIFEST.in | 3 + docs/tutorials/wiki2/src/installation/pytest.ini | 7 +- .../wiki2/src/installation/tests/__init__.py | 0 .../wiki2/src/installation/tests/test_it.py | 66 ++++++++ .../wiki2/src/installation/tutorial/tests.py | 66 -------- docs/tutorials/wiki2/src/models/MANIFEST.in | 3 + docs/tutorials/wiki2/src/models/pytest.ini | 7 +- docs/tutorials/wiki2/src/models/tests/__init__.py | 0 docs/tutorials/wiki2/src/models/tests/test_it.py | 66 ++++++++ docs/tutorials/wiki2/src/models/tutorial/tests.py | 66 -------- docs/tutorials/wiki2/src/tests/MANIFEST.in | 3 + docs/tutorials/wiki2/src/tests/pytest.ini | 7 +- docs/tutorials/wiki2/src/tests/tests/__init__.py | 0 .../wiki2/src/tests/tests/test_functional.py | 134 ++++++++++++++++ .../tutorials/wiki2/src/tests/tests/test_initdb.py | 16 ++ .../wiki2/src/tests/tests/test_security.py | 23 +++ .../wiki2/src/tests/tests/test_user_model.py | 67 ++++++++ docs/tutorials/wiki2/src/tests/tests/test_views.py | 168 +++++++++++++++++++++ .../wiki2/src/tests/tutorial/tests/__init__.py | 0 .../src/tests/tutorial/tests/test_functional.py | 134 ---------------- .../wiki2/src/tests/tutorial/tests/test_initdb.py | 16 -- .../src/tests/tutorial/tests/test_security.py | 23 --- .../src/tests/tutorial/tests/test_user_model.py | 67 -------- .../wiki2/src/tests/tutorial/tests/test_views.py | 168 --------------------- docs/tutorials/wiki2/src/views/MANIFEST.in | 3 + docs/tutorials/wiki2/src/views/pytest.ini | 7 +- docs/tutorials/wiki2/src/views/tests/__init__.py | 0 docs/tutorials/wiki2/src/views/tests/test_it.py | 66 ++++++++ docs/tutorials/wiki2/src/views/tutorial/tests.py | 66 -------- docs/tutorials/wiki2/tests.rst | 39 +++-- 46 files changed, 879 insertions(+), 840 deletions(-) create mode 100644 docs/tutorials/wiki2/src/authentication/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/authentication/tests/test_it.py delete mode 100644 docs/tutorials/wiki2/src/authentication/tutorial/tests.py create mode 100644 docs/tutorials/wiki2/src/authorization/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/authorization/tests/test_it.py delete mode 100644 docs/tutorials/wiki2/src/authorization/tutorial/tests.py create mode 100644 docs/tutorials/wiki2/src/basiclayout/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/basiclayout/tests/test_it.py delete mode 100644 docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py create mode 100644 docs/tutorials/wiki2/src/installation/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/installation/tests/test_it.py delete mode 100644 docs/tutorials/wiki2/src/installation/tutorial/tests.py create mode 100644 docs/tutorials/wiki2/src/models/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/models/tests/test_it.py delete mode 100644 docs/tutorials/wiki2/src/models/tutorial/tests.py create mode 100644 docs/tutorials/wiki2/src/tests/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/tests/tests/test_functional.py create mode 100644 docs/tutorials/wiki2/src/tests/tests/test_initdb.py create mode 100644 docs/tutorials/wiki2/src/tests/tests/test_security.py create mode 100644 docs/tutorials/wiki2/src/tests/tests/test_user_model.py create mode 100644 docs/tutorials/wiki2/src/tests/tests/test_views.py delete mode 100644 docs/tutorials/wiki2/src/tests/tutorial/tests/__init__.py delete mode 100644 docs/tutorials/wiki2/src/tests/tutorial/tests/test_functional.py delete mode 100644 docs/tutorials/wiki2/src/tests/tutorial/tests/test_initdb.py delete mode 100644 docs/tutorials/wiki2/src/tests/tutorial/tests/test_security.py delete mode 100644 docs/tutorials/wiki2/src/tests/tutorial/tests/test_user_model.py delete mode 100644 docs/tutorials/wiki2/src/tests/tutorial/tests/test_views.py create mode 100644 docs/tutorials/wiki2/src/views/tests/__init__.py create mode 100644 docs/tutorials/wiki2/src/views/tests/test_it.py delete mode 100644 docs/tutorials/wiki2/src/views/tutorial/tests.py (limited to 'docs') diff --git a/docs/tutorials/wiki2/installation.rst b/docs/tutorials/wiki2/installation.rst index 384584da7..55fca15a1 100644 --- a/docs/tutorials/wiki2/installation.rst +++ b/docs/tutorials/wiki2/installation.rst @@ -393,7 +393,7 @@ On Unix .. code-block:: bash - $VENV/bin/pytest --cov=tutorial tutorial/tests.py -q + $VENV/bin/pytest --cov=tutorial tests -q On Windows ^^^^^^^^^^ diff --git a/docs/tutorials/wiki2/src/authentication/MANIFEST.in b/docs/tutorials/wiki2/src/authentication/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/authentication/MANIFEST.in +++ b/docs/tutorials/wiki2/src/authentication/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/authentication/pytest.ini b/docs/tutorials/wiki2/src/authentication/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/authentication/pytest.ini +++ b/docs/tutorials/wiki2/src/authentication/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/authentication/tests/__init__.py b/docs/tutorials/wiki2/src/authentication/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/authentication/tests/test_it.py b/docs/tutorials/wiki2/src/authentication/tests/test_it.py new file mode 100644 index 000000000..ea16534fc --- /dev/null +++ b/docs/tutorials/wiki2/src/authentication/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + settings = self.config.get_settings() + + from tutorial.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from tutorial.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from tutorial.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from tutorial.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'myproj') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/tests.py b/docs/tutorials/wiki2/src/authentication/tutorial/tests.py deleted file mode 100644 index 47990669e..000000000 --- a/docs/tutorials/wiki2/src/authentication/tutorial/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'myproj') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/authorization/MANIFEST.in b/docs/tutorials/wiki2/src/authorization/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/authorization/MANIFEST.in +++ b/docs/tutorials/wiki2/src/authorization/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/authorization/pytest.ini b/docs/tutorials/wiki2/src/authorization/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/authorization/pytest.ini +++ b/docs/tutorials/wiki2/src/authorization/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/authorization/tests/__init__.py b/docs/tutorials/wiki2/src/authorization/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/authorization/tests/test_it.py b/docs/tutorials/wiki2/src/authorization/tests/test_it.py new file mode 100644 index 000000000..ea16534fc --- /dev/null +++ b/docs/tutorials/wiki2/src/authorization/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + settings = self.config.get_settings() + + from tutorial.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from tutorial.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from tutorial.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from tutorial.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'myproj') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py b/docs/tutorials/wiki2/src/authorization/tutorial/tests.py deleted file mode 100644 index 47990669e..000000000 --- a/docs/tutorials/wiki2/src/authorization/tutorial/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'myproj') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/basiclayout/MANIFEST.in b/docs/tutorials/wiki2/src/basiclayout/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/basiclayout/MANIFEST.in +++ b/docs/tutorials/wiki2/src/basiclayout/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/basiclayout/pytest.ini b/docs/tutorials/wiki2/src/basiclayout/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/basiclayout/pytest.ini +++ b/docs/tutorials/wiki2/src/basiclayout/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/basiclayout/tests/__init__.py b/docs/tutorials/wiki2/src/basiclayout/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/basiclayout/tests/test_it.py b/docs/tutorials/wiki2/src/basiclayout/tests/test_it.py new file mode 100644 index 000000000..ea16534fc --- /dev/null +++ b/docs/tutorials/wiki2/src/basiclayout/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + settings = self.config.get_settings() + + from tutorial.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from tutorial.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from tutorial.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from tutorial.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'myproj') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py b/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py deleted file mode 100644 index 47990669e..000000000 --- a/docs/tutorials/wiki2/src/basiclayout/tutorial/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'myproj') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/installation/MANIFEST.in b/docs/tutorials/wiki2/src/installation/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/installation/MANIFEST.in +++ b/docs/tutorials/wiki2/src/installation/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/installation/pytest.ini b/docs/tutorials/wiki2/src/installation/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/installation/pytest.ini +++ b/docs/tutorials/wiki2/src/installation/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/installation/tests/__init__.py b/docs/tutorials/wiki2/src/installation/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/installation/tests/test_it.py b/docs/tutorials/wiki2/src/installation/tests/test_it.py new file mode 100644 index 000000000..ea16534fc --- /dev/null +++ b/docs/tutorials/wiki2/src/installation/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + settings = self.config.get_settings() + + from tutorial.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from tutorial.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from tutorial.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from tutorial.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'myproj') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/installation/tutorial/tests.py b/docs/tutorials/wiki2/src/installation/tutorial/tests.py deleted file mode 100644 index 47990669e..000000000 --- a/docs/tutorials/wiki2/src/installation/tutorial/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'myproj') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/models/MANIFEST.in b/docs/tutorials/wiki2/src/models/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/models/MANIFEST.in +++ b/docs/tutorials/wiki2/src/models/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/models/pytest.ini b/docs/tutorials/wiki2/src/models/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/models/pytest.ini +++ b/docs/tutorials/wiki2/src/models/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/models/tests/__init__.py b/docs/tutorials/wiki2/src/models/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/models/tests/test_it.py b/docs/tutorials/wiki2/src/models/tests/test_it.py new file mode 100644 index 000000000..ea16534fc --- /dev/null +++ b/docs/tutorials/wiki2/src/models/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + settings = self.config.get_settings() + + from tutorial.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from tutorial.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from tutorial.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from tutorial.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'myproj') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/models/tutorial/tests.py b/docs/tutorials/wiki2/src/models/tutorial/tests.py deleted file mode 100644 index 47990669e..000000000 --- a/docs/tutorials/wiki2/src/models/tutorial/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'myproj') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/tests/MANIFEST.in b/docs/tutorials/wiki2/src/tests/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/tests/MANIFEST.in +++ b/docs/tutorials/wiki2/src/tests/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/tests/pytest.ini b/docs/tutorials/wiki2/src/tests/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/tests/pytest.ini +++ b/docs/tutorials/wiki2/src/tests/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/tests/tests/__init__.py b/docs/tutorials/wiki2/src/tests/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/tests/tests/test_functional.py b/docs/tutorials/wiki2/src/tests/tests/test_functional.py new file mode 100644 index 000000000..0250e71c9 --- /dev/null +++ b/docs/tutorials/wiki2/src/tests/tests/test_functional.py @@ -0,0 +1,134 @@ +import transaction +import unittest +import webtest + + +class FunctionalTests(unittest.TestCase): + + basic_login = ( + '/login?login=basic&password=basic' + '&next=FrontPage&form.submitted=Login') + basic_wrong_login = ( + '/login?login=basic&password=incorrect' + '&next=FrontPage&form.submitted=Login') + basic_login_no_next = ( + '/login?login=basic&password=basic' + '&form.submitted=Login') + editor_login = ( + '/login?login=editor&password=editor' + '&next=FrontPage&form.submitted=Login') + + @classmethod + def setUpClass(cls): + from tutorial.models.meta import Base + from tutorial.models import ( + User, + Page, + get_tm_session, + ) + from tutorial import main + + settings = { + 'sqlalchemy.url': 'sqlite://', + 'auth.secret': 'seekrit', + } + app = main({}, **settings) + cls.testapp = webtest.TestApp(app) + + session_factory = app.registry['dbsession_factory'] + cls.engine = session_factory.kw['bind'] + Base.metadata.create_all(bind=cls.engine) + + with transaction.manager: + dbsession = get_tm_session(session_factory, transaction.manager) + editor = User(name='editor', role='editor') + editor.set_password('editor') + basic = User(name='basic', role='basic') + basic.set_password('basic') + page1 = Page(name='FrontPage', data='This is the front page') + page1.creator = editor + page2 = Page(name='BackPage', data='This is the back page') + page2.creator = basic + dbsession.add_all([basic, editor, page1, page2]) + + @classmethod + def tearDownClass(cls): + from tutorial.models.meta import Base + Base.metadata.drop_all(bind=cls.engine) + + def test_root(self): + res = self.testapp.get('/', status=302) + self.assertEqual(res.location, 'http://localhost/FrontPage') + + def test_FrontPage(self): + res = self.testapp.get('/FrontPage', status=200) + self.assertTrue(b'FrontPage' in res.body) + + def test_unexisting_page(self): + self.testapp.get('/SomePage', status=404) + + def test_successful_log_in(self): + res = self.testapp.get(self.basic_login, status=302) + self.assertEqual(res.location, 'http://localhost/FrontPage') + + def test_successful_log_in_no_next(self): + res = self.testapp.get(self.basic_login_no_next, status=302) + self.assertEqual(res.location, 'http://localhost/') + + def test_failed_log_in(self): + res = self.testapp.get(self.basic_wrong_login, status=200) + self.assertTrue(b'login' in res.body) + + def test_logout_link_present_when_logged_in(self): + self.testapp.get(self.basic_login, status=302) + res = self.testapp.get('/FrontPage', status=200) + self.assertTrue(b'Logout' in res.body) + + def test_logout_link_not_present_after_logged_out(self): + self.testapp.get(self.basic_login, status=302) + self.testapp.get('/FrontPage', status=200) + res = self.testapp.get('/logout', status=302) + self.assertTrue(b'Logout' not in res.body) + + def test_anonymous_user_cannot_edit(self): + res = self.testapp.get('/FrontPage/edit_page', status=302).follow() + self.assertTrue(b'Login' in res.body) + + def test_anonymous_user_cannot_add(self): + res = self.testapp.get('/add_page/NewPage', status=302).follow() + self.assertTrue(b'Login' in res.body) + + def test_basic_user_cannot_edit_front(self): + self.testapp.get(self.basic_login, status=302) + res = self.testapp.get('/FrontPage/edit_page', status=302).follow() + self.assertTrue(b'Login' in res.body) + + def test_basic_user_can_edit_back(self): + self.testapp.get(self.basic_login, status=302) + res = self.testapp.get('/BackPage/edit_page', status=200) + self.assertTrue(b'Editing' in res.body) + + def test_basic_user_can_add(self): + self.testapp.get(self.basic_login, status=302) + res = self.testapp.get('/add_page/NewPage', status=200) + self.assertTrue(b'Editing' in res.body) + + def test_editors_member_user_can_edit(self): + self.testapp.get(self.editor_login, status=302) + res = self.testapp.get('/FrontPage/edit_page', status=200) + self.assertTrue(b'Editing' in res.body) + + def test_editors_member_user_can_add(self): + self.testapp.get(self.editor_login, status=302) + res = self.testapp.get('/add_page/NewPage', status=200) + self.assertTrue(b'Editing' in res.body) + + def test_editors_member_user_can_view(self): + self.testapp.get(self.editor_login, status=302) + res = self.testapp.get('/FrontPage', status=200) + self.assertTrue(b'FrontPage' in res.body) + + def test_redirect_to_edit_for_existing_page(self): + self.testapp.get(self.editor_login, status=302) + res = self.testapp.get('/add_page/FrontPage', status=302) + self.assertTrue(b'FrontPage' in res.body) diff --git a/docs/tutorials/wiki2/src/tests/tests/test_initdb.py b/docs/tutorials/wiki2/src/tests/tests/test_initdb.py new file mode 100644 index 000000000..9a24f0b22 --- /dev/null +++ b/docs/tutorials/wiki2/src/tests/tests/test_initdb.py @@ -0,0 +1,16 @@ +import os +import unittest + + +class TestInitializeDB(unittest.TestCase): + + def test_usage(self): + from tutorial.scripts.initialize_db import main + with self.assertRaises(SystemExit): + main(argv=['foo']) + + def test_run(self): + from tutorial.scripts.initialize_db import main + main(argv=['foo', 'development.ini']) + self.assertTrue(os.path.exists('tutorial.sqlite')) + os.remove('tutorial.sqlite') diff --git a/docs/tutorials/wiki2/src/tests/tests/test_security.py b/docs/tutorials/wiki2/src/tests/tests/test_security.py new file mode 100644 index 000000000..9a1455ef9 --- /dev/null +++ b/docs/tutorials/wiki2/src/tests/tests/test_security.py @@ -0,0 +1,23 @@ +import unittest +from pyramid.testing import DummyRequest + + +class TestMyAuthenticationPolicy(unittest.TestCase): + + def test_no_user(self): + request = DummyRequest() + request.user = None + + from tutorial.security import MyAuthenticationPolicy + policy = MyAuthenticationPolicy(None) + self.assertEqual(policy.authenticated_userid(request), None) + + def test_authenticated_user(self): + from tutorial.models import User + request = DummyRequest() + request.user = User() + request.user.id = 'foo' + + from tutorial.security import MyAuthenticationPolicy + policy = MyAuthenticationPolicy(None) + self.assertEqual(policy.authenticated_userid(request), 'foo') diff --git a/docs/tutorials/wiki2/src/tests/tests/test_user_model.py b/docs/tutorials/wiki2/src/tests/tests/test_user_model.py new file mode 100644 index 000000000..21904da6b --- /dev/null +++ b/docs/tutorials/wiki2/src/tests/tests/test_user_model.py @@ -0,0 +1,67 @@ +import unittest +import transaction + +from pyramid import testing + + +class BaseTest(unittest.TestCase): + + def setUp(self): + from tutorial.models import get_tm_session + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + self.config.include('tutorial.routes') + + session_factory = self.config.registry['dbsession_factory'] + self.session = get_tm_session(session_factory, transaction.manager) + + self.init_database() + + def init_database(self): + from tutorial.models.meta import Base + session_factory = self.config.registry['dbsession_factory'] + engine = session_factory.kw['bind'] + Base.metadata.create_all(engine) + + def tearDown(self): + testing.tearDown() + transaction.abort() + + def makeUser(self, name, role): + from tutorial.models import User + return User(name=name, role=role) + + +class TestSetPassword(BaseTest): + + def test_password_hash_saved(self): + user = self.makeUser(name='foo', role='bar') + self.assertFalse(user.password_hash) + + user.set_password('secret') + self.assertTrue(user.password_hash) + + +class TestCheckPassword(BaseTest): + + def test_password_hash_not_set(self): + user = self.makeUser(name='foo', role='bar') + self.assertFalse(user.password_hash) + + self.assertFalse(user.check_password('secret')) + + def test_correct_password(self): + user = self.makeUser(name='foo', role='bar') + user.set_password('secret') + self.assertTrue(user.password_hash) + + self.assertTrue(user.check_password('secret')) + + def test_incorrect_password(self): + user = self.makeUser(name='foo', role='bar') + user.set_password('secret') + self.assertTrue(user.password_hash) + + self.assertFalse(user.check_password('incorrect')) diff --git a/docs/tutorials/wiki2/src/tests/tests/test_views.py b/docs/tutorials/wiki2/src/tests/tests/test_views.py new file mode 100644 index 000000000..5c17457dd --- /dev/null +++ b/docs/tutorials/wiki2/src/tests/tests/test_views.py @@ -0,0 +1,168 @@ +import unittest +import transaction + +from pyramid import testing + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + from tutorial.models import get_tm_session + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + self.config.include('tutorial.routes') + + session_factory = self.config.registry['dbsession_factory'] + self.session = get_tm_session(session_factory, transaction.manager) + + self.init_database() + + def init_database(self): + from tutorial.models.meta import Base + session_factory = self.config.registry['dbsession_factory'] + engine = session_factory.kw['bind'] + Base.metadata.create_all(engine) + + def tearDown(self): + testing.tearDown() + transaction.abort() + + def makeUser(self, name, role, password='dummy'): + from tutorial.models import User + user = User(name=name, role=role) + user.set_password(password) + return user + + def makePage(self, name, data, creator): + from tutorial.models import Page + return Page(name=name, data=data, creator=creator) + + +class ViewWikiTests(unittest.TestCase): + def setUp(self): + self.config = testing.setUp() + self.config.include('tutorial.routes') + + def tearDown(self): + testing.tearDown() + + def _callFUT(self, request): + from tutorial.views.default import view_wiki + return view_wiki(request) + + def test_it(self): + request = testing.DummyRequest() + response = self._callFUT(request) + self.assertEqual(response.location, 'http://example.com/FrontPage') + + +class ViewPageTests(BaseTest): + def _callFUT(self, request): + from tutorial.views.default import view_page + return view_page(request) + + def test_it(self): + from tutorial.routes import PageResource + + # add a page to the db + user = self.makeUser('foo', 'editor') + page = self.makePage('IDoExist', 'Hello CruelWorld IDoExist', user) + self.session.add_all([page, user]) + + # create a request asking for the page we've created + request = dummy_request(self.session) + request.context = PageResource(page) + + # call the view we're testing and check its behavior + info = self._callFUT(request) + self.assertEqual(info['page'], page) + self.assertEqual( + info['content'], + '
\n' + '

Hello ' + 'CruelWorld ' + '' + 'IDoExist' + '

\n
\n') + self.assertEqual(info['edit_url'], + 'http://example.com/IDoExist/edit_page') + + +class AddPageTests(BaseTest): + def _callFUT(self, request): + from tutorial.views.default import add_page + return add_page(request) + + def test_it_pageexists(self): + from tutorial.models import Page + from tutorial.routes import NewPage + request = testing.DummyRequest({'form.submitted': True, + 'body': 'Hello yo!'}, + dbsession=self.session) + request.user = self.makeUser('foo', 'editor') + request.context = NewPage('AnotherPage') + self._callFUT(request) + pagecount = self.session.query(Page).filter_by(name='AnotherPage').count() + self.assertGreater(pagecount, 0) + + def test_it_notsubmitted(self): + from tutorial.routes import NewPage + request = dummy_request(self.session) + request.user = self.makeUser('foo', 'editor') + request.context = NewPage('AnotherPage') + info = self._callFUT(request) + self.assertEqual(info['pagedata'], '') + self.assertEqual(info['save_url'], + 'http://example.com/add_page/AnotherPage') + + def test_it_submitted(self): + from tutorial.models import Page + from tutorial.routes import NewPage + request = testing.DummyRequest({'form.submitted': True, + 'body': 'Hello yo!'}, + dbsession=self.session) + request.user = self.makeUser('foo', 'editor') + request.context = NewPage('AnotherPage') + self._callFUT(request) + page = self.session.query(Page).filter_by(name='AnotherPage').one() + self.assertEqual(page.data, 'Hello yo!') + + +class EditPageTests(BaseTest): + def _callFUT(self, request): + from tutorial.views.default import edit_page + return edit_page(request) + + def makeContext(self, page): + from tutorial.routes import PageResource + return PageResource(page) + + def test_it_notsubmitted(self): + user = self.makeUser('foo', 'editor') + page = self.makePage('abc', 'hello', user) + self.session.add_all([page, user]) + + request = dummy_request(self.session) + request.context = self.makeContext(page) + info = self._callFUT(request) + self.assertEqual(info['pagename'], 'abc') + self.assertEqual(info['save_url'], + 'http://example.com/abc/edit_page') + + def test_it_submitted(self): + user = self.makeUser('foo', 'editor') + page = self.makePage('abc', 'hello', user) + self.session.add_all([page, user]) + + request = testing.DummyRequest({'form.submitted': True, + 'body': 'Hello yo!'}, + dbsession=self.session) + request.context = self.makeContext(page) + response = self._callFUT(request) + self.assertEqual(response.location, 'http://example.com/abc') + self.assertEqual(page.data, 'Hello yo!') diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests/__init__.py b/docs/tutorials/wiki2/src/tests/tutorial/tests/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_functional.py b/docs/tutorials/wiki2/src/tests/tutorial/tests/test_functional.py deleted file mode 100644 index 0250e71c9..000000000 --- a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_functional.py +++ /dev/null @@ -1,134 +0,0 @@ -import transaction -import unittest -import webtest - - -class FunctionalTests(unittest.TestCase): - - basic_login = ( - '/login?login=basic&password=basic' - '&next=FrontPage&form.submitted=Login') - basic_wrong_login = ( - '/login?login=basic&password=incorrect' - '&next=FrontPage&form.submitted=Login') - basic_login_no_next = ( - '/login?login=basic&password=basic' - '&form.submitted=Login') - editor_login = ( - '/login?login=editor&password=editor' - '&next=FrontPage&form.submitted=Login') - - @classmethod - def setUpClass(cls): - from tutorial.models.meta import Base - from tutorial.models import ( - User, - Page, - get_tm_session, - ) - from tutorial import main - - settings = { - 'sqlalchemy.url': 'sqlite://', - 'auth.secret': 'seekrit', - } - app = main({}, **settings) - cls.testapp = webtest.TestApp(app) - - session_factory = app.registry['dbsession_factory'] - cls.engine = session_factory.kw['bind'] - Base.metadata.create_all(bind=cls.engine) - - with transaction.manager: - dbsession = get_tm_session(session_factory, transaction.manager) - editor = User(name='editor', role='editor') - editor.set_password('editor') - basic = User(name='basic', role='basic') - basic.set_password('basic') - page1 = Page(name='FrontPage', data='This is the front page') - page1.creator = editor - page2 = Page(name='BackPage', data='This is the back page') - page2.creator = basic - dbsession.add_all([basic, editor, page1, page2]) - - @classmethod - def tearDownClass(cls): - from tutorial.models.meta import Base - Base.metadata.drop_all(bind=cls.engine) - - def test_root(self): - res = self.testapp.get('/', status=302) - self.assertEqual(res.location, 'http://localhost/FrontPage') - - def test_FrontPage(self): - res = self.testapp.get('/FrontPage', status=200) - self.assertTrue(b'FrontPage' in res.body) - - def test_unexisting_page(self): - self.testapp.get('/SomePage', status=404) - - def test_successful_log_in(self): - res = self.testapp.get(self.basic_login, status=302) - self.assertEqual(res.location, 'http://localhost/FrontPage') - - def test_successful_log_in_no_next(self): - res = self.testapp.get(self.basic_login_no_next, status=302) - self.assertEqual(res.location, 'http://localhost/') - - def test_failed_log_in(self): - res = self.testapp.get(self.basic_wrong_login, status=200) - self.assertTrue(b'login' in res.body) - - def test_logout_link_present_when_logged_in(self): - self.testapp.get(self.basic_login, status=302) - res = self.testapp.get('/FrontPage', status=200) - self.assertTrue(b'Logout' in res.body) - - def test_logout_link_not_present_after_logged_out(self): - self.testapp.get(self.basic_login, status=302) - self.testapp.get('/FrontPage', status=200) - res = self.testapp.get('/logout', status=302) - self.assertTrue(b'Logout' not in res.body) - - def test_anonymous_user_cannot_edit(self): - res = self.testapp.get('/FrontPage/edit_page', status=302).follow() - self.assertTrue(b'Login' in res.body) - - def test_anonymous_user_cannot_add(self): - res = self.testapp.get('/add_page/NewPage', status=302).follow() - self.assertTrue(b'Login' in res.body) - - def test_basic_user_cannot_edit_front(self): - self.testapp.get(self.basic_login, status=302) - res = self.testapp.get('/FrontPage/edit_page', status=302).follow() - self.assertTrue(b'Login' in res.body) - - def test_basic_user_can_edit_back(self): - self.testapp.get(self.basic_login, status=302) - res = self.testapp.get('/BackPage/edit_page', status=200) - self.assertTrue(b'Editing' in res.body) - - def test_basic_user_can_add(self): - self.testapp.get(self.basic_login, status=302) - res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue(b'Editing' in res.body) - - def test_editors_member_user_can_edit(self): - self.testapp.get(self.editor_login, status=302) - res = self.testapp.get('/FrontPage/edit_page', status=200) - self.assertTrue(b'Editing' in res.body) - - def test_editors_member_user_can_add(self): - self.testapp.get(self.editor_login, status=302) - res = self.testapp.get('/add_page/NewPage', status=200) - self.assertTrue(b'Editing' in res.body) - - def test_editors_member_user_can_view(self): - self.testapp.get(self.editor_login, status=302) - res = self.testapp.get('/FrontPage', status=200) - self.assertTrue(b'FrontPage' in res.body) - - def test_redirect_to_edit_for_existing_page(self): - self.testapp.get(self.editor_login, status=302) - res = self.testapp.get('/add_page/FrontPage', status=302) - self.assertTrue(b'FrontPage' in res.body) diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_initdb.py b/docs/tutorials/wiki2/src/tests/tutorial/tests/test_initdb.py deleted file mode 100644 index 72fbff04b..000000000 --- a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_initdb.py +++ /dev/null @@ -1,16 +0,0 @@ -import os -import unittest - - -class TestInitializeDB(unittest.TestCase): - - def test_usage(self): - from ..scripts.initialize_db import main - with self.assertRaises(SystemExit): - main(argv=['foo']) - - def test_run(self): - from ..scripts.initialize_db import main - main(argv=['foo', 'development.ini']) - self.assertTrue(os.path.exists('tutorial.sqlite')) - os.remove('tutorial.sqlite') diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_security.py b/docs/tutorials/wiki2/src/tests/tutorial/tests/test_security.py deleted file mode 100644 index cbec6420d..000000000 --- a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_security.py +++ /dev/null @@ -1,23 +0,0 @@ -import unittest -from pyramid.testing import DummyRequest - - -class TestMyAuthenticationPolicy(unittest.TestCase): - - def test_no_user(self): - request = DummyRequest() - request.user = None - - from ..security import MyAuthenticationPolicy - policy = MyAuthenticationPolicy(None) - self.assertEqual(policy.authenticated_userid(request), None) - - def test_authenticated_user(self): - from ..models import User - request = DummyRequest() - request.user = User() - request.user.id = 'foo' - - from ..security import MyAuthenticationPolicy - policy = MyAuthenticationPolicy(None) - self.assertEqual(policy.authenticated_userid(request), 'foo') diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_user_model.py b/docs/tutorials/wiki2/src/tests/tutorial/tests/test_user_model.py deleted file mode 100644 index 9490ac990..000000000 --- a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_user_model.py +++ /dev/null @@ -1,67 +0,0 @@ -import unittest -import transaction - -from pyramid import testing - - -class BaseTest(unittest.TestCase): - - def setUp(self): - from ..models import get_tm_session - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('..models') - self.config.include('..routes') - - session_factory = self.config.registry['dbsession_factory'] - self.session = get_tm_session(session_factory, transaction.manager) - - self.init_database() - - def init_database(self): - from ..models.meta import Base - session_factory = self.config.registry['dbsession_factory'] - engine = session_factory.kw['bind'] - Base.metadata.create_all(engine) - - def tearDown(self): - testing.tearDown() - transaction.abort() - - def makeUser(self, name, role): - from ..models import User - return User(name=name, role=role) - - -class TestSetPassword(BaseTest): - - def test_password_hash_saved(self): - user = self.makeUser(name='foo', role='bar') - self.assertFalse(user.password_hash) - - user.set_password('secret') - self.assertTrue(user.password_hash) - - -class TestCheckPassword(BaseTest): - - def test_password_hash_not_set(self): - user = self.makeUser(name='foo', role='bar') - self.assertFalse(user.password_hash) - - self.assertFalse(user.check_password('secret')) - - def test_correct_password(self): - user = self.makeUser(name='foo', role='bar') - user.set_password('secret') - self.assertTrue(user.password_hash) - - self.assertTrue(user.check_password('secret')) - - def test_incorrect_password(self): - user = self.makeUser(name='foo', role='bar') - user.set_password('secret') - self.assertTrue(user.password_hash) - - self.assertFalse(user.check_password('incorrect')) diff --git a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_views.py b/docs/tutorials/wiki2/src/tests/tutorial/tests/test_views.py deleted file mode 100644 index 2c945ab33..000000000 --- a/docs/tutorials/wiki2/src/tests/tutorial/tests/test_views.py +++ /dev/null @@ -1,168 +0,0 @@ -import unittest -import transaction - -from pyramid import testing - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - from ..models import get_tm_session - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('..models') - self.config.include('..routes') - - session_factory = self.config.registry['dbsession_factory'] - self.session = get_tm_session(session_factory, transaction.manager) - - self.init_database() - - def init_database(self): - from ..models.meta import Base - session_factory = self.config.registry['dbsession_factory'] - engine = session_factory.kw['bind'] - Base.metadata.create_all(engine) - - def tearDown(self): - testing.tearDown() - transaction.abort() - - def makeUser(self, name, role, password='dummy'): - from ..models import User - user = User(name=name, role=role) - user.set_password(password) - return user - - def makePage(self, name, data, creator): - from ..models import Page - return Page(name=name, data=data, creator=creator) - - -class ViewWikiTests(unittest.TestCase): - def setUp(self): - self.config = testing.setUp() - self.config.include('..routes') - - def tearDown(self): - testing.tearDown() - - def _callFUT(self, request): - from tutorial.views.default import view_wiki - return view_wiki(request) - - def test_it(self): - request = testing.DummyRequest() - response = self._callFUT(request) - self.assertEqual(response.location, 'http://example.com/FrontPage') - - -class ViewPageTests(BaseTest): - def _callFUT(self, request): - from tutorial.views.default import view_page - return view_page(request) - - def test_it(self): - from ..routes import PageResource - - # add a page to the db - user = self.makeUser('foo', 'editor') - page = self.makePage('IDoExist', 'Hello CruelWorld IDoExist', user) - self.session.add_all([page, user]) - - # create a request asking for the page we've created - request = dummy_request(self.session) - request.context = PageResource(page) - - # call the view we're testing and check its behavior - info = self._callFUT(request) - self.assertEqual(info['page'], page) - self.assertEqual( - info['content'], - '
\n' - '

Hello ' - 'CruelWorld ' - '' - 'IDoExist' - '

\n
\n') - self.assertEqual(info['edit_url'], - 'http://example.com/IDoExist/edit_page') - - -class AddPageTests(BaseTest): - def _callFUT(self, request): - from tutorial.views.default import add_page - return add_page(request) - - def test_it_pageexists(self): - from ..models import Page - from ..routes import NewPage - request = testing.DummyRequest({'form.submitted': True, - 'body': 'Hello yo!'}, - dbsession=self.session) - request.user = self.makeUser('foo', 'editor') - request.context = NewPage('AnotherPage') - self._callFUT(request) - pagecount = self.session.query(Page).filter_by(name='AnotherPage').count() - self.assertGreater(pagecount, 0) - - def test_it_notsubmitted(self): - from ..routes import NewPage - request = dummy_request(self.session) - request.user = self.makeUser('foo', 'editor') - request.context = NewPage('AnotherPage') - info = self._callFUT(request) - self.assertEqual(info['pagedata'], '') - self.assertEqual(info['save_url'], - 'http://example.com/add_page/AnotherPage') - - def test_it_submitted(self): - from ..models import Page - from ..routes import NewPage - request = testing.DummyRequest({'form.submitted': True, - 'body': 'Hello yo!'}, - dbsession=self.session) - request.user = self.makeUser('foo', 'editor') - request.context = NewPage('AnotherPage') - self._callFUT(request) - page = self.session.query(Page).filter_by(name='AnotherPage').one() - self.assertEqual(page.data, 'Hello yo!') - - -class EditPageTests(BaseTest): - def _callFUT(self, request): - from tutorial.views.default import edit_page - return edit_page(request) - - def makeContext(self, page): - from ..routes import PageResource - return PageResource(page) - - def test_it_notsubmitted(self): - user = self.makeUser('foo', 'editor') - page = self.makePage('abc', 'hello', user) - self.session.add_all([page, user]) - - request = dummy_request(self.session) - request.context = self.makeContext(page) - info = self._callFUT(request) - self.assertEqual(info['pagename'], 'abc') - self.assertEqual(info['save_url'], - 'http://example.com/abc/edit_page') - - def test_it_submitted(self): - user = self.makeUser('foo', 'editor') - page = self.makePage('abc', 'hello', user) - self.session.add_all([page, user]) - - request = testing.DummyRequest({'form.submitted': True, - 'body': 'Hello yo!'}, - dbsession=self.session) - request.context = self.makeContext(page) - response = self._callFUT(request) - self.assertEqual(response.location, 'http://example.com/abc') - self.assertEqual(page.data, 'Hello yo!') diff --git a/docs/tutorials/wiki2/src/views/MANIFEST.in b/docs/tutorials/wiki2/src/views/MANIFEST.in index 05cc195d9..b4624fd1c 100644 --- a/docs/tutorials/wiki2/src/views/MANIFEST.in +++ b/docs/tutorials/wiki2/src/views/MANIFEST.in @@ -1,2 +1,5 @@ include *.txt *.ini *.cfg *.rst recursive-include tutorial *.ico *.png *.css *.gif *.jpg *.pt *.txt *.mak *.mako *.js *.html *.xml *.jinja2 +recursive-include tests * +recursive-exclude * __pycache__ +recursive-exclude * *.py[co] diff --git a/docs/tutorials/wiki2/src/views/pytest.ini b/docs/tutorials/wiki2/src/views/pytest.ini index a3489cdf8..42c3259f9 100644 --- a/docs/tutorials/wiki2/src/views/pytest.ini +++ b/docs/tutorials/wiki2/src/views/pytest.ini @@ -1,3 +1,6 @@ [pytest] -testpaths = tutorial -python_files = test*.py +addopts = --strict + +testpaths = + tutorial + tests diff --git a/docs/tutorials/wiki2/src/views/tests/__init__.py b/docs/tutorials/wiki2/src/views/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/docs/tutorials/wiki2/src/views/tests/test_it.py b/docs/tutorials/wiki2/src/views/tests/test_it.py new file mode 100644 index 000000000..ea16534fc --- /dev/null +++ b/docs/tutorials/wiki2/src/views/tests/test_it.py @@ -0,0 +1,66 @@ +import unittest + +from pyramid import testing + +import transaction + + +def dummy_request(dbsession): + return testing.DummyRequest(dbsession=dbsession) + + +class BaseTest(unittest.TestCase): + def setUp(self): + self.config = testing.setUp(settings={ + 'sqlalchemy.url': 'sqlite:///:memory:' + }) + self.config.include('tutorial.models') + settings = self.config.get_settings() + + from tutorial.models import ( + get_engine, + get_session_factory, + get_tm_session, + ) + + self.engine = get_engine(settings) + session_factory = get_session_factory(self.engine) + + self.session = get_tm_session(session_factory, transaction.manager) + + def init_database(self): + from tutorial.models.meta import Base + Base.metadata.create_all(self.engine) + + def tearDown(self): + from tutorial.models.meta import Base + + testing.tearDown() + transaction.abort() + Base.metadata.drop_all(self.engine) + + +class TestMyViewSuccessCondition(BaseTest): + + def setUp(self): + super(TestMyViewSuccessCondition, self).setUp() + self.init_database() + + from tutorial.models import MyModel + + model = MyModel(name='one', value=55) + self.session.add(model) + + def test_passing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info['one'].name, 'one') + self.assertEqual(info['project'], 'myproj') + + +class TestMyViewFailureCondition(BaseTest): + + def test_failing_view(self): + from tutorial.views.default import my_view + info = my_view(dummy_request(self.session)) + self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/src/views/tutorial/tests.py b/docs/tutorials/wiki2/src/views/tutorial/tests.py deleted file mode 100644 index 47990669e..000000000 --- a/docs/tutorials/wiki2/src/views/tutorial/tests.py +++ /dev/null @@ -1,66 +0,0 @@ -import unittest - -from pyramid import testing - -import transaction - - -def dummy_request(dbsession): - return testing.DummyRequest(dbsession=dbsession) - - -class BaseTest(unittest.TestCase): - def setUp(self): - self.config = testing.setUp(settings={ - 'sqlalchemy.url': 'sqlite:///:memory:' - }) - self.config.include('.models') - settings = self.config.get_settings() - - from .models import ( - get_engine, - get_session_factory, - get_tm_session, - ) - - self.engine = get_engine(settings) - session_factory = get_session_factory(self.engine) - - self.session = get_tm_session(session_factory, transaction.manager) - - def init_database(self): - from .models.meta import Base - Base.metadata.create_all(self.engine) - - def tearDown(self): - from .models.meta import Base - - testing.tearDown() - transaction.abort() - Base.metadata.drop_all(self.engine) - - -class TestMyViewSuccessCondition(BaseTest): - - def setUp(self): - super(TestMyViewSuccessCondition, self).setUp() - self.init_database() - - from .models import MyModel - - model = MyModel(name='one', value=55) - self.session.add(model) - - def test_passing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info['one'].name, 'one') - self.assertEqual(info['project'], 'myproj') - - -class TestMyViewFailureCondition(BaseTest): - - def test_failing_view(self): - from .views.default import my_view - info = my_view(dummy_request(self.session)) - self.assertEqual(info.status_int, 500) diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index 941a50928..bc11b16e1 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -5,18 +5,15 @@ Adding Tests ============ We will now add tests for the models and views as well as a few functional -tests in a new ``tests`` subpackage. Tests ensure that an application works, +tests in a new ``tests`` package. Tests ensure that an application works, and that it continues to work when changes are made in the future. -The file ``tests.py`` was generated from choosing the ``sqlalchemy`` backend -option, but it is a common practice to put tests into a ``tests`` -subpackage, especially as projects grow in size and complexity. Each module in -the test subpackage should contain tests for its corresponding module in our -application. Each corresponding pair of modules should have the same names, -except the test module should have the prefix ``test_``. +The file ``tests/test_it.py`` at the root of our project directory was generated from choosing the ``sqlalchemy`` backend option. +It is a common practice to put tests into a ``tests`` package alongside the application package, especially as projects grow in size and complexity. +Each module in the test package should contain tests for its corresponding module in our application. +Each corresponding pair of modules should have the same names, except the test module should have the prefix ``test_``. -Start by deleting ``tests.py``, then create a new directory to contain our new -tests as well as a new empty file ``tests/__init__.py``. +Start by deleting ``tests/test_it.py``. .. warning:: @@ -47,36 +44,36 @@ user cannot edit pages that it didn't create but the ``editor`` user can, and so on. -View the results of all our edits to ``tests`` subpackage -========================================================= +View the results of all our edits to ``tests`` package +====================================================== -Create ``tutorial/tests/test_views.py`` such that it appears as follows: +Create ``tests/test_views.py`` such that it appears as follows: -.. literalinclude:: src/tests/tutorial/tests/test_views.py +.. literalinclude:: src/tests/tests/test_views.py :linenos: :language: python -Create ``tutorial/tests/test_functional.py`` such that it appears as follows: +Create ``tests/test_functional.py`` such that it appears as follows: -.. literalinclude:: src/tests/tutorial/tests/test_functional.py +.. literalinclude:: src/tests/tests/test_functional.py :linenos: :language: python -Create ``tutorial/tests/test_initdb.py`` such that it appears as follows: +Create ``tests/test_initdb.py`` such that it appears as follows: -.. literalinclude:: src/tests/tutorial/tests/test_initdb.py +.. literalinclude:: src/tests/tests/test_initdb.py :linenos: :language: python -Create ``tutorial/tests/test_security.py`` such that it appears as follows: +Create ``tests/test_security.py`` such that it appears as follows: -.. literalinclude:: src/tests/tutorial/tests/test_security.py +.. literalinclude:: src/tests/tests/test_security.py :linenos: :language: python -Create ``tutorial/tests/test_user_model.py`` such that it appears as follows: +Create ``tests/test_user_model.py`` such that it appears as follows: -.. literalinclude:: src/tests/tutorial/tests/test_user_model.py +.. literalinclude:: src/tests/tests/test_user_model.py :linenos: :language: python -- cgit v1.2.3 From e9fb506204aee7219c7ebf58bfcaf3e84e41e279 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 21:47:58 -0800 Subject: Add missing description for new test in cookiecutter. --- docs/narr/testing.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'docs') diff --git a/docs/narr/testing.rst b/docs/narr/testing.rst index d89a4d3aa..0fa1e98fd 100644 --- a/docs/narr/testing.rst +++ b/docs/narr/testing.rst @@ -403,8 +403,7 @@ function ``my_view`` that returns an HTML body when the root URL is invoked: :linenos: :language: python -The following example functional test demonstrates invoking the above -:term:`view`: +The following example functional tests demonstrate invoking the above :term:`view`: .. literalinclude:: myproject/tests/test_it.py :linenos: @@ -412,10 +411,13 @@ The following example functional test demonstrates invoking the above :language: python When these tests are run, each test method creates a "real" :term:`WSGI` application using the ``main`` function in your ``myproject.__init__`` module, using :term:`WebTest` to wrap that WSGI application. -It assigns the result to -``self.testapp``. In the test named ``test_root``, the ``TestApp``'s ``GET`` -method is used to invoke the root URL. Finally, an assertion is made that the -returned HTML contains the text ``Pyramid``. +It assigns the result to ``self.testapp``. + +In the test named ``test_root``, the ``TestApp``'s ``GET`` method is used to invoke the root URL. +An assertion is made that the returned HTML contains the text ``Pyramid``. + +In the test named ``test_notfound``, the ``TestApp``'s ``GET`` method is used to invoke a bad URL ``/badurl``. +An assertion is made that the returned status code in the response is ``404``. See the :term:`WebTest` documentation for further information about the methods available to a :class:`webtest.app.TestApp` instance. -- cgit v1.2.3 From b8cc2a85919757bcf5582c683eaff7d384cdfa03 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 23:07:32 -0800 Subject: Resynch docs with cookiecutter - remove unnecessary `omit` line in .coveragerc --- docs/narr/myproject/.coveragerc | 1 - docs/quick_tour/logging/.coveragerc | 1 - docs/quick_tour/package/.coveragerc | 1 - docs/quick_tour/sessions/.coveragerc | 1 - docs/quick_tour/sqla_demo/.coveragerc | 1 - docs/quick_tutorial/cookiecutters/.coveragerc | 1 - docs/tutorials/wiki/src/authorization/.coveragerc | 1 - docs/tutorials/wiki/src/basiclayout/.coveragerc | 1 - docs/tutorials/wiki/src/installation/.coveragerc | 1 - docs/tutorials/wiki/src/models/.coveragerc | 1 - docs/tutorials/wiki/src/tests/.coveragerc | 1 - docs/tutorials/wiki/src/views/.coveragerc | 1 - docs/tutorials/wiki2/src/authentication/.coveragerc | 1 - docs/tutorials/wiki2/src/authorization/.coveragerc | 1 - docs/tutorials/wiki2/src/basiclayout/.coveragerc | 1 - docs/tutorials/wiki2/src/installation/.coveragerc | 1 - docs/tutorials/wiki2/src/models/.coveragerc | 1 - docs/tutorials/wiki2/src/tests/.coveragerc | 1 - docs/tutorials/wiki2/src/views/.coveragerc | 1 - 19 files changed, 19 deletions(-) (limited to 'docs') diff --git a/docs/narr/myproject/.coveragerc b/docs/narr/myproject/.coveragerc index f0c31d6d7..5837f5504 100644 --- a/docs/narr/myproject/.coveragerc +++ b/docs/narr/myproject/.coveragerc @@ -1,3 +1,2 @@ [run] source = myproject -omit = myproject/test* diff --git a/docs/quick_tour/logging/.coveragerc b/docs/quick_tour/logging/.coveragerc index 128e26410..a94933b5f 100644 --- a/docs/quick_tour/logging/.coveragerc +++ b/docs/quick_tour/logging/.coveragerc @@ -1,3 +1,2 @@ [run] source = hello_world -omit = hello_world/test* diff --git a/docs/quick_tour/package/.coveragerc b/docs/quick_tour/package/.coveragerc index 128e26410..a94933b5f 100644 --- a/docs/quick_tour/package/.coveragerc +++ b/docs/quick_tour/package/.coveragerc @@ -1,3 +1,2 @@ [run] source = hello_world -omit = hello_world/test* diff --git a/docs/quick_tour/sessions/.coveragerc b/docs/quick_tour/sessions/.coveragerc index 128e26410..a94933b5f 100644 --- a/docs/quick_tour/sessions/.coveragerc +++ b/docs/quick_tour/sessions/.coveragerc @@ -1,3 +1,2 @@ [run] source = hello_world -omit = hello_world/test* diff --git a/docs/quick_tour/sqla_demo/.coveragerc b/docs/quick_tour/sqla_demo/.coveragerc index 918f8dea0..8b6a8026a 100644 --- a/docs/quick_tour/sqla_demo/.coveragerc +++ b/docs/quick_tour/sqla_demo/.coveragerc @@ -1,3 +1,2 @@ [run] source = sqla_demo -omit = sqla_demo/test* diff --git a/docs/quick_tutorial/cookiecutters/.coveragerc b/docs/quick_tutorial/cookiecutters/.coveragerc index 1bcbb8c3e..8aa37b9e7 100644 --- a/docs/quick_tutorial/cookiecutters/.coveragerc +++ b/docs/quick_tutorial/cookiecutters/.coveragerc @@ -1,3 +1,2 @@ [run] source = cc_starter -omit = cc_starter/test* diff --git a/docs/tutorials/wiki/src/authorization/.coveragerc b/docs/tutorials/wiki/src/authorization/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki/src/authorization/.coveragerc +++ b/docs/tutorials/wiki/src/authorization/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki/src/basiclayout/.coveragerc b/docs/tutorials/wiki/src/basiclayout/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki/src/basiclayout/.coveragerc +++ b/docs/tutorials/wiki/src/basiclayout/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki/src/installation/.coveragerc b/docs/tutorials/wiki/src/installation/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki/src/installation/.coveragerc +++ b/docs/tutorials/wiki/src/installation/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki/src/models/.coveragerc b/docs/tutorials/wiki/src/models/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki/src/models/.coveragerc +++ b/docs/tutorials/wiki/src/models/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki/src/tests/.coveragerc b/docs/tutorials/wiki/src/tests/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki/src/tests/.coveragerc +++ b/docs/tutorials/wiki/src/tests/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki/src/views/.coveragerc b/docs/tutorials/wiki/src/views/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki/src/views/.coveragerc +++ b/docs/tutorials/wiki/src/views/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/authentication/.coveragerc b/docs/tutorials/wiki2/src/authentication/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/authentication/.coveragerc +++ b/docs/tutorials/wiki2/src/authentication/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/authorization/.coveragerc b/docs/tutorials/wiki2/src/authorization/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/authorization/.coveragerc +++ b/docs/tutorials/wiki2/src/authorization/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/basiclayout/.coveragerc b/docs/tutorials/wiki2/src/basiclayout/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/basiclayout/.coveragerc +++ b/docs/tutorials/wiki2/src/basiclayout/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/installation/.coveragerc b/docs/tutorials/wiki2/src/installation/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/installation/.coveragerc +++ b/docs/tutorials/wiki2/src/installation/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/models/.coveragerc b/docs/tutorials/wiki2/src/models/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/models/.coveragerc +++ b/docs/tutorials/wiki2/src/models/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/tests/.coveragerc b/docs/tutorials/wiki2/src/tests/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/tests/.coveragerc +++ b/docs/tutorials/wiki2/src/tests/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* diff --git a/docs/tutorials/wiki2/src/views/.coveragerc b/docs/tutorials/wiki2/src/views/.coveragerc index a1d87d03d..5db0e79cf 100644 --- a/docs/tutorials/wiki2/src/views/.coveragerc +++ b/docs/tutorials/wiki2/src/views/.coveragerc @@ -1,3 +1,2 @@ [run] source = tutorial -omit = tutorial/test* -- cgit v1.2.3 From d0627e1f81334d2e16ec075b8e31f1ab0583b89d Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 1 Jan 2020 23:44:23 -0800 Subject: run linkcheck, update broken links --- docs/glossary.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/glossary.rst b/docs/glossary.rst index 5a33ff39d..61ba34f45 100644 --- a/docs/glossary.rst +++ b/docs/glossary.rst @@ -61,8 +61,7 @@ Glossary .. seealso:: - See also `PkgResources - `_. + See also `Package Discovery and Resource Access using pkg_resources `_. asset Any file contained within a Python :term:`package` which is *not* @@ -443,7 +442,7 @@ Glossary dispatching and other application configuration tasks. reStructuredText - A `plain text markup format `_ + A `plain text markup format `_ that is the defacto standard for documenting Python projects. The Pyramid documentation is written in reStructuredText. -- cgit v1.2.3 From b5fec394fc63e381d233d4b7a23a5d4e8c5acdd8 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 2 Jan 2020 23:30:21 -0800 Subject: Remove unrepeatable test, per https://github.com/Pylons/pyramid/pull/3556#issuecomment-570474759 --- docs/tutorials/wiki2/src/tests/tests/test_initdb.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/src/tests/tests/test_initdb.py b/docs/tutorials/wiki2/src/tests/tests/test_initdb.py index 9a24f0b22..a66945ccc 100644 --- a/docs/tutorials/wiki2/src/tests/tests/test_initdb.py +++ b/docs/tutorials/wiki2/src/tests/tests/test_initdb.py @@ -8,9 +8,3 @@ class TestInitializeDB(unittest.TestCase): from tutorial.scripts.initialize_db import main with self.assertRaises(SystemExit): main(argv=['foo']) - - def test_run(self): - from tutorial.scripts.initialize_db import main - main(argv=['foo', 'development.ini']) - self.assertTrue(os.path.exists('tutorial.sqlite')) - os.remove('tutorial.sqlite') -- cgit v1.2.3 From ed3d70c00f616ae5979d99d9b1e233117b613f4a Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Thu, 2 Jan 2020 23:36:44 -0800 Subject: Update tests.rst to align with removal of 1 unrepeatable test --- docs/tutorials/wiki2/tests.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index bc11b16e1..c7d1a0f31 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -109,7 +109,7 @@ The expected result should look like the following: .. code-block:: text - ................................ - 32 passed in 9.90 seconds + ............................... + 31 passed in 8.85 seconds .. _webtest: https://docs.pylonsproject.org/projects/webtest/en/latest/ -- cgit v1.2.3 From c4bf8853b67c2a178f2bd84d8cb6d76f21269f90 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Fri, 3 Jan 2020 18:25:02 -0800 Subject: Stupid PyCharm caching of diff will be the death of me --- docs/tutorials/wiki2/src/authentication/tutorial/views/auth.py | 2 +- docs/tutorials/wiki2/src/authorization/tutorial/views/auth.py | 2 +- docs/tutorials/wiki2/src/tests/tutorial/views/auth.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/tutorials/wiki2/src/authentication/tutorial/views/auth.py b/docs/tutorials/wiki2/src/authentication/tutorial/views/auth.py index 2b993b430..16fa616e5 100644 --- a/docs/tutorials/wiki2/src/authentication/tutorial/views/auth.py +++ b/docs/tutorials/wiki2/src/authentication/tutorial/views/auth.py @@ -11,7 +11,7 @@ from pyramid.view import ( from ..models import User -@view_config(route_name='login', renderer='../templates/login.jinja2') +@view_config(route_name='login', renderer='tutorial:templates/login.jinja2') def login(request): next_url = request.params.get('next', request.referrer) if not next_url: diff --git a/docs/tutorials/wiki2/src/authorization/tutorial/views/auth.py b/docs/tutorials/wiki2/src/authorization/tutorial/views/auth.py index 2b993b430..16fa616e5 100644 --- a/docs/tutorials/wiki2/src/authorization/tutorial/views/auth.py +++ b/docs/tutorials/wiki2/src/authorization/tutorial/views/auth.py @@ -11,7 +11,7 @@ from pyramid.view import ( from ..models import User -@view_config(route_name='login', renderer='../templates/login.jinja2') +@view_config(route_name='login', renderer='tutorial:templates/login.jinja2') def login(request): next_url = request.params.get('next', request.referrer) if not next_url: diff --git a/docs/tutorials/wiki2/src/tests/tutorial/views/auth.py b/docs/tutorials/wiki2/src/tests/tutorial/views/auth.py index 2b993b430..16fa616e5 100644 --- a/docs/tutorials/wiki2/src/tests/tutorial/views/auth.py +++ b/docs/tutorials/wiki2/src/tests/tutorial/views/auth.py @@ -11,7 +11,7 @@ from pyramid.view import ( from ..models import User -@view_config(route_name='login', renderer='../templates/login.jinja2') +@view_config(route_name='login', renderer='tutorial:templates/login.jinja2') def login(request): next_url = request.params.get('next', request.referrer) if not next_url: -- cgit v1.2.3 From b629ee810ccf9ffb4f166f3e766c8f795a0cecdb Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 3 Jan 2020 22:53:51 -0600 Subject: remove inotify --- docs/narr/project.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/narr/project.rst b/docs/narr/project.rst index fc5cfd056..c65bdb178 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -1168,7 +1168,7 @@ inotify support By default ``hupper`` will poll the filesystem for changes to all Python code. This can be pretty inefficient in larger projects. To be nicer to your hard drive, you should install either the `watchman `_ or `watchdog `_ package in development. -``hupper`` will use, in order of preference for efficiency, if available, ``watchman``, ``watchdog``, then finally ``inotify`` to poll the filesystem. +``hupper`` will use, in order of preference for efficiency, if available, ``watchman``, ``watchdog``, or finally polling to detect changes to the filesystem. Monitoring Custom Files ~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.2.3 From b349c2ba948148d2f5441308c6646f624100b364 Mon Sep 17 00:00:00 2001 From: Michael Merickel Date: Fri, 3 Jan 2020 22:59:27 -0600 Subject: exclude tests package from source packages --- docs/narr/commandline.rst | 2 +- docs/narr/myproject/setup.py | 2 +- docs/narr/project.rst | 2 +- docs/quick_tour/logging/setup.py | 2 +- docs/quick_tour/package/setup.py | 2 +- docs/quick_tour/sessions/setup.py | 2 +- docs/quick_tour/sqla_demo/setup.py | 2 +- docs/quick_tutorial/cookiecutters/setup.py | 2 +- docs/tutorials/wiki/src/authorization/setup.py | 2 +- docs/tutorials/wiki/src/basiclayout/setup.py | 2 +- docs/tutorials/wiki/src/installation/setup.py | 2 +- docs/tutorials/wiki/src/models/setup.py | 2 +- docs/tutorials/wiki/src/tests/setup.py | 2 +- docs/tutorials/wiki/src/views/setup.py | 2 +- docs/tutorials/wiki2/src/authentication/setup.py | 2 +- docs/tutorials/wiki2/src/authorization/setup.py | 2 +- docs/tutorials/wiki2/src/basiclayout/setup.py | 2 +- docs/tutorials/wiki2/src/installation/setup.py | 2 +- docs/tutorials/wiki2/src/models/setup.py | 2 +- docs/tutorials/wiki2/src/tests/setup.py | 2 +- docs/tutorials/wiki2/src/views/setup.py | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) (limited to 'docs') diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 0c5189903..149488206 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -1025,7 +1025,7 @@ top-level directory, your ``setup.py`` file will look something like this: author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, install_requires=requires, diff --git a/docs/narr/myproject/setup.py b/docs/narr/myproject/setup.py index 40aa2c53b..e5872df29 100644 --- a/docs/narr/myproject/setup.py +++ b/docs/narr/myproject/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/narr/project.rst b/docs/narr/project.rst index c65bdb178..043f77754 100644 --- a/docs/narr/project.rst +++ b/docs/narr/project.rst @@ -803,7 +803,7 @@ application. ``author`` and ``author_email`` are text fields which probably don't need any description. ``url`` is a field that should point at your application project's URL (if any). ``keywords`` are keywords that describe your project. -``packages=find_packages()`` causes all +``packages=find_packages(exclude=['tests'])`` causes all packages within the project to be found when packaging the application. ``include_package_data`` will include non-Python files when the application is packaged if those files are checked into version control. ``zip_safe=False`` diff --git a/docs/quick_tour/logging/setup.py b/docs/quick_tour/logging/setup.py index e9c15db04..1fec15ce5 100644 --- a/docs/quick_tour/logging/setup.py +++ b/docs/quick_tour/logging/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tour/package/setup.py b/docs/quick_tour/package/setup.py index e9c15db04..1fec15ce5 100644 --- a/docs/quick_tour/package/setup.py +++ b/docs/quick_tour/package/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tour/sessions/setup.py b/docs/quick_tour/sessions/setup.py index e9c15db04..1fec15ce5 100644 --- a/docs/quick_tour/sessions/setup.py +++ b/docs/quick_tour/sessions/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tour/sqla_demo/setup.py b/docs/quick_tour/sqla_demo/setup.py index 23740ba9f..f3302a7e9 100644 --- a/docs/quick_tour/sqla_demo/setup.py +++ b/docs/quick_tour/sqla_demo/setup.py @@ -43,7 +43,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/quick_tutorial/cookiecutters/setup.py b/docs/quick_tutorial/cookiecutters/setup.py index d5d3d018b..9c9d54e5b 100644 --- a/docs/quick_tutorial/cookiecutters/setup.py +++ b/docs/quick_tutorial/cookiecutters/setup.py @@ -37,7 +37,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki/src/authorization/setup.py b/docs/tutorials/wiki/src/authorization/setup.py index fa5948acb..f19d643e6 100644 --- a/docs/tutorials/wiki/src/authorization/setup.py +++ b/docs/tutorials/wiki/src/authorization/setup.py @@ -44,7 +44,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki/src/basiclayout/setup.py b/docs/tutorials/wiki/src/basiclayout/setup.py index d6d488ed2..f85780010 100644 --- a/docs/tutorials/wiki/src/basiclayout/setup.py +++ b/docs/tutorials/wiki/src/basiclayout/setup.py @@ -42,7 +42,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki/src/installation/setup.py b/docs/tutorials/wiki/src/installation/setup.py index d6d488ed2..f85780010 100644 --- a/docs/tutorials/wiki/src/installation/setup.py +++ b/docs/tutorials/wiki/src/installation/setup.py @@ -42,7 +42,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki/src/models/setup.py b/docs/tutorials/wiki/src/models/setup.py index d6d488ed2..f85780010 100644 --- a/docs/tutorials/wiki/src/models/setup.py +++ b/docs/tutorials/wiki/src/models/setup.py @@ -42,7 +42,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki/src/tests/setup.py b/docs/tutorials/wiki/src/tests/setup.py index fa5948acb..f19d643e6 100644 --- a/docs/tutorials/wiki/src/tests/setup.py +++ b/docs/tutorials/wiki/src/tests/setup.py @@ -44,7 +44,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki/src/views/setup.py b/docs/tutorials/wiki/src/views/setup.py index 6f3cae397..439bb7759 100644 --- a/docs/tutorials/wiki/src/views/setup.py +++ b/docs/tutorials/wiki/src/views/setup.py @@ -43,7 +43,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/authentication/setup.py b/docs/tutorials/wiki2/src/authentication/setup.py index a99793c15..500c5e599 100644 --- a/docs/tutorials/wiki2/src/authentication/setup.py +++ b/docs/tutorials/wiki2/src/authentication/setup.py @@ -45,7 +45,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/authorization/setup.py b/docs/tutorials/wiki2/src/authorization/setup.py index a99793c15..500c5e599 100644 --- a/docs/tutorials/wiki2/src/authorization/setup.py +++ b/docs/tutorials/wiki2/src/authorization/setup.py @@ -45,7 +45,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/basiclayout/setup.py b/docs/tutorials/wiki2/src/basiclayout/setup.py index a0efdea6d..5e7a0111d 100644 --- a/docs/tutorials/wiki2/src/basiclayout/setup.py +++ b/docs/tutorials/wiki2/src/basiclayout/setup.py @@ -43,7 +43,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/installation/setup.py b/docs/tutorials/wiki2/src/installation/setup.py index a0efdea6d..5e7a0111d 100644 --- a/docs/tutorials/wiki2/src/installation/setup.py +++ b/docs/tutorials/wiki2/src/installation/setup.py @@ -43,7 +43,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/models/setup.py b/docs/tutorials/wiki2/src/models/setup.py index da99411a0..60234751a 100644 --- a/docs/tutorials/wiki2/src/models/setup.py +++ b/docs/tutorials/wiki2/src/models/setup.py @@ -44,7 +44,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/tests/setup.py b/docs/tutorials/wiki2/src/tests/setup.py index a99793c15..500c5e599 100644 --- a/docs/tutorials/wiki2/src/tests/setup.py +++ b/docs/tutorials/wiki2/src/tests/setup.py @@ -45,7 +45,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ diff --git a/docs/tutorials/wiki2/src/views/setup.py b/docs/tutorials/wiki2/src/views/setup.py index a99793c15..500c5e599 100644 --- a/docs/tutorials/wiki2/src/views/setup.py +++ b/docs/tutorials/wiki2/src/views/setup.py @@ -45,7 +45,7 @@ setup( author_email='', url='', keywords='web pyramid pylons', - packages=find_packages(), + packages=find_packages(exclude=['tests']), include_package_data=True, zip_safe=False, extras_require={ -- cgit v1.2.3