import factory from legal test_factories import SubMatterFactory Matte

 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
import factory
from legal.test_factories import SubMatterFactory, MatterTypeFactory
from organizations.test_factories import OrganizationFactory
from tasks.models import Task, TaskStatus, TaskImportance, TaskTemplateSet
from users.test_factories import UserFactory
class TaskStatusFactory(factory.DjangoModelFactory):
value = factory.Sequence(lambda n: 'task status {0}'.format(n))
class Meta:
model = TaskStatus
class TaskImportanceFactory(factory.DjangoModelFactory):
value = factory.Sequence(lambda n: 'task importance {0}'.format(n))
class Meta:
model = TaskImportance
class TaskFactory(factory.DjangoModelFactory):
sub_matter = factory.SubFactory(SubMatterFactory)
title = factory.Sequence(lambda n: 'task {0}'.format(n))
assignor = factory.SubFactory(UserFactory)
assignee = factory.SubFactory(UserFactory)
status = factory.SubFactory(TaskStatusFactory)
importance = factory.SubFactory(TaskImportanceFactory)
class Meta:
model = Task
class TaskTemplateSetFactory(factory.DjangoModelFactory):
matter_type = factory.SubFactory(MatterTypeFactory)
organization = factory.SubFactory(OrganizationFactory)
title = factory.Sequence(lambda n: "TaskTemplateSet {0}".format(n))
@factory.post_generation
def definings(self, create, extracted, **kwargs):
if not create:
return
if extracted:
for defining in extracted:
self.definings.add(defining)
@factory.post_generation
def event_types(self, create, extracted, **kwargs):
if not create:
return
if extracted:
for event_type in extracted:
self.event_types.add(event_type)
class Meta:
model = TaskTemplateSet