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_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_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_post_form_edit_exiting_allocation(self): new_volunteer = ProfileFactory() data = self.get_edit_data() data['worker'] = new_volunteer.pk, data['role'] = 'Producer', login_as(self.privileged_profile, self) response = self.client.post(self.url, data=data, follow=True) assert_email_template_used( "A change has been made to your Volunteer Schedule!")
def test_register_spam_check_fail(self, m_urlopen): url = reverse(self.view_name, urlconf='gbe.urls') a = Mock() a.read.side_effect = urllib.error.URLError("test url error") m_urlopen.return_value = a response = self.client.post(url, self.get_post_data(), follow=True) to_list = [admin[1] for admin in settings.ADMINS] assert_email_template_used('Email Spam Check Error', settings.DEFAULT_FROM_EMAIL)
def test_act_waitlist_sends_notification_has_template(self): EmailTemplateSenderFactory(from_email="*****@*****.**", template__name='act wait list', template__subject="test template") url = reverse(self.view_name, args=[self.context.act.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) response = self.client.post(url, data=self.data) assert_email_template_used("test template", "*****@*****.**")
def test_volunteer_withdraw_sends_notification(self): url = reverse(self.view_name, args=[self.volunteer.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) data = {'conference': self.volunteer.b_conference, 'events': [], 'accepted': 4} response = self.client.post(url, data=data) assert_email_template_used( "Your volunteer proposal has changed status to Withdrawn")
def test_post_form_edit_to_rejected(self): new_volunteer = ProfileFactory() data = self.get_edit_data() data['worker'] = new_volunteer.pk, data['role'] = 'Rejected', login_as(self.privileged_profile, self) response = self.client.post(self.url, data=data, follow=True) self.assert_good_post(response, self.volunteer_opp, new_volunteer, self.alloc, 'Do these notes work?', "Rejected") assert_email_template_used( "Your volunteer proposal has changed status to Reject")
def test_act_waitlist_sends_notification_has_template(self): EmailTemplateSenderFactory( from_email="*****@*****.**", template__name='act wait list', template__subject="test template" ) url = reverse(self.view_name, args=[self.context.act.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) response = self.client.post(url, data=self.data) assert_email_template_used( "test template", "*****@*****.**")
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_volunteer_accept_sends_notification_has_template(self): EmailTemplateSenderFactory( from_email="*****@*****.**", template__name='volunteer schedule update', template__subject="test template" ) url = reverse(self.view_name, args=[self.volunteer.pk], urlconf='gbe.urls') login_as(self.privileged_user, self) data = {'conference': self.volunteer.b_conference, 'events': [], 'accepted': 3} response = self.client.post(url, data=data) assert_email_template_used( "test template", "*****@*****.**")
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_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_changestate_book_act_with_conflict(self): # accepted -> waitlist (#2, see above) # change show, change role EmailTemplateSenderFactory(from_email="*****@*****.**", template__name='act wait list', template__subject="test template") grant_privilege(self.privileged_user, 'Act Reviewers') conflict = SchedEventFactory( starttime=self.context.sched_event.starttime) EventLabelFactory(event=conflict, text=self.context.conference.conference_slug) ResourceAllocationFactory( event=conflict, resource=WorkerFactory( _item=self.context.performer.performer_profile)) login_as(self.privileged_user, self) response = self.client.post(self.url, data=self.data, follow=True) self.assertContains(response, "Conflicting booking: %s" % str(conflict)) assert_email_template_used("test template", "*****@*****.**")
def test_set_reject(self): self.context.worker.role = "Pending Volunteer" self.context.worker.save() login_as(self.privileged_user, self) response = self.client.get( reverse(self.approve_name, urlconf='gbe.scheduling.urls', args=[ "reject", self.context.profile.pk, self.context.allocation.pk ])) self.assert_volunteer_state(response, self.context.allocation, "reject") self.assertContains(response, '<tr class="gbe-table-row gbe-table-success">') alert_msg = set_volunteer_role_msg % "Rejected" 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) assert_email_template_used( "Your volunteer proposal has changed status to Reject", outbox_size=2)
def test_post_form_edit_exiting_alloc_used_email_tmpl(self): new_volunteer = ProfileFactory() data = self.get_edit_data() data['worker'] = new_volunteer.pk, data['role'] = 'Producer', login_as(self.privileged_profile, self) response = self.client.post(self.url, data=data, follow=True) msg = assert_email_template_used( "A change has been made to your Volunteer Schedule!") self.unsub_link = Site.objects.get_current().domain + reverse( 'email_update', urlconf='gbe.urls', args=[new_volunteer.user_object.email]) assert (self.unsub_link in msg.body) assert (self.get_param in msg.body)
def test_post_form_valid_delete_allocation_sends_notification(self): data = self.get_edit_data() data['delete'] = 1 login_as(self.privileged_profile, self) response = self.client.post(self.url, data=data, follow=True) self.assertRedirects( response, "%s?worker_open=True&changed_id=%d" % ( reverse('edit_volunteer', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug, self.volunteer_opp.pk]), self.alloc.pk)) msg = assert_email_template_used( "A change has been made to your Volunteer Schedule!") assert("http://%s%s" % ( Site.objects.get_current().domain, reverse('home', urlconf='gbe.urls')) in msg.body)
def test_post_form_valid_delete_allocation_sends_notification(self): data = self.get_edit_data() data['delete'] = 1 login_as(self.privileged_profile, self) response = self.client.post(self.url, data=data, follow=True) self.assertRedirects( response, "%s?worker_open=True&changed_id=%d" % (reverse('edit_volunteer', urlconf='gbe.scheduling.urls', args=[ self.context.conference.conference_slug, self.volunteer_opp.pk ]), self.alloc.pk)) msg = assert_email_template_used( "A change has been made to your Volunteer Schedule!") assert ("http://%s%s" % (Site.objects.get_current().domain, reverse('home', urlconf='gbe.urls')) in msg.body)
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)