From f10f81ccdfbf44cfa92ef5fcdcb84e6fed4053fb Mon Sep 17 00:00:00 2001 From: Theron Luhn Date: Sat, 7 Nov 2020 11:28:05 -0800 Subject: Remove request.user from wiki2 testing tutorial. --- docs/tutorials/wiki2/tests.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/tutorials/wiki2/tests.rst') diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index 1bf38d988..cee7a809d 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -110,7 +110,7 @@ Integration tests We can directly execute the view code, bypassing :app:`Pyramid` and testing just the code that we've written. These tests use dummy requests that we'll prepare appropriately to set the conditions each view expects. -For example, setting ``request.user``, or adding some dummy data to the session. +For example, setting ``request.identity``, or adding some dummy data to the session. Update ``tests/test_views.py`` such that it appears as follows: -- cgit v1.2.3 From 7933c51abd4b716aea9199acdc8cc7ec9296d07e Mon Sep 17 00:00:00 2001 From: Theron Luhn Date: Wed, 11 Nov 2020 21:44:05 -0800 Subject: Add to test documentation. --- docs/tutorials/wiki2/tests.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'docs/tutorials/wiki2/tests.rst') diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index cee7a809d..dce14cf9b 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -69,6 +69,9 @@ Per-test fixtures - ``dummy_request`` - a :class:`pyramid.testing.DummyRequest` object that is very lightweight. This is a great object to pass to view functions that have minimal side-effects as it'll be fast and simple. +- ``dummy_config`` — a :class:`pyramid.config.Configurator` object used as configuration by ``dummy_request``. + Useful for mocking configuration like routes and security policies. + Modifying the fixtures ---------------------- @@ -109,8 +112,8 @@ Integration tests ================= We can directly execute the view code, bypassing :app:`Pyramid` and testing just the code that we've written. -These tests use dummy requests that we'll prepare appropriately to set the conditions each view expects. -For example, setting ``request.identity``, or adding some dummy data to the session. +These tests use dummy requests that we'll prepare appropriately to set the conditions each view expects, such as adding dummy data to the session. +We'll be using ``dummy_config`` to configure the necessary routes, as well as setting the security policy as :class:`pyramid.testing.DummySecurityPolicy` to mock ``dummy_request.identity``. Update ``tests/test_views.py`` such that it appears as follows: -- cgit v1.2.3 From 86cb46d4d977d3a948308326bee628421cab93ea Mon Sep 17 00:00:00 2001 From: Theron Luhn Date: Wed, 11 Nov 2020 21:53:35 -0800 Subject: Remove `app_request` from wiki2 tests. --- docs/tutorials/wiki2/tests.rst | 3 --- 1 file changed, 3 deletions(-) (limited to 'docs/tutorials/wiki2/tests.rst') diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index dce14cf9b..4ea2e2e15 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -63,9 +63,6 @@ Per-test fixtures The ``testapp`` is able to mutate the request environ such that the ``dbsession`` and ``tm`` fixtures are injected and used by any code that's touching ``request.dbsession`` and ``request.tm``. The ``testapp`` maintains a cookiejar, so it can be used to share state across requests, as well as the transaction database connection. -- ``app_request`` - a :class:`pyramid.request.Request` object that can be used for more lightweight tests versus the full ``testapp``. - The ``app_request`` can be passed to view functions and other code that need a fully functional request object. - - ``dummy_request`` - a :class:`pyramid.testing.DummyRequest` object that is very lightweight. This is a great object to pass to view functions that have minimal side-effects as it'll be fast and simple. -- cgit v1.2.3 From ea25ec5cd5715ab3dcf266a968166425e279927a Mon Sep 17 00:00:00 2001 From: Theron Luhn Date: Fri, 11 Dec 2020 09:22:15 -0800 Subject: Revert "Remove `app_request` from wiki2 tests." This reverts commit 86cb46d4d977d3a948308326bee628421cab93ea. --- docs/tutorials/wiki2/tests.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs/tutorials/wiki2/tests.rst') diff --git a/docs/tutorials/wiki2/tests.rst b/docs/tutorials/wiki2/tests.rst index 4ea2e2e15..dce14cf9b 100644 --- a/docs/tutorials/wiki2/tests.rst +++ b/docs/tutorials/wiki2/tests.rst @@ -63,6 +63,9 @@ Per-test fixtures The ``testapp`` is able to mutate the request environ such that the ``dbsession`` and ``tm`` fixtures are injected and used by any code that's touching ``request.dbsession`` and ``request.tm``. The ``testapp`` maintains a cookiejar, so it can be used to share state across requests, as well as the transaction database connection. +- ``app_request`` - a :class:`pyramid.request.Request` object that can be used for more lightweight tests versus the full ``testapp``. + The ``app_request`` can be passed to view functions and other code that need a fully functional request object. + - ``dummy_request`` - a :class:`pyramid.testing.DummyRequest` object that is very lightweight. This is a great object to pass to view functions that have minimal side-effects as it'll be fast and simple. -- cgit v1.2.3