def test_remove_volunteer(self): self.url = reverse(self.view_name, args=[self.volunteeropp.pk, "off"], urlconf="gbe.scheduling.urls") self.context.book_volunteer(volunteer_sched_event=self.volunteeropp, volunteer=self.profile) redirect_url = reverse('volunteer_signup', urlconf="gbe.scheduling.urls") login_as(self.profile, self) response = self.client.get("%s?next=%s" % (self.url, redirect_url), follow=True) self.assertRedirects(response, redirect_url) self.assertContains(response, self.volunteeropp.eventitem.e_title) assert_alert_exists(response, 'success', 'Success', unset_volunteer_msg) msg = assert_email_template_used( "A change has been made to your Volunteer Schedule!", outbox_size=2) assert ("http://%s%s" % (Site.objects.get_current().domain, reverse('home', urlconf='gbe.urls')) in msg.body) assert_email_recipient([self.profile.user_object.email], outbox_size=2) staff_msg = assert_email_template_used("Volunteer Schedule Change", outbox_size=2, message_index=1) assert (self.volunteeropp.eventitem.e_title in staff_msg.body) assert_email_recipient( [self.context.staff_lead.profile.user_object.email], outbox_size=2, message_index=1)
def test_approve(self): self.context.worker.role = "Pending Volunteer" self.context.worker.save() login_as(self.privileged_user, self) approve_url = reverse(self.approve_name, urlconf='gbe.scheduling.urls', args=[ "approve", self.context.profile.pk, self.context.allocation.pk ]) response = self.client.get(approve_url) self.assertNotContains(response, approve_url) self.assertNotContains(response, '<tr class="gbe-table-row gbe-table-success">') alert_msg = set_volunteer_role_msg % "Volunteer" full_msg = '%s Person: %s<br/>Event: %s, Start Time: %s' % ( alert_msg, str(self.context.profile), str(self.context.opp_event), self.context.opp_event.starttime.strftime(GBE_DATETIME_FORMAT)) assert_alert_exists(response, 'success', 'Success', full_msg) msg = assert_email_template_used( "A change has been made to your Volunteer Schedule!", outbox_size=2) assert ("http://%s%s" % (Site.objects.get_current().domain, reverse('home', urlconf='gbe.urls')) in msg.body) assert_email_recipient([self.context.profile.user_object.email], outbox_size=2) staff_msg = assert_email_template_used("Volunteer Schedule Change", outbox_size=2, message_index=1) assert (str(self.context.opp_event) in staff_msg.body) assert_email_recipient([self.privileged_user.email], outbox_size=2, message_index=1)
def test_parent_event(self): vol_context = VolunteerContext(conference=self.context.conference) lead = vol_context.set_staff_lead() class_context = ClassContext( conference=self.context.conference, teacher=PersonaFactory(performer_profile=self.profile), starttime=vol_context.opp_event.starttime) url = reverse(self.view_name, args=[vol_context.opp_event.pk, "on"], urlconf="gbe.scheduling.urls") login_as(self.profile, self) response = self.client.get(url, follow=True) staff_msg = assert_email_template_used("Volunteer Schedule Change", outbox_size=2, message_index=1) assert (vol_context.opportunity.e_title in staff_msg.body) conflict_msg = 'Conflicting booking: %s, Start Time: %s' % ( class_context.bid.e_title, class_context.sched_event.starttime.strftime(GBE_DATETIME_FORMAT)) assert (class_context.bid.e_title in staff_msg.body) assert_email_recipient([lead.user_object.email], outbox_size=2, message_index=1) self.assertContains(response, conflict_msg) assert (conflict_msg in staff_msg.body)
def test_volunteer_conflict(self): self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Volunteer Coordinator') class_context = ClassContext( conference=self.context.conference, teacher=PersonaFactory(performer_profile=self.profile), starttime=self.volunteeropp.starttime) login_as(self.profile, self) response = self.client.get(self.url, follow=True) redirect_url = reverse('home', urlconf="gbe.urls") msg = assert_email_template_used( "A change has been made to your Volunteer Schedule!", outbox_size=2) assert ("http://%s%s" % (Site.objects.get_current().domain, reverse('home', urlconf='gbe.urls')) in msg.body) assert_email_recipient([self.profile.user_object.email], outbox_size=2) staff_msg = assert_email_template_used("Volunteer Schedule Change", outbox_size=2, message_index=1) assert (self.volunteeropp.eventitem.e_title in staff_msg.body) conflict_msg = 'Conflicting booking: %s, Start Time: %s' % ( class_context.bid.e_title, class_context.sched_event.starttime.strftime(GBE_DATETIME_FORMAT)) assert (class_context.bid.e_title in staff_msg.body) assert_email_recipient([ self.privileged_user.email, self.context.staff_lead.profile.user_object.email ], outbox_size=2, message_index=1) self.assertContains(response, conflict_msg) assert (conflict_msg in staff_msg.body)
def test_act_accept_sends_debug_to_admin(self): url = reverse(self.view_name, args=[self.context.act.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) self.data['accepted'] = '3' response = self.client.post(url, data=self.data) assert_email_recipient([('*****@*****.**')])
def test_act_accept_has_template_per_show(self): EmailTemplateSenderFactory(from_email="*****@*****.**", template__name='act accepted - %s' % self.show.e_title.lower(), template__subject="test template") url = reverse(self.view_name, args=[self.context.act.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) self.data['accepted'] = '3' response = self.client.post(url, data=self.data) assert_email_template_used("test template", "*****@*****.**") assert_email_recipient([(self.context.performer.contact.contact_email) ])
def test_act_accept_has_template_per_show(self): EmailTemplateSenderFactory( from_email="*****@*****.**", template__name='act accepted - %s' % self.show.e_title.lower(), template__subject="test template" ) url = reverse(self.view_name, args=[self.context.act.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) self.data['accepted'] = '3' response = self.client.post(url, data=self.data) assert_email_template_used( "test template", "*****@*****.**") assert_email_recipient([( self.context.performer.contact.contact_email)])
def test_approval_w_conflict(self): self.context.worker.role = "Pending Volunteer" self.context.worker.save() class_context = ClassContext( conference=self.context.conference, teacher=PersonaFactory(performer_profile=self.context.profile), starttime=self.context.opp_event.starttime) self.context.worker.role = "Pending Volunteer" self.context.worker.save() login_as(self.privileged_user, self) approve_url = reverse(self.approve_name, urlconf='gbe.scheduling.urls', args=[ "approve", self.context.profile.pk, self.context.allocation.pk ]) response = self.client.get(approve_url) self.assertNotContains(response, approve_url) self.assertNotContains(response, '<tr gbe-table-row gbe-table-success">') alert_msg = set_volunteer_role_msg % "Volunteer" full_msg = '%s Person: %s<br/>Event: %s, Start Time: %s' % ( alert_msg, str(self.context.profile), str(self.context.opp_event), self.context.opp_event.starttime.strftime(GBE_DATETIME_FORMAT)) conflict_msg = 'Conflicting booking: %s, Start Time: %s' % ( class_context.bid.e_title, class_context.sched_event.starttime.strftime(GBE_DATETIME_FORMAT)) self.assertContains(response, conflict_msg) staff_msg = assert_email_template_used("Volunteer Schedule Change", outbox_size=2, message_index=1) assert (conflict_msg in staff_msg.body) assert (class_context.bid.e_title in staff_msg.body) assert_email_recipient([self.privileged_user.email], outbox_size=2, message_index=1)
def test_act_accept_sends_debug_to_admin(self): login_as(self.privileged_user, self) self.data['accepted'] = '3' response = self.client.post(self.url, data=self.data) assert_email_recipient([('*****@*****.**')])