Skip to content

Document use of authenticated client and django_user_model - #554

Merged
blueyed merged 1 commit into
pytest-dev:masterfrom
shacker:shacker_doc_cleanup
Dec 25, 2017
Merged

Document use of authenticated client and django_user_model#554
blueyed merged 1 commit into
pytest-dev:masterfrom
shacker:shacker_doc_cleanup

Conversation

@shacker

@shacker shacker commented Dec 6, 2017

Copy link
Copy Markdown
Contributor

- Includes misc documentation cleanup
Comment thread docs/helpers.rst

Environment autouse fixtures
----------------------------
Automatic cleanup

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this title because they appear to the end developer not as fixtures but as general features of pytest-django.

Comment thread docs/helpers.rst
--------


Example with ``rf``, ``admin_user``, fixture and class-based views

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this example because it was not at all clear how it demonstrates the automatic cleanup discussed in this section. If an example is needed, hopefully we can come up with something more succinct and demonstrative.

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #554 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #554   +/-   ##
=====================================
  Coverage      92%    92%           
=====================================
  Files          33     33           
  Lines        1627   1627           
  Branches      140    140           
=====================================
  Hits         1497   1497           
  Misses         93     93           
  Partials       37     37
Flag Coverage Δ
#dj110 84.75% <ø> (ø) ⬆️
#dj111 86.04% <ø> (ø) ⬆️
#dj18 85.61% <ø> (ø) ⬆️
#dj19 84.63% <ø> (ø) ⬆️
#dj20 84.32% <ø> (ø) ⬆️
#djmaster 84.32% <ø> (ø) ⬆️
#mysql_innodb 84.26% <ø> (ø) ⬆️
#mysql_myisam 84.2% <ø> (ø) ⬆️
#postgres 87.64% <ø> (ø) ⬆️
#py27 89.36% <ø> (ø) ⬆️
#py34 84.63% <ø> (ø) ⬆️
#py35 84.75% <ø> (ø) ⬆️
#py36 84.81% <ø> (ø) ⬆️
#sqlite 86.1% <ø> (ø) ⬆️
#sqlite_file 84.63% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94cccb9...4f26394. Read the comment docs.

@codecov-io

Copy link
Copy Markdown

Codecov Report

Merging #554 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #554   +/-   ##
=====================================
  Coverage      92%    92%           
=====================================
  Files          33     33           
  Lines        1627   1627           
  Branches      140    140           
=====================================
  Hits         1497   1497           
  Misses         93     93           
  Partials       37     37
Flag Coverage Δ
#dj110 84.75% <ø> (ø) ⬆️
#dj111 86.04% <ø> (ø) ⬆️
#dj18 85.61% <ø> (ø) ⬆️
#dj19 84.63% <ø> (ø) ⬆️
#dj20 84.32% <ø> (ø) ⬆️
#djmaster 84.32% <ø> (ø) ⬆️
#mysql_innodb 84.26% <ø> (ø) ⬆️
#mysql_myisam 84.2% <ø> (ø) ⬆️
#postgres 87.64% <ø> (ø) ⬆️
#py27 89.36% <ø> (ø) ⬆️
#py34 84.63% <ø> (ø) ⬆️
#py35 84.75% <ø> (ø) ⬆️
#py36 84.81% <ø> (ø) ⬆️
#sqlite 86.1% <ø> (ø) ⬆️
#sqlite_file 84.63% <ø> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94cccb9...4f26394. Read the comment docs.

@blueyed
blueyed merged commit 2611a5c into pytest-dev:master Dec 25, 2017
@blueyed

blueyed commented Dec 25, 2017

Copy link
Copy Markdown
Contributor

Thank you!

tony added a commit to develtech/pytest-django that referenced this pull request Dec 26, 2017
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.
tony added a commit to develtech/pytest-django that referenced this pull request Dec 26, 2017
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.
tony added a commit to develtech/pytest-django that referenced this pull request Dec 26, 2017
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.
tony added a commit to develtech/pytest-django that referenced this pull request Jan 18, 2018
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.
tony added a commit to develtech/pytest-django that referenced this pull request Jan 18, 2018
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
timb07 pushed a commit to timb07/pytest-django that referenced this pull request May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants