|
| 1 | +from pathlib import Path |
| 2 | +from users.tests.factories import UserFactory |
| 3 | +from conferences.tests.factories import ConferenceFactory |
| 4 | +from organizers.tests.factories import OrganizerFactory |
| 5 | +from visa.models import ( |
| 6 | + InvitationLetterAsset, |
| 7 | + InvitationLetterDocument, |
| 8 | + InvitationLetterRequest, |
| 9 | + InvitationLetterOrganizerConfig, |
| 10 | +) |
| 11 | +import factory |
| 12 | +import factory.fuzzy |
| 13 | +from factory.django import DjangoModelFactory |
| 14 | + |
| 15 | + |
| 16 | +class InvitationLetterRequestFactory(DjangoModelFactory): |
| 17 | + conference = factory.SubFactory(ConferenceFactory) |
| 18 | + requester = factory.SubFactory(UserFactory) |
| 19 | + date_of_birth = factory.Faker("date") |
| 20 | + full_name = factory.Faker("name") |
| 21 | + nationality = factory.Faker("country") |
| 22 | + address = factory.Faker("address") |
| 23 | + passport_number = factory.Faker("ssn") |
| 24 | + embassy_name = factory.Faker("company") |
| 25 | + |
| 26 | + class Meta: |
| 27 | + model = InvitationLetterRequest |
| 28 | + |
| 29 | + |
| 30 | +class InvitationLetterOrganizerConfigFactory(DjangoModelFactory): |
| 31 | + organizer = factory.SubFactory(OrganizerFactory) |
| 32 | + |
| 33 | + class Meta: |
| 34 | + model = InvitationLetterOrganizerConfig |
| 35 | + |
| 36 | + |
| 37 | +class InvitationLetterDocumentFactory(DjangoModelFactory): |
| 38 | + invitation_letter_organizer_config = factory.SubFactory( |
| 39 | + InvitationLetterOrganizerConfigFactory |
| 40 | + ) |
| 41 | + document = factory.django.FileField( |
| 42 | + from_path=Path(__file__).parent / "fixtures" / "sample-pdf.pdf" |
| 43 | + ) |
| 44 | + |
| 45 | + class Meta: |
| 46 | + model = InvitationLetterDocument |
| 47 | + |
| 48 | + |
| 49 | +class InvitationLetterAssetFactory(DjangoModelFactory): |
| 50 | + invitation_letter_organizer_config = factory.SubFactory( |
| 51 | + InvitationLetterOrganizerConfigFactory |
| 52 | + ) |
| 53 | + identifier = factory.Faker("md5") |
| 54 | + image = factory.django.ImageField() |
| 55 | + |
| 56 | + class Meta: |
| 57 | + model = InvitationLetterAsset |
0 commit comments