-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfactories.py
57 lines (37 loc) · 1.64 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
from django.conf import settings
from django.template.defaultfilters import slugify
import factory
from filingcabinet import get_document_model, get_documentcollection_model
from filingcabinet.models import CollectionDirectory, DocumentPortal, Page
Document = get_document_model()
DocumentCollection = get_documentcollection_model()
class UserFactory(factory.django.DjangoModelFactory):
class Meta:
model = settings.AUTH_USER_MODEL
class DocumentFactory(factory.django.DjangoModelFactory):
class Meta:
model = Document
title = factory.Sequence(lambda n: "Document {}".format(n))
slug = factory.LazyAttribute(lambda o: slugify(o.title))
class PageFactory(factory.django.DjangoModelFactory):
class Meta:
model = Page
document = factory.SubFactory(DocumentFactory)
number = factory.Sequence(lambda n: n)
class DocumentCollectionFactory(factory.django.DjangoModelFactory):
class Meta:
model = DocumentCollection
title = factory.Sequence(lambda n: "DocumentCollection {}".format(n))
slug = factory.LazyAttribute(lambda o: slugify(o.title))
user = factory.SubFactory(UserFactory)
class CollectionDirectoryFactory(factory.django.DjangoModelFactory):
class Meta:
model = CollectionDirectory
collection = factory.SubFactory(DocumentCollectionFactory)
name = factory.Sequence(lambda n: "CollectionDirectory {}".format(n))
depth = 0
class DocumentPortalFactory(factory.django.DjangoModelFactory):
class Meta:
model = DocumentPortal
title = factory.Sequence(lambda n: "DocumentPortal {}".format(n))
slug = factory.LazyAttribute(lambda o: slugify(o.title))