Skip to content
Snippets Groups Projects
Commit cc6b09e9 authored by Nicolas Mérigot's avatar Nicolas Mérigot
Browse files

feature: add user factory and command

parent b8255e7e
No related branches found
No related tags found
1 merge request!9Feature: add user factory in dev flavor
import factory
from django.contrib.auth.models import User
from django.db.models.signals import post_save
@factory.django.mute_signals(post_save)
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = User
username = factory.Faker('user_name')
first_name = factory.Faker('first_name')
last_name = factory.Faker('last_name')
email = factory.Faker('email')
password = factory.PostGenerationMethodCall('set_password', 'totototo')
from django.core.management.base import BaseCommand, CommandError
from djangoldp.factories import UserFactory
class Command(BaseCommand):
help = 'Mock data'
def add_arguments(self, parser):
parser.add_argument('--size', type=int, default=0, help='Number of user to create')
def handle(self, *args, **options):
UserFactory.create_batch(size=options['size']);
self.stdout.write(self.style.SUCCESS('Successful data mock install'))
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