forked from pytest-dev/pytest-django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fixtures for user request factories, clients
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.
- Loading branch information
Showing
2 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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