factories.py 700 Bytes
Newer Older
luxcem's avatar
luxcem committed
1
2
3
import datetime

import pytz
4
import factory
luxcem's avatar
luxcem committed
5
from factory.fuzzy import FuzzyDateTime
6
7
8
9
10
11
12

from .models import Article


class ArticleFactory(factory.django.DjangoModelFactory):
    class Meta:
        model = Article
luxcem's avatar
luxcem committed
13

14
15
    url = factory.Faker("url")
    lang = "en"
luxcem's avatar
luxcem committed
16

17
    title = factory.Faker("sentence", nb_words=4)
luxcem's avatar
luxcem committed
18
    website = factory.Sequence(lambda n: "Website {}".format(n))
19
    extracts = factory.Faker("text")
luxcem's avatar
luxcem committed
20
21
22
23
24
25
26
27

    created_at = FuzzyDateTime(
        datetime.datetime(2014, 1, 1, tzinfo=pytz.UTC))
    updated_at = FuzzyDateTime(
        datetime.datetime(2014, 1, 1, tzinfo=pytz.UTC))
    published_at = FuzzyDateTime(
        datetime.datetime(2014, 1, 1, tzinfo=pytz.UTC))

28
    status = "NEW"