Commit graph

42 commits

Author SHA1 Message Date
Nick Prat
e777819073
Fixed an infinite recursion bug when deleting models related to a tracked model with a ForeignKey (#620)
* Fixed an infinite recursion bug when deleting a model, that has a reverse relationship to a tracked model with SET_NULL on_delete

---------

Co-authored-by: Napat Ch <napat@thevcgroup.com>
2025-04-03 19:58:57 +02:00
Maarten ter Huurne
3c314234ff Drop uses of JoinManager from the tests
The `JoinManager` class is deprecated and not annotated.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
c83ef89bc9 Annotate test helpers 2024-06-13 12:02:05 +02:00
Maarten ter Huurne
218843d754 Add minimal annotations to unit tests
These annotations are sufficient to pass mypy inspection if mypy is
configured to allow unannotated functions.
2024-06-13 12:02:05 +02:00
Maarten ter Huurne
a6b0a2aff7 Fix and re-enable AbstractModelTrackerTests
There used to be a [bug in Django](https://code.djangoproject.com/ticket/30427)
that caused these tests to fail, according to the discussion of #370.
That bug was fixed in Django 4.0.

However, because the test model was using a `FieldTracker`
rather than a `ModelTracker`, all model-specific test cases
in `ModelTrackerTests` continued to fail.
2024-06-12 16:54:14 +02:00
Maarten ter Huurne
512d0f1890 Avoid deprecated SoftDeletableModel.objects manager in tests
Use the `available_objects` manager instead.
2024-04-16 04:02:33 +02:00
Maarten ter Huurne
800961626a Move CustomSoftDeleteQuerySet to tests.models
The `CustomSoftDeleteQuerySet` class was the only code left in
the `test.managers` module, while it is not in fact a `Manager`.
2024-04-16 04:02:33 +02:00
Maarten ter Huurne
68a4c14c74 Auto-generate manager implementation for CustomSoftDelete
Besides requiring less code, this also allows the django-stubs
mypy plugin to automatically generate a type-annotated version
of the manager.

Unfortunately, the plugin does not put a `ClassVar` annotation
on `objects`, which is why we need the suppression.
2024-04-16 04:02:12 +02:00
Maarten ter Huurne
2f58a1160d Add minimal type annotations to make mypy pass
Avoid using `Self` as a type argument: for some reason this fails
when mypy has an empty cache, but passes when the cache has been
filled. Maybe it's a weird interaction between the mypy core and
the django-stubs plugin?
2024-04-05 17:16:06 +02:00
Guilherme Martins Crocetti
4c9d6eee13
feat(monitor): Change default to None when the field is marked as nullable and no default is provided (#599) 2024-04-04 10:26:17 +02:00
Maarten ter Huurne
d320924383
Forward additional arguments to contribute_to_class() to Django (#605)
* Pass additional arguments to superclass `contribute_to_class()`

In Django 3.2 there is an additional argument `private_only` and more
could be added in future versions.
2024-04-03 08:53:52 +02:00
Maarten ter Huurne
9df3df99cf Remove obsolete NoRendered test model
The code under test was removed in fda2d39e, but this model remained.
2024-03-22 18:50:05 +01:00
Maarten ter Huurne
6c39b58cb4 Remove FeaturedManager and related obsolete test model code
The code under test was removed in 6ae66e01, but some of the test code
remained.
2024-03-22 18:43:45 +01:00
Jelmer
6e722b51b0
Merge pull request #596 from ProtixIT/status-test-model-naming
Resolve name clash among test models
2024-03-22 18:00:40 +01:00
Maarten ter Huurne
ed4f04f282 Resolve name clash among test models
There were two classes named `StatusCustomManager`: the first is an
actual manager, the second a status model that uses a custom manager.
The latter is renamed to `CustomManagerStatusModel` in this commit.
2024-03-22 17:32:51 +01:00
Maarten ter Huurne
b7677161cb Remove redundant definition of JoinManager from tests
The `JoinManager` class already exists in `model_utils.managers`,
with the exact same definition.
2024-03-22 16:29:37 +01:00
Adam Johnson
11f3a53b0f Remove SaveSignalHandlingModel 2023-10-26 16:56:30 +01:00
Serhii Tereshchenko
0ec4ac5e38
fix: Use proper column name instead of attname (#573)
fix: Use proper column name instead of attname
2023-06-16 15:34:47 +02:00
Hasan Ramezani
b354d90c20 Drop support for Django < 3.2 2022-08-17 23:08:29 +02:00
Hasan Ramezani
2269f810c8 Fix TypeError in save when model inherits from both TimeStampModel and StatusModel. (Fixes GH-465) 2020-12-02 00:07:22 +01:00
David Smith
79ff8ea6be
Used isort to sort imports (#460) 2020-11-29 20:58:00 +00:00
Hasan Ramezani
79cbc96055 Replace ugettext_lazy with gettext_lazy in test models to satisfy Django deprecation warning. 2020-11-28 19:26:34 +01:00
Arseniy Panfilov
fdd3af34d9 failing tests with different types of arguments for 'updated_fields' 2020-10-15 15:51:33 +06:00
Sergey Tikhonov
1386c379b7 FieldTracker should patch save_base instead of save (#404)
* add test for reproducing FieldTracker update_fields issue

FieldTracker does not see update_fields changed in tracked model.save() method

* Patch Model.save_base instead of save

This change allows proper capturing update_fields kwarg if is is changed in overridden save() method.

* Add some details about FieldTracker implementation

* Mention FieldTracker behavior change
2019-12-15 22:43:58 +06:00
Misha K
5aa40c66be Add django 3.0 to the test matrix and drop six (#395)
*  - add django 3.0 to the test matrix
 - drop six

* add entry in CHANGES

* remove context kwarg

* fix test with DeferredAttribute

* rename StringyDescriptor's name to attname

* Fix flake8

* Drop support for Django 1.11 because the API are not compatibles anymore with Django 3.0

* Try to fix tests.

* Define model for the field mock.

* Simplifies the code.

* Properly mock the field.

* Typo

* Use the new API field name.

* Call it attname

* Grab the field instance from the model.

* Use postgres in travis tests.

* Django 2.0.1 minimum is needed.

* Update Changelog to tell about breaking Django 1.11.

* Update changelog to tell about Django 3.0 support.

* @natim review.
2019-12-09 19:37:16 +06:00
Adam Dobrawy
ffa1a85dc7 Modernize Python syntax, add Python 3.8 (#398)
* Modernize Python syntax, add Python 3.8

* Update Python version & dist in TravisCI

* Add postgresql as addon

* Switch to psycopg2-binary

* Drop django.utils.six
2019-11-14 22:50:04 +06:00
Hasan Ramezani
aa94194dbc Drop Python 2 support. (#394) 2019-09-30 14:08:52 +06:00
asday
d9aa34e498 Fixed spacing.
Extraneous whitespace, too many blank lines, and too few blank
lines.
2019-08-19 22:38:05 +01:00
asday
b7483fa538 Removed an unused import. 2019-08-19 22:37:01 +01:00
Emin Bugra Saral
5d6f8f4e9f Disable signals on save feature 2019-05-20 19:35:05 +02:00
Asif Saif Uddin
25dde41418
Merge pull request #360 from marfyl/master
Add UUIDModel and UUIDField
2019-05-16 05:45:53 +06:00
Jack Cushman
f2e97e4141 Move patch_save to finalize_class so it works on models with save() methods 2019-04-25 17:50:08 -04:00
Nick Sandford
d557c42533 Catch deferred attribute exception (#367) 2019-03-29 12:46:40 +06:00
Skia
1b9b5ac2c1 managers: honor OneToOneField.parent_link=False (#363) 2019-03-12 23:29:02 +06:00
JMP
8d9a00b89b Fix pep8 error 2019-02-26 18:16:01 +01:00
JMP
5ff0867bf9 UUIDModels for testing purposes 2019-02-26 17:35:50 +01:00
Jonathan Sundqvist
2cb773372d Add a JoinManager that helps with performance (#351)
* Add the join manager + tests

* Documentation for join manager

* Use order_by for consistent tests

* Use postgres instead sqlite for tests for better reliability

* Fix coverage

* Drop django 1.8
2018-11-25 20:18:23 +06:00
Lucas Wiman
679aed41a2 Remove unused __unicode__ method (dead code). 2018-07-02 11:52:05 -07:00
Lucas Wiman
15f9393bb2 Handle API change in DeferredAttribute descriptor in django-trunk.
This should maintain compatibility with the next version of django.
2018-06-28 13:16:33 -07:00
Lucas Wiman
90ed7fc905 Improve coverage. 2018-06-21 12:41:42 -07:00
Lucas Wiman
be52bc9290 Add failing test for deferred attributes. 2018-06-21 12:41:42 -07:00
Bruno Alla
10ebc16271 Exclude tests from distribution
fixes #258
2017-02-15 23:00:10 +00:00
Renamed from model_utils/tests/models.py (Browse further)