Skip to content

Commit

Permalink
Reuse existing models
Browse files Browse the repository at this point in the history
  • Loading branch information
francoisfreitag committed Mar 21, 2023
1 parent 51a59f6 commit 834afc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions tests/djapp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ class StandardModel(models.Model):
foo = models.CharField(max_length=20)


class WithRelation(models.Model):
rel = models.ForeignKey(StandardModel, models.CASCADE)


class NonIntegerPk(models.Model):
foo = models.CharField(max_length=20, primary_key=True)
bar = models.CharField(max_length=20, blank=True)
Expand Down
14 changes: 7 additions & 7 deletions tests/test_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,25 +998,25 @@ def test_class_decorator_related_model_with_post_hook(self):
"""

@factory.django.mute_signals(signals.post_save)
class StandardFactory(factory.django.DjangoModelFactory):
class PointedFactory(factory.django.DjangoModelFactory):
class Meta:
model = models.StandardModel
model = models.PointedModel

@factory.post_generation
def post_action(obj, create, extracted, **kwargs):
pass

class WithRelationFactory(factory.django.DjangoModelFactory):
rel = factory.SubFactory(StandardFactory)
class PointerFactory(factory.django.DjangoModelFactory):
pointed = factory.SubFactory(PointedFactory)

class Meta:
model = models.WithRelation
model = models.PointerModel

WithRelationFactory.create()
PointerFactory.create()

self.handlers.post_save.assert_called_once_with(
signal=mock.ANY,
sender=models.WithRelation,
sender=models.PointerModel,
instance=mock.ANY,
created=True,
update_fields=None,
Expand Down

0 comments on commit 834afc1

Please sign in to comment.