Skip to content

Commit

Permalink
added test for Suor#353
Browse files Browse the repository at this point in the history
  • Loading branch information
lampwins authored and Suor committed Jun 19, 2020
1 parent 5a7f63b commit ea70324
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,19 @@ def contribute_to_class(self, cls, name, **kwargs):

class CombinedFieldModel(models.Model):
text = CombinedField(max_length=8, default='example')


# 353
class Foo(models.Model):
uid = models.UUIDField(default=uuid.uuid4)


class Bar(models.Model):
uid = models.UUIDField(default=uuid.uuid4)
foo = models.OneToOneField(
to="Foo",
on_delete=models.SET_NULL,
related_name='related_foo',
blank=True,
null=True
)
10 changes: 10 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,16 @@ def test_352(self):
CombinedFieldModel.objects.create()
list(CombinedFieldModel.objects.cache().all())

def test_353(self):
foo = Foo.objects.create()

bar = Bar.objects.create()

self.assertEqual(Foo.objects.cache().filter(related_foo__isnull=True).count(), 1)
bar.foo = foo
bar.save()
self.assertEqual(Foo.objects.cache().filter(related_foo__isnull=True).count(), 0)


class RelatedTests(BaseTestCase):
fixtures = ['basic']
Expand Down

0 comments on commit ea70324

Please sign in to comment.