SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit b9284b59 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

add factories for all careers models

parent c2da97f6
No related branches found
No related tags found
No related merge requests found
from django.utils.text import slugify
import factory
from common.faker import LazyAwareDate, LazyRandEnum
from scipost.constants import TITLE_CHOICES
from .models import JobApplication, JobOpening
class JobOpeningFactory(factory.django.DjangoModelFactory):
class Meta:
model = JobOpening
title = factory.Faker("job")
short_description = factory.Faker("sentence")
description = factory.Faker("paragraph")
application_deadline = LazyAwareDate("date_this_year")
status = LazyRandEnum(JobOpening.JOBOPENING_STATUSES)
announced = LazyAwareDate("date_this_year")
slug = factory.LazyAttribute(lambda self: slugify(self.title))
class JobApplicationFactory(factory.django.DjangoModelFactory):
class Meta:
model = JobApplication
uuid = factory.Faker("uuid4")
status = LazyRandEnum(JobApplication.JOBAPP_STATUSES)
last_updated = LazyAwareDate("date_this_year")
job_opening = factory.SubFactory(JobOpeningFactory)
date_received = LazyAwareDate("date_this_year")
title = LazyRandEnum(TITLE_CHOICES)
first_name = factory.Faker("first_name")
last_name = factory.Faker("last_name")
email = factory.Faker("email")
motivation = factory.django.FileField()
cv = factory.django.FileField()
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django.test import TestCase
from ..factories import JobApplicationFactory, JobOpeningFactory
class TestJobOpeningFactory(TestCase):
def test_can_create_job_openings(self):
job_opening = JobOpeningFactory()
self.assertIsNotNone(job_opening)
class TestJobApplicationFactory(TestCase):
def test_can_create_job_applications(self):
job_application = JobApplicationFactory()
self.assertIsNotNone(job_application)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment