Merge branch 'feature-factories' into 'master'
feature: factories See merge request startinblox/djangoldp-packages/djangoldp-notifications!3
This commit is contained in:
commit
666cca49e5
17
djangoldp_notification/factories.py
Normal file
17
djangoldp_notification/factories.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import factory
|
||||||
|
from .models import Notification
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
|
||||||
|
@factory.django.mute_signals(post_save)
|
||||||
|
class NotificationFactory(factory.django.DjangoModelFactory):
|
||||||
|
class Meta:
|
||||||
|
model = Notification
|
||||||
|
|
||||||
|
type = factory.Faker('text', max_nb_chars=50)
|
||||||
|
summary = factory.Faker('paragraph', nb_sentences=3, variable_nb_sentences=True)
|
||||||
|
author_user = factory.Iterator(User.objects.all())
|
||||||
|
user = factory.Iterator(User.objects.all())
|
||||||
|
date = factory.Faker('past_datetime')
|
||||||
|
read = factory.Faker('boolean')
|
||||||
|
object = factory.Faker('url')
|
@ -0,0 +1,14 @@
|
|||||||
|
from django.core.management.base import BaseCommand, CommandError
|
||||||
|
from djangoldp_notification.factories import NotificationFactory
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
help = 'Mock data'
|
||||||
|
|
||||||
|
def add_arguments(self, parser):
|
||||||
|
parser.add_argument('--size', type=int, default=0, help='Number of notifications to create')
|
||||||
|
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
for i in range(0, options['size']):
|
||||||
|
notif = NotificationFactory.create()
|
||||||
|
|
||||||
|
self.stdout.write(self.style.SUCCESS('Successful data mock install'))
|
@ -12,6 +12,10 @@ packages = find:
|
|||||||
install_requires =
|
install_requires =
|
||||||
djangoldp~=0.5
|
djangoldp~=0.5
|
||||||
|
|
||||||
|
[options.extras_require]
|
||||||
|
dev =
|
||||||
|
factory_boy>=2.11.0
|
||||||
|
|
||||||
[semantic_release]
|
[semantic_release]
|
||||||
version_source = tag
|
version_source = tag
|
||||||
version_variable = djangoldp_notification/__init__.py:__version__
|
version_variable = djangoldp_notification/__init__.py:__version__
|
||||||
|
Loading…
Reference in New Issue
Block a user