This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
/
factories.py
83 lines (60 loc) · 1.85 KB
/
factories.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import factory
from mithras.abraxas.models import (Bookmark, Comment, Image, Node, Post, Tag,
Users)
class UsersFactory(factory.django.DjangoModelFactory):
class Meta:
model = Users
username = factory.Sequence(lambda n: "testuser%d" % n)
email = "test@example.com"
fullname = "test user"
bio = "a bio"
class NodeFactory(factory.django.DjangoModelFactory):
class Meta:
model = Node
slug = "foo"
status = "Publish"
title = "Foo"
user = factory.SubFactory(UsersFactory)
type = "post"
class PostFactory(factory.django.DjangoModelFactory):
class Meta:
model = Post
node = factory.SubFactory(NodeFactory)
body = "some text for the post"
version = 1
user = factory.SubFactory(UsersFactory)
class BookmarkFactory(factory.django.DjangoModelFactory):
class Meta:
model = Bookmark
node = factory.SubFactory(NodeFactory)
description = "some text for the post"
version = 1
user = factory.SubFactory(UsersFactory)
url = "https://example.com/"
via_name = "somewhere"
via_url = "https://somewhere.example.com/"
class ImageFactory(factory.django.DjangoModelFactory):
class Meta:
model = Image
node = factory.SubFactory(NodeFactory)
description = "some text for the post"
version = 1
user = factory.SubFactory(UsersFactory)
thumb_width = 100
thumb_height = 100
height = 1024
width = 1024
ext = ".jpg"
rhash = "wert1234523452345"
class TagFactory(factory.django.DjangoModelFactory):
class Meta:
model = Tag
name = "example"
slug = "example"
class CommentFactory(factory.django.DjangoModelFactory):
class Meta:
model = Comment
node = factory.SubFactory(NodeFactory)
body = "here is a comment"
status = "approved"
reply_to = 0