Initial commit from ZIP
This commit is contained in:
commit
378d4692a9
454 files changed
+40367
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
import factory
|
||||
from faker import Factory as FakerFactory
|
||||
|
||||
from outbo.apps.authentication import models
|
||||
from tests.factories.organizations import (
|
||||
AgencyOrganizationFactory,
|
||||
ClientOrganizationFactory,
|
||||
SupplierOrganizationFactory,
|
||||
)
|
||||
|
||||
faker = FakerFactory.create()
|
||||
|
||||
|
||||
class UserFactory(factory.django.DjangoModelFactory):
|
||||
username = factory.LazyAttribute(lambda x: faker.profile()["username"])
|
||||
first_name = factory.LazyAttribute(lambda x: faker.first_name())
|
||||
last_name = factory.LazyAttribute(lambda x: faker.last_name())
|
||||
email = factory.LazyAttribute(lambda x: faker.profile()["mail"])
|
||||
is_staff = False
|
||||
is_superuser = False
|
||||
password = "password"
|
||||
|
||||
@classmethod
|
||||
def _create(cls, model_class, *args, **kwargs):
|
||||
manager = cls._get_manager(model_class)
|
||||
return manager.create_user(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = models.User
|
||||
django_get_or_create = ("username",)
|
||||
|
||||
|
||||
class AgencyUserFactory(UserFactory):
|
||||
organization = factory.SubFactory(AgencyOrganizationFactory)
|
||||
|
||||
|
||||
class ClientUserFactory(UserFactory):
|
||||
organization = factory.SubFactory(ClientOrganizationFactory)
|
||||
|
||||
|
||||
class SupplierUserFactory(UserFactory):
|
||||
organization = factory.SubFactory(SupplierOrganizationFactory)
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import factory
|
||||
from faker import Factory as FakerFactory
|
||||
|
||||
from outbo.apps.organizations import models
|
||||
|
||||
faker = FakerFactory.create()
|
||||
|
||||
|
||||
class AgencyOrganizationFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.company())
|
||||
|
||||
class Meta:
|
||||
model = models.AgencyOrganization
|
||||
|
||||
|
||||
class ClientOrganizationFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.company())
|
||||
|
||||
class Meta:
|
||||
model = models.ClientOrganization
|
||||
|
||||
|
||||
class SupplierOrganizationFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.company())
|
||||
|
||||
class Meta:
|
||||
model = models.SupplierOrganization
|
||||
|
||||
|
||||
class CategoryFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.word())
|
||||
|
||||
class Meta:
|
||||
model = models.Category
|
||||
|
||||
|
||||
class BrandFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.word())
|
||||
client = factory.SubFactory(ClientOrganizationFactory)
|
||||
|
||||
class Meta:
|
||||
model = models.Brand
|
||||
Executable
+33
@@ -0,0 +1,33 @@
|
||||
import factory
|
||||
|
||||
from outbo.apps.products import models
|
||||
from tests.factories.projects import ProjectFactory
|
||||
from faker import Factory as FakerFactory
|
||||
|
||||
faker = FakerFactory.create()
|
||||
|
||||
|
||||
class ProductStageFactory(factory.django.DjangoModelFactory):
|
||||
id = ""
|
||||
label = ""
|
||||
group = 0
|
||||
description = ""
|
||||
next_action = ""
|
||||
order = 0
|
||||
|
||||
class Meta:
|
||||
model = models.ProductStage
|
||||
|
||||
|
||||
class PackagingTypeFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.word())
|
||||
|
||||
class Meta:
|
||||
model = models.PackagingType
|
||||
|
||||
|
||||
class ProductFactory(factory.django.DjangoModelFactory):
|
||||
project = factory.SubFactory(ProjectFactory)
|
||||
|
||||
class Meta:
|
||||
model = models.Product
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
import factory
|
||||
from faker import Factory as FakerFactory
|
||||
|
||||
from outbo.apps.projects import models
|
||||
from tests.factories.organizations import CategoryFactory, BrandFactory
|
||||
|
||||
faker = FakerFactory.create()
|
||||
|
||||
|
||||
class ProjectFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.LazyAttribute(lambda x: faker.sentence())
|
||||
description = factory.LazyAttribute(lambda x: " ".join(faker.sentences(nb=3)))
|
||||
category = factory.SubFactory(CategoryFactory)
|
||||
brand = factory.SubFactory(BrandFactory)
|
||||
printing_files_date = factory.LazyAttribute(
|
||||
lambda x: faker.date_between(start_date="today", end_date="+60d")
|
||||
)
|
||||
promo_date = factory.LazyAttribute(
|
||||
lambda x: faker.date_between(start_date="+60d", end_date="+120d")
|
||||
)
|
||||
products_amount = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=10))
|
||||
published = False
|
||||
|
||||
@classmethod
|
||||
def _create(cls, model_class, *args, **kwargs):
|
||||
manager = cls._get_manager(model_class)
|
||||
return manager.create(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
model = models.Project
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
import binascii
|
||||
import os
|
||||
|
||||
import factory
|
||||
from faker import Factory as FakerFactory
|
||||
from rest_framework.authtoken import models
|
||||
|
||||
from tests.factories.authentication import UserFactory
|
||||
|
||||
faker = FakerFactory.create()
|
||||
|
||||
|
||||
class TokenFactory(factory.django.DjangoModelFactory):
|
||||
user = factory.SubFactory(UserFactory)
|
||||
key = factory.LazyAttribute(lambda x: binascii.hexlify(os.urandom(20)).decode())
|
||||
|
||||
class Meta:
|
||||
model = models.Token
|
||||
Reference in new issue
Block a user