Skip to content

Commit 668ff97

Browse files
committed
Fix tests
1 parent d1050c1 commit 668ff97

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

backend/grants/tests/factories.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from helpers.constants import GENDERS
77
from users.tests.factories import UserFactory
88
from countries import countries
9+
from participants.tests.factories import ParticipantFactory
10+
from participants.models import Participant
911

1012

1113
class GrantFactory(DjangoModelFactory):
@@ -34,3 +36,14 @@ class Meta:
3436
github_handle = factory.Faker("user_name")
3537
linkedin_url = factory.Faker("user_name")
3638
mastodon_handle = factory.Faker("user_name")
39+
40+
@classmethod
41+
def _create(self, model_class, *args, **kwargs):
42+
grant = super()._create(model_class, *args, **kwargs)
43+
44+
if not Participant.objects.filter(
45+
user_id=grant.user.id, conference=grant.conference
46+
).exists():
47+
ParticipantFactory(user_id=grant.user.id, conference=grant.conference)
48+
49+
return grant

0 commit comments

Comments
 (0)