Skip to content

Commit

Permalink
v9.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
GitRon committed Jan 12, 2024
1 parent e44f38c commit 559faf7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

**9.4.1** (2024-01-12)
* Updated testing docs

**9.4.0** (2023-12-05)
* Support for Django 5.0 added

Expand Down
2 changes: 1 addition & 1 deletion ambient_toolbox/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Python toolbox of Ambient Digital containing an abundance of useful tools and gadgets."""

__version__ = "9.4.0"
__version__ = "9.4.1"
21 changes: 12 additions & 9 deletions docs/features/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ class MyViewTestCase(ClassBasedViewTestMixin, TestCase):

### RequestProviderMixin

In many cases you will find yourself in the position that you need a request in your unittests. A wise programmer will
of course try to avoid looping the request object through all services - but from time to time you just end up with a
well written method which takes the request as a parameter.
In many cases, you will find yourself in the position that you need a request in your unittests.
A wise programmer will try to avoid looping the request object through all services but from time to time you end up
with a well-written method which takes the request as a parameter.

For these cases the toolbox provides a handy mixin, from which you can easily derive your test class. Then you will be
able to use a method called `get_request(user=None)`. If you specify a user, he/she will be the request user. In most
cases you won't need to set an explicit url, so `/` will be taken as a default. If you do need it, just pass set
the `url` parameter.
For these cases, the toolbox provides a handy mixin, from which you can derive your test class.
Then you will be able to use a method called `get_request(user=None)`.
If you specify a user, he/she will be the request user.
In most cases you won't need to set an explicit url, so `/` will be taken as a default.
If you do need it, pass set the `url` parameter.

````python
from django.test import TestCase
Expand Down Expand Up @@ -69,7 +70,7 @@ Please refer to the view layer section to get details about how to use this view
### DjangoMessagingFrameworkTestMixin

If you're working with Django views, you might want to use (and therefore test) the Django messaging framework. To make
this as easy as possible, just inherit your view test class from the `DjangoMessagingFrameworkTestMixin`.
this as easy as possible, inherit your view test class from the `DjangoMessagingFrameworkTestMixin`.

You can either check for a full message or just for a partial one.

Expand All @@ -96,7 +97,7 @@ class MyViewTest(DjangoMessagingFrameworkTestMixin, TestCase):

### Motivation

When working in a Django project, it can happen very easily that you create unit-tests in a way that they won't be
When working on a Django project, it can happen very easily that you create unit tests in a way that they won't be
auto-discovered. The mean thing about this is that you can still run those tests - so it's hard to find those issues.

The most common mistakes are forgetting the `__init__.py` in the directory or not prefixing your python files
Expand All @@ -105,6 +106,8 @@ CI pipeline.

python manage.py validate_test_structure

Note: If you enforce 100% coverage in your project, this check is redundant, since the coverage will detect any
tests / test files which are not executed.

### Configuration

Expand Down

0 comments on commit 559faf7

Please sign in to comment.