From 559faf7ff732a83c44706d92ced6c7f5443c1b7c Mon Sep 17 00:00:00 2001 From: Ronny Vedrilla Date: Fri, 12 Jan 2024 09:49:23 +0100 Subject: [PATCH] v9.4.1 --- CHANGES.md | 3 +++ ambient_toolbox/__init__.py | 2 +- docs/features/tests.md | 21 ++++++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fb04237..95fa9e9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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 diff --git a/ambient_toolbox/__init__.py b/ambient_toolbox/__init__.py index 07c81c0..c4b254d 100644 --- a/ambient_toolbox/__init__.py +++ b/ambient_toolbox/__init__.py @@ -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" diff --git a/docs/features/tests.md b/docs/features/tests.md index c919280..23b02f7 100644 --- a/docs/features/tests.md +++ b/docs/features/tests.md @@ -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 @@ -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. @@ -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 @@ -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