Skip to content

Commit

Permalink
(forum_conversation) get more realistic anonymous post/topic made by …
Browse files Browse the repository at this point in the history
…factories
  • Loading branch information
vincentporte committed Feb 13, 2024
1 parent 78d5cab commit dba9b54
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lacommunaute/forum_conversation/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def upvoted_by(self, create, extracted, **kwargs):
class AnonymousPostFactory(PostFactory):
username = factory.Faker("email")
poster = None
anonymous_key = factory.Faker("uuid4")


class CertifiedPostFactory(factory.django.DjangoModelFactory):
Expand Down Expand Up @@ -80,3 +81,18 @@ def with_tags(self, create, extracted, **kwargs):
if isinstance(extracted, list):
for tag in extracted:
self.tags.add(tag)


class AnonymousTopicFactory(TopicFactory):
poster = None

class Meta:
skip_postgeneration_save = True

class Params:
with_post = factory.Trait(
post=factory.RelatedFactory(
AnonymousPostFactory,
factory_related_name="topic",
)
)

0 comments on commit dba9b54

Please sign in to comment.