-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconftest.py
219 lines (149 loc) · 4.07 KB
/
conftest.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import pytest
from rest_framework.test import APIClient
from django.contrib.auth import get_user_model
from django.core.cache import cache
from apps.animes.tests.factories import BroadcastFactory, AnimeFactory
from apps.characters.tests.factories import (
CharacterFactory,
CharacterVoiceFactory,
CharacterAnimeFactory,
CharacterMangaFactory,
)
from apps.clubs.tests.factories import ClubFactory, ClubMemberFactory
from apps.genres.tests.factories import GenreFactory, ThemeFactory, DemographicFactory
from apps.mangas.tests.factories import MagazineFactory, MangaFactory
from apps.producers.tests.factories import ProducerFactory
from apps.persons.tests.factories import PersonFactory, StaffAnimeFactory
from apps.playlists.tests.factories import (
AnimeListFactory,
MangaListFactory,
AnimeListItemFactory,
MangaListItemFactory,
)
from apps.news.tests.factories import NewsFactory
from apps.reviews.tests.factories import ReviewFactory
from apps.profiles.tests.factories import ProfileFactory
from apps.users.tests.factories import (
UserBaseFactory,
MemberFactory,
PremiumFactory,
ContributorFactory,
ModeratorFactory,
AdministratorFactory,
)
from apps.utils.tests.factories import PictureFactory
User = get_user_model()
@pytest.fixture(autouse=True)
def clear_cache():
cache.clear()
@pytest.fixture
def api_client():
return APIClient()
@pytest.fixture
def anonymous_user(api_client):
return api_client
@pytest.fixture
def user():
return UserBaseFactory.create()
@pytest.fixture
def api_client_with_member_user(api_client):
user = MemberFactory()
api_client.force_authenticate(user=user)
return api_client, user
@pytest.fixture
def member_user(api_client):
user = MemberFactory()
api_client.force_authenticate(user=user)
return api_client
@pytest.fixture
def premium_user(api_client):
user = PremiumFactory()
api_client.force_authenticate(user=user)
return api_client
@pytest.fixture
def contributor_user(api_client):
user = ContributorFactory()
api_client.force_authenticate(user=user)
return api_client
@pytest.fixture
def moderator_user(api_client):
user = ModeratorFactory()
api_client.force_authenticate(user=user)
return api_client
@pytest.fixture
def administrator_user(api_client):
user = AdministratorFactory()
api_client.force_authenticate(user=user)
return api_client
@pytest.fixture
def genre():
return GenreFactory.create()
@pytest.fixture
def theme():
return ThemeFactory.create()
@pytest.fixture
def demographic():
return DemographicFactory.create()
@pytest.fixture
def magazine():
return MagazineFactory.create()
@pytest.fixture
def manga():
return MangaFactory.create()
@pytest.fixture
def news():
return NewsFactory.create()
@pytest.fixture
def broadcast():
return BroadcastFactory.create()
@pytest.fixture
def anime():
return AnimeFactory.create()
@pytest.fixture
def character():
return CharacterFactory.create()
@pytest.fixture
def character_voice():
return CharacterVoiceFactory.create()
@pytest.fixture
def character_anime():
return CharacterAnimeFactory.create()
@pytest.fixture
def character_manga():
return CharacterMangaFactory.create()
@pytest.fixture
def club():
return ClubFactory.create()
@pytest.fixture
def club_member():
return ClubMemberFactory.create()
@pytest.fixture()
def producer():
return ProducerFactory.create()
@pytest.fixture()
def review():
return ReviewFactory.create()
@pytest.fixture
def person():
return PersonFactory.create()
@pytest.fixture
def staff_anime():
return StaffAnimeFactory.create()
@pytest.fixture
def profile():
return ProfileFactory.create()
@pytest.fixture
def anime_list():
return AnimeListFactory.create()
@pytest.fixture
def manga_list():
return MangaListFactory.create()
@pytest.fixture
def anime_list_item():
return AnimeListItemFactory.create()
@pytest.fixture
def manga_list_item():
return MangaListItemFactory.create()
@pytest.fixture
def picture():
return PictureFactory.create()