Commit 4d2b78e9 authored by Nicolas Mérigot's avatar Nicolas Mérigot

feature: add job offer factory

parent a999d46f
import factory
from .models import JobOffer
from django.contrib.auth.models import User
from django.db.models.signals import post_save
class JobOfferFactory(factory.django.DjangoModelFactory):
class Meta:
model = JobOffer
author = factory.Iterator(User.objects.all())
title = factory.Faker('word')
description = factory.Faker('text', max_nb_chars=250)
creationDate = factory.Faker('past_date')
closingDate = factory.Faker('future_date')
def skills(self, create, extracted, **kwargs):
if not create:
if extracted:
for skill in extracted:
from import BaseCommand, CommandError
from djangoldp_joboffer.factories import JobOfferFactory
from djangoldp_skill.models import Skill
class Command(BaseCommand):
help = 'Mock data'
def randomSkill(self, quantity: int = 10):
query_set = Skill.objects.order_by('?')[:quantity]
return query_set
def add_arguments(self, parser):
parser.add_argument('--size', type=int, default=0, help='Number of job offer to create')
parser.add_argument('--sizeof', type=int, default=3, help='Number of skill required into each job offer created')
def handle(self, *args, **options):
for i in range(0, options['size']):
random_skill = self.randomSkill(options['sizeof']);
self.stdout.write('Successful data mock install'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment