Skip to content

Commit

Permalink
Use fixed length name in CampaignFactory (#103)
Browse files Browse the repository at this point in the history
The `CampaignFactory` could potentially generate strings longer than 50 characters (thus introducing some flakiness when running the tests).

This sets the range to a string of a random length between [0, 51[.
  • Loading branch information
fmrsabino authored May 20, 2024
1 parent 0796b9a commit 6d47603
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion safe_locking_service/campaigns/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from random import randrange

from django.utils import timezone

from factory import Faker, LazyFunction, SubFactory
from factory.django import DjangoModelFactory
from factory.fuzzy import FuzzyText

from ..models import ActivityMetadata, Campaign, Period

Expand All @@ -10,7 +13,7 @@ class CampaignFactory(DjangoModelFactory):
class Meta:
model = Campaign

name = Faker("catch_phrase")
name = FuzzyText(length=randrange(51))
description = Faker("bs")
start_date = LazyFunction(timezone.now)
end_date = LazyFunction(timezone.now)
Expand Down

0 comments on commit 6d47603

Please sign in to comment.