def test_simple_scheduling(self): vol = Volunteer(volunteer_id='v001') group = StudentGroup('A') sess = Session(week='week2', day='thursday', session_id='s001') sess.assign_student_group(group) sess.schedule_volunteer(vol) self.assertEqual( vol.get_groups_seen(), ['A'], 'volunteer has correctly updated list of groups seen') self.assertEqual(vol.get_schedule()['thursday']['week2'], ['s001'], 'volunteer schedule updated correctly') self.assertEqual(vol.get_times_scheduled(), 1, 'correctly counted times scheduled') self.assertEqual(vol.get_schedule()['tuesday']['week2'], [], 'Tuesday not updated')
def test_shceduling_previously_seen_volunteer(self): vol = Volunteer(volunteer_id='v001') group = StudentGroup('A') sess1 = Session(week='week2', day='thursday', session_id='s001') sess1.assign_student_group(group) sess2 = Session(week='week3', day='tuesday', session_id='s002') sess2.assign_student_group(group) sess1.schedule_volunteer(vol) sess2.schedule_volunteer(vol) self.assertEqual( vol.get_groups_seen(), ['A'], 'volunteer has correctly updated list of groups seen') self.assertEqual(vol.get_schedule()['thursday']['week2'], ['s001'], 'first schedule update successful') self.assertEqual(vol.get_schedule()['tuesday']['week3'], [], 'second schedule update not successful')
def test_over_scheduling_volunteer(self): vol = Volunteer(volunteer_id='v001') # create 5 sessions on the same day, each session with a different student group sessions = [] for i in range(1, 6): group = StudentGroup('A' + str(i)) sess = Session(week='week2', day='thursday', session_id='s00' + str(i)) sess.assign_student_group(group) sessions.append(sess) # schedule the volunteer for all sessions for session in sessions: session.schedule_volunteer(vol) self.assertEqual(len(vol.get_schedule()['thursday']['week2']), 4, "only four of the five sessions are scheduled")