1010 dump_relevant_talk_information_to_dict ,
1111 AddSpeakerToTalkForm ,
1212)
13+ try :
14+ from pycon .settings import CONFERENCE_TIMESLOTS
15+ except ImportError :
16+ CONFERENCE_TIMESLOTS = None
1317
1418from tests .common_tools import redirects_to , template_used
1519from tests .factories import TalkFactory
@@ -140,22 +144,23 @@ def test_if_user_can_submit_talk_details_and_is_redirect_to_step2(user_client):
140144 )
141145 step1_url = reverse ("cfp:step1_submit_proposal" )
142146
143- response = user_client .post (
144- step1_url ,
145- {
146- "type" : TALK_TYPE_CHOICES .t_30 ,
147- "abstract" : "Abstract goes here" ,
148- "title" : "A title" ,
149- "sub_title" : "A sub title" ,
150- "abstract_short" : "Short abstract" ,
151- "abstract_extra" : "Abstract _extra" ,
152- "tags" : "abc, defg" ,
153- "level" : TALK_LEVEL .beginner ,
154- "domain_level" : TALK_LEVEL .advanced ,
155- "i_accept_speaker_release" : True ,
156- },
157- )
158-
147+ data = {
148+ "type" : TALK_TYPE_CHOICES .t_30 ,
149+ "abstract" : "Abstract goes here" ,
150+ "title" : "A title" ,
151+ "sub_title" : "A sub title" ,
152+ "abstract_short" : "Short abstract" ,
153+ "abstract_extra" : "Abstract _extra" ,
154+ "tags" : "abc, defg" ,
155+ "level" : TALK_LEVEL .beginner ,
156+ "domain_level" : TALK_LEVEL .advanced ,
157+ "i_accept_speaker_release" : True ,
158+ }
159+ if CONFERENCE_TIMESLOTS and \
160+ isinstance (CONFERENCE_TIMESLOTS , (list , tuple )):
161+ data ['availability' ] = [CONFERENCE_TIMESLOTS [0 ][0 ], ]
162+
163+ response = user_client .post (step1_url , data )
159164 assert response .status_code == STEP1_CORRECT_REDIRECT_302
160165
161166 talk = Talk .objects .get ()
@@ -169,12 +174,45 @@ def test_if_user_can_submit_talk_details_and_is_redirect_to_step2(user_client):
169174 assert talk_dict ["python_level" ] == "Beginner"
170175 assert talk_dict ["domain_level" ] == "Advanced"
171176 assert talk_dict ["speakers" ] == []
177+ if 'availability' in data :
178+ assert talk_dict ['availability' ] == data ['availability' ]
172179
173180 assert redirects_to (
174181 response , reverse ("cfp:step2_add_speakers" , args = [talk .uuid ])
175182 )
176183
177184
185+ @mark .skipif (CONFERENCE_TIMESLOTS is None , reason = 'no timeslot defined' )
186+ def test_if_user_cannot_submit_talk_if_availability_not_selected (user_client ):
187+ STEP1_VALIDATION_FAIL_200 = 200
188+
189+ Conference .objects .create (
190+ code = settings .CONFERENCE_CONFERENCE ,
191+ name = settings .CONFERENCE_CONFERENCE ,
192+ cfp_start = timezone .now ().date () - timedelta (days = 2 ),
193+ cfp_end = timezone .now ().date () + timedelta (days = 1 ),
194+ )
195+ step1_url = reverse ("cfp:step1_submit_proposal" )
196+
197+ response = user_client .post (
198+ step1_url ,
199+ {
200+ "type" : TALK_TYPE_CHOICES .t_30 ,
201+ "abstract" : "Abstract goes here" ,
202+ "title" : "A title" ,
203+ "sub_title" : "A sub title" ,
204+ "abstract_short" : "Short abstract" ,
205+ "abstract_extra" : "Abstract _extra" ,
206+ "tags" : "abc, defg" ,
207+ "level" : TALK_LEVEL .beginner ,
208+ "domain_level" : TALK_LEVEL .advanced ,
209+ "i_accept_speaker_release" : True ,
210+ },
211+ )
212+
213+ assert response .status_code == STEP1_VALIDATION_FAIL_200
214+
215+
178216def test_if_user_cannot_submit_talk_if_release_not_selected (user_client ):
179217 STEP1_VALIDATION_FAIL_200 = 200
180218
@@ -469,21 +507,23 @@ def test_update_proposal_updates_proposal(user_client):
469507
470508 edit_url = reverse ("cfp:update" , args = [talk .uuid ])
471509
472- response = user_client .post (
473- edit_url ,
474- {
475- "type" : TALK_TYPE_CHOICES .t_45 ,
476- "abstract" : "New abstract" ,
477- "abstract_short" : "New short abstract" ,
478- "abstract_extra" : "New extra abstract" ,
479- "level" : TALK_LEVEL .intermediate ,
480- "domain_level" : TALK_LEVEL .advanced ,
481- "title" : "New title" ,
482- "sub_title" : "New sub title" ,
483- "tags" : "Some, tags" ,
484- "i_accept_speaker_release" : True ,
485- },
486- )
510+ data = {
511+ "type" : TALK_TYPE_CHOICES .t_45 ,
512+ "abstract" : "New abstract" ,
513+ "abstract_short" : "New short abstract" ,
514+ "abstract_extra" : "New extra abstract" ,
515+ "level" : TALK_LEVEL .intermediate ,
516+ "domain_level" : TALK_LEVEL .advanced ,
517+ "title" : "New title" ,
518+ "sub_title" : "New sub title" ,
519+ "tags" : "Some, tags" ,
520+ "i_accept_speaker_release" : True ,
521+ }
522+ if CONFERENCE_TIMESLOTS and \
523+ isinstance (CONFERENCE_TIMESLOTS , (list , tuple )):
524+ data ['availability' ] = [CONFERENCE_TIMESLOTS [0 ][0 ], ]
525+
526+ response = user_client .post (edit_url , data )
487527
488528 assert response .status_code == 302
489529 talk .refresh_from_db ()
0 commit comments