@@ -47,6 +47,14 @@ def do_schedule(schedule,session,timeslot):
4747 post_data = '{ "session_id": "%s", "timeslot_id": "%s" }' % (session .pk ,timeslot .pk )
4848 return self .client .post (url ,post_data ,content_type = 'application/x-www-form-urlencoded' )
4949
50+ def do_extend (schedule ,scheduledsession ):
51+ session = scheduledsession .session
52+ url = urlreverse ("ietf.meeting.ajax.scheduledsessions_json" ,
53+ kwargs = dict (num = session .meeting .number ,
54+ name = schedule .name ,))
55+ post_data = '{ "session_id": "%s", "timeslot_id": "%s", "extendedfrom_id": "%s" }' % (session .pk ,scheduledsession .timeslot .slot_to_the_right .pk ,scheduledsession .timeslot .pk )
56+ return self .client .post (url ,post_data ,content_type = 'application/x-www-form-urlencoded' )
57+
5058 # not logged in
5159 # faulty delete
5260 r = do_unschedule (mars_scheduled )
@@ -75,12 +83,23 @@ def do_schedule(schedule,session,timeslot):
7583 r = do_schedule (schedule ,ames_session ,mars_slot )
7684 self .assertEqual (r .status_code , 201 )
7785
78- # Unschedule mars
86+ # Move the two timeslots close enough together for extension to work
87+ ames_slot_qs = TimeSlot .objects .filter (id = ames_slot .id )
88+ ames_slot_qs .update (time = mars_slot .time + mars_slot .duration + datetime .timedelta (minutes = 10 ))
89+
90+ # Extend the mars session
91+ r = do_extend (schedule ,mars_scheduled )
92+ self .assertEqual (r .status_code , 201 )
93+ self .assertTrue ("error" not in json .loads (r .content ))
94+ self .assertEqual (mars_session .scheduledsession_set .count (),2 )
95+
96+ # Unschedule mars
7997 r = do_unschedule (mars_scheduled )
8098 self .assertEqual (r .status_code , 200 )
8199 self .assertTrue ("error" not in json .loads (r .content ))
100+ # Make sure it got both the original and extended session
101+ self .assertEqual (mars_session .scheduledsession_set .count (),0 )
82102
83- self .assertEqual (ScheduledSession .objects .filter (session = mars_session ).count (), 0 )
84103 self .assertEqual (ScheduledSession .objects .get (session = ames_session ).timeslot , mars_slot )
85104
86105
@@ -187,11 +206,12 @@ def test_sessions_json(self):
187206 info = json .loads (r .content )
188207 self .assertEqual (set ([x ['short_name' ] for x in info ]),set (['mars' ,'ames' ]))
189208
190- schedule = Schedule . objects . filter ( meeting = meeting ). first ()
209+ schedule = meeting . agenda
191210 url = urlreverse ("ietf.meeting.ajax.scheduledsessions_json" ,kwargs = dict (num = meeting .number ,name = schedule .name ))
211+ r = self .client .get (url )
192212 self .assertEqual (r .status_code , 200 )
193213 info = json .loads (r .content )
194- self .assertEqual (set ([ x [ 'short_name' ] for x in info ]), set ([ 'mars' , 'ames' ]) )
214+ self .assertEqual (len ( info ), 2 )
195215
196216
197217 def test_slot_json (self ):
0 commit comments