Skip to content

Commit

Permalink
Avoid deprecated SoftDeletableModel.objects manager in tests
Browse files Browse the repository at this point in the history
Use the `available_objects` manager instead.
  • Loading branch information
mthuurne committed Apr 16, 2024
1 parent 8009616 commit 512d0f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ def only_read(self):
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:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_managers/test_softdelete_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
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)

0 comments on commit 512d0f1

Please sign in to comment.