Add fixtures for user request factories, clients#568
Open
tony wants to merge 4 commits intopytest-dev:mainfrom
Open
Add fixtures for user request factories, clients#568tony wants to merge 4 commits intopytest-dev:mainfrom
tony wants to merge 4 commits intopytest-dev:mainfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #568 +/- ##
=========================================
+ Coverage 91.92% 92.3% +0.37%
=========================================
Files 33 33
Lines 1660 1741 +81
Branches 143 144 +1
=========================================
+ Hits 1526 1607 +81
Misses 95 95
Partials 39 39
Continue to review full report at Codecov.
|
b3c08be to
981d032
Compare
Member
Author
Contributor
|
Yes, yes, and yes, please.. :) |
Fixes pytest-dev#565 This is based on conversations in issues pytest-dev#553, pytest-dev#554, and pytest-dev#284 - Introduces a django_user fixture, which is a user with no additional priveleges. Similar to admin_user. - A user_client, based on django_user. Similar to admin_client. - 3 new RequestFactory based fixtures, for unauthenticated, authenticated, and admin users: - rf_unauth: relies on AnonymousUser, similar to django docs example. - rf_admin: relies on admin_user fixture - rf_user: relies on new django_user fixture In addition, these 3 fixtures differ from rf in that they: - Mimic AuthenticationMiddleware by add the user attribute to the request object - Mimic SessionMiddleware by adding the 'session' attribute to the request object. This is an in-memory session store object from ``django.contrib.sessions.backends.base.SessionBase``. This fills the gaps left over by not having normal and unauthenticated user objects, clients, and request factories (when admin ones were available), and also covers a common case likely present in Django projects - anonymous (not logged in), authenticated, and admin users. Also, Update fixtures.py with changes from @blueyed
Update helpers.rst with corrections from @blueyed
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #565
This is based on conversations in issues #553, #554, and #284
Introduces a django_user fixture, which is a user with no additional
priveleges. Similar to admin_user.
A user_client, based on django_user. Similar to admin_client.
3 new RequestFactory based fixtures, for unauthenticated,
authenticated, and admin users:
example.
In addition, these 3 fixtures differ from rf in that they:
the request object
to the request object. This is an in-memory session store object
from
django.contrib.sessions.backends.base.SessionBase.This fills the gaps left over by not having normal and unauthenticated
user objects, clients, and request factories (when admin ones were
available), and also covers a common case likely present in Django
projects - anonymous (not logged in), authenticated, and admin users.