Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathconftest.py
More file actions
Latest commit
255 lines (182 loc) · 5.92 KB
/
Copy pathconftest.py
File metadata and controls
255 lines (182 loc) · 5.92 KB
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
importposthog
importpytest
fromfakerimportFaker
frommodel_bakeryimportbaker
fromrolepermissions.rolesimportassign_role
frompythonpro.cohorts.modelsimportCohort
@pytest.fixture
deffake():
returnFaker('pt_BR')
@pytest.fixture
defclient_with_user(client, logged_user):
client.force_login(logged_user)
returnclient
_all_roles=set('data_scientist lead client webdev bootcamper pythonista member'.split())
_advanced_roles=set('member pythonista bootcamper'.split())
_level_zero_roles=set('lead client webdev bootcamper member'.split())
_level_one_roles=set('client webdev bootcamper member'.split())
_level_two_roles=set('webdev bootcamper member'.split())
_level_three_roles=set('bootcamper member'.split())
@pytest.fixture
deflogged_user(django_user_model):
logged_user=baker.make(django_user_model, is_superuser=False)
logged_user.email=logged_user.email.lower()
logged_user.save()
returnlogged_user
@pytest.fixture(params=_all_roles)
@pytest.mark.django_db
defpythonpro_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_all_roles(client, pythonpro_role):
client.force_login(pythonpro_role)
returnclient
@pytest.fixture(params=_advanced_roles)
@pytest.mark.django_db
defadvanced_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_advanced_roles(client, advanced_role):
client.force_login(advanced_role)
returnclient
@pytest.fixture(params=_all_roles-_advanced_roles)
@pytest.mark.django_db
defnot_advanced_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture(params=_level_one_roles)
@pytest.mark.django_db
deflevel_one_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_level_one_roles(client, level_one_role):
client.force_login(level_one_role)
returnclient
@pytest.fixture(params=_level_zero_roles)
@pytest.mark.django_db
deflevel_zero_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_level_zero_roles(client, level_zero_role):
client.force_login(level_zero_role)
returnclient
@pytest.fixture(params=_all_roles-_level_one_roles)
@pytest.mark.django_db
defnot_level_one_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_not_level_one_roles(client, not_level_one_role):
client.force_login(not_level_one_role)
returnclient
@pytest.fixture(params=_level_two_roles)
@pytest.mark.django_db
deflevel_two_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_level_two_roles(client, level_two_role):
client.force_login(level_two_role)
returnclient
@pytest.fixture(params=_all_roles-_level_two_roles)
@pytest.mark.django_db
defnot_level_two_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_not_level_two_roles(client, not_level_two_role):
client.force_login(not_level_two_role)
returnclient
@pytest.fixture(params=_level_three_roles)
@pytest.mark.django_db
deflevel_three_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_level_three_roles(client, level_three_role):
client.force_login(level_three_role)
returnclient
@pytest.fixture(params=_all_roles-_level_three_roles)
@pytest.mark.django_db
defnot_level_three_role(logged_user, request):
role=request.param
assign_role(logged_user, role)
returnlogged_user
@pytest.fixture
defclient_with_not_level_three_roles(client, not_level_three_role):
client.force_login(not_level_three_role)
returnclient
@pytest.fixture
defcohort(db):
returnbaker.make(Cohort)
@pytest.fixture
defclient_with_lead(client, logged_user):
assign_role(logged_user, 'lead')
client.force_login(logged_user)
returnclient
@pytest.fixture
defclient_with_webdev(client, logged_user):
assign_role(logged_user, 'webdev')
client.force_login(logged_user)
returnclient
@pytest.fixture
defclient_with_member(client, logged_user):
assign_role(logged_user, 'member')
client.force_login(logged_user)
returnclient
@pytest.fixture
defclient_with_client(client, logged_user):
assign_role(logged_user, 'client')
client.force_login(logged_user)
returnclient
@pytest.fixture
defclient_with_bootcamper(client, logged_user):
assign_role(logged_user, 'bootcamper')
client.force_login(logged_user)
returnclient
@pytest.fixture
defclient_with_pythonista(client, logged_user):
assign_role(logged_user, 'pythonista')
client.force_login(logged_user)
returnclient
@pytest.fixture(autouse=True)
defuse_db_always(db):
pass
@pytest.fixture(autouse=True)
defturn_active_campaign_on(settings):
"""
This way test don't depend on local .env configuration
"""
settings.ACTIVE_CAMPAIGN_TURNED_ON=True
@pytest.fixture(autouse=True)
defturn_cache_off(settings):
"""
This way test don't depend on local .env configuration
"""
settings.CACHE_TURNED_ON=False
@pytest.fixture(autouse=True)
defturn_ssl_rediret_off_for_tests(settings):
"""
There is no need to place secure=True in all client requests
"""
settings.SECURE_SSL_REDIRECT=False
@pytest.fixture(autouse=True)
defturn_posthog_off_for_tests(settings):
"""
There is no need to place secure=True in all client requests
"""
posthog.disabled=True
pytest_plugins= ['pythonpro.modules.tests.test_topics_view']