14
14
15
15
from tests .common_tools import redirects_to , template_used
16
16
17
+ pytestmark = mark .django_db
18
+
17
19
18
- @mark .django_db
19
20
@mark .parametrize (
20
21
"url" ,
21
22
[
22
23
reverse ("cfp:step1_submit_proposal" ),
23
24
# using some random uuid because we just need to resolve url
24
25
reverse ("cfp:step2_add_speakers" , args = ["ABCDEFI" ]),
25
26
reverse ("cfp:step3_thanks" , args = ["ABCDEFI" ]),
27
+ reverse ("cfp:update" , args = ["ABCDEFI" ]),
28
+ reverse ("cfp:update_speakers" , args = ["ABCDEFI" ]),
26
29
],
27
30
)
28
31
def test_if_cfp_pages_are_login_required (client , url ):
@@ -32,7 +35,6 @@ def test_if_cfp_pages_are_login_required(client, url):
32
35
assert redirects_to (response , "/accounts/login/" )
33
36
34
37
35
- @mark .django_db
36
38
def test_if_cfp_pages_are_unavailable_if_cfp_is_undefined (user_client ):
37
39
Conference .objects .create (
38
40
code = settings .CONFERENCE_CONFERENCE ,
@@ -45,7 +47,6 @@ def test_if_cfp_pages_are_unavailable_if_cfp_is_undefined(user_client):
45
47
assert template_used (response , "ep19/bs/cfp/cfp_is_closed.html" )
46
48
47
49
48
- @mark .django_db
49
50
def test_if_cfp_pages_are_unavailable_if_cfp_is_in_the_future (user_client ):
50
51
Conference .objects .create (
51
52
code = settings .CONFERENCE_CONFERENCE ,
@@ -59,7 +60,6 @@ def test_if_cfp_pages_are_unavailable_if_cfp_is_in_the_future(user_client):
59
60
assert template_used (response , "ep19/bs/cfp/cfp_is_closed.html" )
60
61
61
62
62
- @mark .django_db
63
63
def test_if_cfp_pages_are_unavailable_if_cfp_is_in_the_past (user_client ):
64
64
Conference .objects .create (
65
65
code = settings .CONFERENCE_CONFERENCE ,
@@ -74,7 +74,6 @@ def test_if_cfp_pages_are_unavailable_if_cfp_is_in_the_past(user_client):
74
74
assert template_used (response , "ep19/bs/cfp/cfp_is_closed.html" )
75
75
76
76
77
- @mark .django_db
78
77
def test_if_cfp_pages_are_available_if_cfp_is_active (user_client ):
79
78
Conference .objects .create (
80
79
code = settings .CONFERENCE_CONFERENCE ,
@@ -89,7 +88,6 @@ def test_if_cfp_pages_are_available_if_cfp_is_active(user_client):
89
88
assert template_used (response , "ep19/bs/cfp/step1_talk_info.html" )
90
89
91
90
92
- @mark .django_db
93
91
def test_validation_errors_are_handled_on_step1 (user_client ):
94
92
"""
95
93
NOTE(artcz)
@@ -108,7 +106,6 @@ def test_validation_errors_are_handled_on_step1(user_client):
108
106
assert template_used (response , "ep19/bs/cfp/step1_talk_info.html" )
109
107
110
108
111
- @mark .django_db
112
109
def test_if_user_can_submit_talk_details_and_is_redirect_to_step2 (user_client ):
113
110
STEP1_CORRECT_REDIRECT_302 = 302
114
111
@@ -154,7 +151,6 @@ def test_if_user_can_submit_talk_details_and_is_redirect_to_step2(user_client):
154
151
)
155
152
156
153
157
- @mark .django_db
158
154
def test_validation_errors_are_handled_on_step2 (user_client ):
159
155
"""
160
156
NOTE(artcz)
@@ -174,7 +170,6 @@ def test_validation_errors_are_handled_on_step2(user_client):
174
170
assert template_used (response , "ep19/bs/cfp/step2_add_speaker.html" )
175
171
176
172
177
- @mark .django_db
178
173
def test_if_user_can_add_a_speaker_to_a_proposal (user_client ):
179
174
create_conference_with_open_cfp ()
180
175
STEP2_CORRECT_REDIRECT_302 = 302
@@ -213,7 +208,6 @@ def test_if_user_can_add_a_speaker_to_a_proposal(user_client):
213
208
)
214
209
215
210
216
- @mark .django_db
217
211
def test_if_correct_thanks_page_is_rendered (user_client ):
218
212
create_conference_with_open_cfp ()
219
213
talk = TalkFactory ()
@@ -223,7 +217,6 @@ def test_if_correct_thanks_page_is_rendered(user_client):
223
217
assert template_used (response , "ep19/bs/cfp/step3_thanks.html" )
224
218
225
219
226
- @mark .django_db
227
220
def test_thanks_page_contains_link_to_preview_proposal (user_client ):
228
221
create_conference_with_open_cfp ()
229
222
talk = TalkFactory ()
@@ -235,7 +228,6 @@ def test_thanks_page_contains_link_to_preview_proposal(user_client):
235
228
assert preview_link in response .content .decode ()
236
229
237
230
238
- @mark .django_db
239
231
def test_preview_page_renders_correct_content (user_client ):
240
232
create_conference_with_open_cfp ()
241
233
talk = TalkFactory ()
@@ -250,8 +242,7 @@ def test_preview_page_renders_correct_content(user_client):
250
242
assert talk .abstract_extra in response .content .decode ()
251
243
252
244
253
- @mark .django_db
254
- def test_preview_page_contains_edit_link_if_cfp_is_open_and_user_is_author (
245
+ def test_preview_page_contains_edit_links_if_cfp_is_open_and_user_is_author (
255
246
user_client
256
247
):
257
248
create_conference_with_open_cfp ()
@@ -261,13 +252,14 @@ def test_preview_page_contains_edit_link_if_cfp_is_open_and_user_is_author(
261
252
talk .save ()
262
253
preview_url = reverse ("cfp:preview" , args = [talk .slug ])
263
254
edit_link = reverse ("cfp:update" , args = [talk .uuid ])
255
+ speaker_edit_link = reverse ("cfp:update_speakers" , args = [talk .uuid ])
264
256
265
257
response = user_client .get (preview_url )
266
258
267
259
assert edit_link in response .content .decode ()
260
+ assert speaker_edit_link in response .content .decode ()
268
261
269
262
270
- @mark .django_db
271
263
def test_preview_page_doesnt_contain_edit_link_if_cfp_is_open_but_user_is_not_author ( # NOQA
272
264
user_client
273
265
):
@@ -276,13 +268,14 @@ def test_preview_page_doesnt_contain_edit_link_if_cfp_is_open_but_user_is_not_au
276
268
talk .setAbstract ("some abstract" )
277
269
preview_url = reverse ("cfp:preview" , args = [talk .slug ])
278
270
edit_link = reverse ("cfp:update" , args = [talk .uuid ])
271
+ speaker_edit_link = reverse ("cfp:update_speakers" , args = [talk .uuid ])
279
272
280
273
response = user_client .get (preview_url )
281
274
282
275
assert edit_link not in response .content .decode ()
276
+ assert speaker_edit_link not in response .content .decode ()
283
277
284
278
285
- @mark .django_db
286
279
def test_preview_page_doesnt_contain_edit_link_if_cfp_is_closed_and_user_is_author ( # NOQA
287
280
user_client
288
281
):
@@ -296,13 +289,14 @@ def test_preview_page_doesnt_contain_edit_link_if_cfp_is_closed_and_user_is_auth
296
289
talk .setAbstract ("some abstract" )
297
290
preview_url = reverse ("cfp:preview" , args = [talk .slug ])
298
291
edit_link = reverse ("cfp:update" , args = [talk .uuid ])
292
+ speaker_edit_link = reverse ("cfp:update_speakers" , args = [talk .uuid ])
299
293
300
294
response = user_client .get (preview_url )
301
295
302
296
assert edit_link not in response .content .decode ()
297
+ assert speaker_edit_link not in response .content .decode ()
303
298
304
299
305
- @mark .django_db
306
300
def test_regular_user_cant_access_program_wg_download (user_client ):
307
301
LOGIN_REQUIRED_302 = 302
308
302
Conference .objects .create (
@@ -315,7 +309,6 @@ def test_regular_user_cant_access_program_wg_download(user_client):
315
309
assert redirects_to (response , "/admin/login/" )
316
310
317
311
318
- @mark .django_db
319
312
def test_admin_user_can_access_program_wg_download (admin_client ):
320
313
Conference .objects .create (
321
314
code = settings .CONFERENCE_CONFERENCE ,
@@ -327,35 +320,46 @@ def test_admin_user_can_access_program_wg_download(admin_client):
327
320
assert response .json () == {"talks" : []}
328
321
329
322
330
- @mark .django_db
331
- def test_update_page_works_if_cfp_is_open_and_user_is_author (user_client ):
323
+ @mark .parametrize (
324
+ "page_name, template" ,
325
+ [
326
+ ("cfp:update" , "ep19/bs/cfp/update_proposal.html" ),
327
+ ("cfp:update_speakers" , "ep19/bs/cfp/update_speakers.html" ),
328
+ ],
329
+ )
330
+ def test_update_pages_work_if_cfp_is_open_and_user_is_author (user_client , page_name , template ):
332
331
create_conference_with_open_cfp ()
333
332
talk = TalkFactory ()
334
333
talk .setAbstract ("some abstract" )
335
334
talk .created_by = user_client .user
336
335
talk .save ()
337
- edit_url = reverse ("cfp:update" , args = [talk .uuid ])
336
+ edit_url = reverse (page_name , args = [talk .uuid ])
338
337
339
338
response = user_client .get (edit_url )
340
339
341
340
assert response .status_code == 200
342
- assert template_used (response , "ep19/bs/cfp/update_proposal.html" )
341
+ assert template_used (response , template )
343
342
344
343
345
- @mark .django_db
346
- def test_update_page_doesnt_work_if_cfp_is_open_but_user_is_not_author (
347
- user_client
344
+ @mark .parametrize (
345
+ "page_name" ,
346
+ [
347
+ "cfp:update" ,
348
+ "cfp:update_speakers" ,
349
+ ],
350
+ )
351
+ def test_update_pages_dont_work_if_cfp_is_open_but_user_is_not_author (
352
+ user_client , page_name ,
348
353
):
349
354
create_conference_with_open_cfp ()
350
355
talk = TalkFactory ()
351
356
talk .setAbstract ("some abstract" )
352
- edit_url = reverse ("cfp:update" , args = [talk .uuid ])
357
+ edit_url = reverse (page_name , args = [talk .uuid ])
353
358
354
359
response = user_client .get (edit_url )
355
360
assert response .status_code == 403
356
361
357
362
358
- @mark .django_db
359
363
def test_preview_page_doesnt_work_if_cfp_is_closed_and_user_is_author (
360
364
user_client
361
365
):
@@ -375,7 +379,6 @@ def test_preview_page_doesnt_work_if_cfp_is_closed_and_user_is_author(
375
379
assert response .status_code == 403
376
380
377
381
378
- @mark .django_db
379
382
def test_validation_errors_are_handled_on_update_proposal (user_client ):
380
383
"""
381
384
NOTE(artcz)
@@ -399,7 +402,6 @@ def test_validation_errors_are_handled_on_update_proposal(user_client):
399
402
assert template_used (response , "ep19/bs/cfp/update_proposal.html" )
400
403
401
404
402
- @mark .django_db
403
405
def test_update_proposal_updates_proposal (user_client ):
404
406
create_conference_with_open_cfp ()
405
407
talk = TalkFactory ()
@@ -441,8 +443,45 @@ def test_update_proposal_updates_proposal(user_client):
441
443
assert talk_dict ["speakers" ] == []
442
444
443
445
446
+ def test_update_speaker_updated_speaker (user_client ):
447
+ create_conference_with_open_cfp ()
448
+ talk = TalkFactory ()
449
+ talk .setAbstract ("some abstract" )
450
+ talk .created_by = user_client .user
451
+ talk .save ()
452
+
453
+ edit_url = reverse ("cfp:update_speakers" , args = [talk .uuid ])
454
+ speaker_data = dict (
455
+ users_given_name = "new name" ,
456
+ is_minor = True ,
457
+ job_title = "goat" ,
458
+ phone = "+48123456789" ,
459
+ gender = "yes" ,
460
+ company = "widgets inc" ,
461
+ company_homepage = "www.widgets.inc" ,
462
+ bio = "this is my bio" ,
463
+ )
464
+
465
+ response = user_client .post (edit_url , speaker_data )
466
+
467
+ assert response .status_code == 302
468
+ assert redirects_to (response , reverse ("cfp:preview" , args = [talk .slug ]))
469
+
470
+ user = user_client .user
471
+ user .refresh_from_db ()
472
+ attendee_profile = user .attendeeprofile
473
+ attendee_profile .refresh_from_db ()
474
+ assert user .first_name == speaker_data ["users_given_name" ]
475
+ assert attendee_profile .phone == speaker_data ["phone" ]
476
+ assert attendee_profile .is_minor == speaker_data ["is_minor" ]
477
+ assert attendee_profile .job_title == speaker_data ["job_title" ]
478
+ assert attendee_profile .gender == speaker_data ["gender" ]
479
+ assert attendee_profile .company == speaker_data ["company" ]
480
+ assert speaker_data ["company_homepage" ] in attendee_profile .company_homepage
481
+ assert attendee_profile .getBio ().body == speaker_data ["bio" ]
482
+
483
+
444
484
# Mark with django db only because AddSpeakerToTalkForm is a ModelForm
445
- @mark .django_db
446
485
@mark .parametrize (
447
486
"valid_phone" , ["+48123456789" , "+44 7 123 456 789" , "+1 858 712 8966" ]
448
487
)
@@ -459,7 +498,6 @@ def test_speaker_form_accepts_valid_international_mobile_numbers(valid_phone):
459
498
460
499
461
500
# Mark with django db only because AddSpeakerToTalkForm is a ModelForm
462
- @mark .django_db
463
501
@mark .parametrize (
464
502
"invalid_phone" ,
465
503
["SOME RANODM TEXT" , "+4471343956789" , "+4412445367" ],
0 commit comments