Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update factories.py #423

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 8 additions & 33 deletions organizations/tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
"""
Provides factory for User.
"""
from django.contrib.auth.models import User
import factory
from factory.django import DjangoModelFactory
from factory import Factory, Faker
from myapp.models import Product

from organizations.models import Organization


class UserFactory(DjangoModelFactory):
""" User creation factory."""
class Meta:
model = User
django_get_or_create = ('email', 'username')

username = factory.Sequence(lambda arg: f'robot{arg}')
email = factory.Sequence(lambda arg: f'robot+test+{arg}@edx.org')
password = factory.PostGenerationMethodCall('set_password', 'test')
first_name = factory.Sequence(lambda arg: f'Robot{arg}')
last_name = 'Test'
is_staff = False
is_active = True
is_superuser = False


class OrganizationFactory(DjangoModelFactory):
""" Organization creation factory."""
class ProductFactory(Factory):
class Meta:
model = Organization
model = Product

name = factory.Sequence(lambda arg: f'organization name {arg}')
short_name = factory.Sequence(lambda arg: f'name{arg}')
description = factory.Sequence(lambda arg: f'description{arg}')
logo = None
active = True
name = Faker('word')
category = Faker('word')
price = Faker('random_number', digits=2)
available = Faker('boolean')