bornhack-website/src/camps/factories.py
Thomas Steen Rasmussen 00af109e2f
add flake8 and isort to pre-commit config, make flake8 and isort happy (#441)
* add flake8 to pre-commit config, and fixup many things to make flake8 happy

* add isort and sort all imports, add to pre-commit and requirements
2020-02-12 13:10:41 +01:00

39 lines
1 KiB
Python

import factory
from django.utils import timezone
from factory.django import DjangoModelFactory
from psycopg2._range import DateTimeTZRange
class CampFactory(DjangoModelFactory):
class Meta:
model = "camps.Camp"
read_only = False
title = factory.Faker("word")
tagline = factory.Faker("sentence")
slug = factory.Faker("slug")
shortslug = factory.Faker("slug")
buildup = factory.LazyFunction(
lambda: DateTimeTZRange(
lower=timezone.now() - timezone.timedelta(days=3),
upper=timezone.now() - timezone.timedelta(hours=1),
)
)
camp = factory.LazyFunction(
lambda: DateTimeTZRange(
lower=timezone.now(), upper=timezone.now() + timezone.timedelta(days=8)
)
)
teardown = factory.LazyFunction(
lambda: DateTimeTZRange(
lower=timezone.now() + timezone.timedelta(days=8, hours=1),
upper=timezone.now() + timezone.timedelta(days=11),
)
)
colour = factory.Faker("hex_color")