Skip to content

Commit

Permalink
Update factories for postgeneration save deprecation
Browse files Browse the repository at this point in the history
v3.3.0 deprecates saving the model after the post_generation method.
Follow the factoryboy instructions for handling this warning:
https://factoryboy.readthedocs.io/en/stable/changelog.html#id1
  • Loading branch information
amstilp committed Nov 20, 2023
1 parent 59e8355 commit 96261d3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions primed/cdsa/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,4 @@ def authorization_domains(self, create, extracted, **kwargs):

class Meta:
model = models.CDSAWorkspace
skip_postgeneration_save = True
2 changes: 2 additions & 0 deletions primed/dbgap/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def studies(self, create, extracted, **kwargs):

class Meta:
model = models.dbGaPStudyAccession
skip_postgeneration_save = True


class dbGaPWorkspaceFactory(TimeStampedModelFactory, DjangoModelFactory):
Expand All @@ -78,6 +79,7 @@ class dbGaPWorkspaceFactory(TimeStampedModelFactory, DjangoModelFactory):

class Meta:
model = models.dbGaPWorkspace
skip_postgeneration_save = True

@post_generation
def authorization_domains(self, create, extracted, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions primed/users/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ def password(self, create: bool, extracted: Sequence[Any], **kwargs):
).evaluate(None, None, extra={"locale": None})
)
self.set_password(password)
self.save()

class Meta:
model = get_user_model()
django_get_or_create = ["username"]
skip_postgeneration_save = True


class GroupFactory(DjangoModelFactory):
Expand Down

0 comments on commit 96261d3

Please sign in to comment.