-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathfactories.py
39 lines (30 loc) · 1.09 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
"""Factories for search models"""
import factory
from factory.fuzzy import FuzzyChoice
from factory.django import DjangoModelFactory
from micromasters.factories import UserFactory
from search.models import PercolateQuery, PercolateQueryMembership
class PercolateQueryFactory(DjangoModelFactory):
"""Factory for PercolateQuery"""
query = factory.DictFactory()
original_query = factory.DictFactory()
source_type = FuzzyChoice(choices=PercolateQuery.SOURCE_TYPES)
class Meta:
model = PercolateQuery
class PercolateQueryMembershipFactory(DjangoModelFactory):
"""Factory for PercolateQueryMembership"""
query = factory.SubFactory(PercolateQueryFactory)
user = factory.SubFactory(UserFactory)
is_member = factory.Faker('boolean')
needs_update = factory.Faker('boolean')
class Meta:
model = PercolateQueryMembership
class Params:
pending_add = factory.Trait(
is_member=True,
needs_update=True,
)
pending_remove = factory.Trait(
is_member=False,
needs_update=True,
)