2018-04-22 06:31:10 +00:00
|
|
|
import factory
|
|
|
|
|
|
|
|
from factory.django import DjangoModelFactory
|
|
|
|
|
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
from psycopg2.extras import DateTimeTZRange
|
|
|
|
|
|
|
|
from utils.factories import UserFactory
|
|
|
|
|
|
|
|
|
|
|
|
class ProductCategoryFactory(DjangoModelFactory):
|
|
|
|
class Meta:
|
2019-03-29 21:19:49 +00:00
|
|
|
model = "shop.ProductCategory"
|
2018-04-22 06:31:10 +00:00
|
|
|
|
2019-03-29 21:19:49 +00:00
|
|
|
name = factory.Faker("word")
|
2018-04-22 06:31:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ProductFactory(DjangoModelFactory):
|
|
|
|
class Meta:
|
2019-03-29 21:19:49 +00:00
|
|
|
model = "shop.Product"
|
2018-04-22 06:31:10 +00:00
|
|
|
|
2019-03-29 21:19:49 +00:00
|
|
|
name = factory.Faker("word")
|
|
|
|
slug = factory.Faker("word")
|
2018-04-22 06:31:10 +00:00
|
|
|
category = factory.SubFactory(ProductCategoryFactory)
|
2019-03-29 21:19:49 +00:00
|
|
|
description = factory.Faker("paragraph")
|
|
|
|
price = factory.Faker("pyint")
|
2018-04-22 06:31:10 +00:00
|
|
|
available_in = factory.LazyFunction(
|
2019-03-29 21:19:49 +00:00
|
|
|
lambda: DateTimeTZRange(
|
|
|
|
lower=timezone.now(), upper=timezone.now() + timezone.timedelta(31)
|
|
|
|
)
|
2018-04-22 06:31:10 +00:00
|
|
|
)
|
2019-07-30 20:51:01 +00:00
|
|
|
ticket_type = factory.SubFactory("tickets.factories.TicketTypeFactory")
|
2018-04-22 06:31:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OrderFactory(DjangoModelFactory):
|
|
|
|
class Meta:
|
2019-03-29 21:19:49 +00:00
|
|
|
model = "shop.Order"
|
2018-04-22 06:31:10 +00:00
|
|
|
|
|
|
|
user = factory.SubFactory(UserFactory)
|
|
|
|
|
|
|
|
|
|
|
|
class OrderProductRelationFactory(DjangoModelFactory):
|
|
|
|
class Meta:
|
2019-03-29 21:19:49 +00:00
|
|
|
model = "shop.OrderProductRelation"
|
2018-04-22 06:31:10 +00:00
|
|
|
|
|
|
|
product = factory.SubFactory(ProductFactory)
|
|
|
|
order = factory.SubFactory(OrderFactory)
|
|
|
|
quantity = 1
|
2019-07-18 19:20:29 +00:00
|
|
|
ticket_generated = False
|