mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-03-16 20:00:23 +00:00
Avoid deprecated SoftDeletableModel.objects manager in tests
Use the `available_objects` manager instead.
This commit is contained in:
parent
800961626a
commit
512d0f1890
2 changed files with 7 additions and 7 deletions
|
|
@ -360,7 +360,7 @@ class CustomSoftDeleteQuerySet(SoftDeletableQuerySet):
|
|||
class CustomSoftDelete(SoftDeletableModel):
|
||||
is_read = models.BooleanField(default=False)
|
||||
|
||||
objects = SoftDeletableManager.from_queryset(CustomSoftDeleteQuerySet)() # type: ignore[misc]
|
||||
available_objects = SoftDeletableManager.from_queryset(CustomSoftDeleteQuerySet)() # type: ignore[misc]
|
||||
|
||||
|
||||
class StringyDescriptor:
|
||||
|
|
|
|||
|
|
@ -6,21 +6,21 @@ from tests.models import CustomSoftDelete
|
|||
class CustomSoftDeleteManagerTests(TestCase):
|
||||
|
||||
def test_custom_manager_empty(self):
|
||||
qs = CustomSoftDelete.objects.only_read()
|
||||
qs = CustomSoftDelete.available_objects.only_read()
|
||||
self.assertEqual(qs.count(), 0)
|
||||
|
||||
def test_custom_qs_empty(self):
|
||||
qs = CustomSoftDelete.objects.all().only_read()
|
||||
qs = CustomSoftDelete.available_objects.all().only_read()
|
||||
self.assertEqual(qs.count(), 0)
|
||||
|
||||
def test_is_read(self):
|
||||
for is_read in [True, False, True, False]:
|
||||
CustomSoftDelete.objects.create(is_read=is_read)
|
||||
qs = CustomSoftDelete.objects.only_read()
|
||||
CustomSoftDelete.available_objects.create(is_read=is_read)
|
||||
qs = CustomSoftDelete.available_objects.only_read()
|
||||
self.assertEqual(qs.count(), 2)
|
||||
|
||||
def test_is_read_removed(self):
|
||||
for is_read, is_removed in [(True, True), (True, False), (False, False), (False, True)]:
|
||||
CustomSoftDelete.objects.create(is_read=is_read, is_removed=is_removed)
|
||||
qs = CustomSoftDelete.objects.only_read()
|
||||
CustomSoftDelete.available_objects.create(is_read=is_read, is_removed=is_removed)
|
||||
qs = CustomSoftDelete.available_objects.only_read()
|
||||
self.assertEqual(qs.count(), 1)
|
||||
|
|
|
|||
Loading…
Reference in a new issue