def test_get_act_w_label(self): context = ShowContext() act, booking = context.book_act() label = LabelFactory(allocation=booking) response = get_people(labels=[context.conference.conference_slug], roles=["Performer"]) self.assertEqual(response.people[1].label, label.text)
def test_send_email_success_email_sent(self): staffcontext = StaffAreaContext(conference=self.context.conference) volunteer, booking = staffcontext.book_volunteer() showcontext = ShowContext(conference=self.context.conference) showcontext.set_producer(producer=staffcontext.staff_lead) login_as(staffcontext.staff_lead, self) data = { 'to': volunteer.user_object.email, 'sender': staffcontext.staff_lead.user_object.email, 'subject': "Subject", 'html_message': "<p>Test Message</p>", 'email-select-conference': [self.context.conference.pk], 'email-select-roles': [ "Volunteer", ], 'event-select-events': showcontext.show.pk, 'event-select-staff_areas': staffcontext.area.pk, 'event-select-event_collections': "Volunteer", 'send': True } response = self.client.post(self.url, data=data, follow=True) assert_queued_email( [ volunteer.user_object.email, ], data['subject'], data['html_message'], data['sender'], )
def test_pick_performer_specific_show(self): showcontext = ShowContext() anothershowcontext = ShowContext(conference=showcontext.conference, ) producer = showcontext.set_producer() login_as(producer, self) data = { 'email-select-conference': [showcontext.conference.pk, self.context.conference.pk], 'email-select-roles': [ 'Performer', ], 'event-select-events': showcontext.show.pk, 'refine': True, } response = self.client.post(self.url, data=data, follow=True) self.assertNotContains( response, anothershowcontext.performer.contact.user_object.email) self.assertContains(response, showcontext.performer.contact.user_object.email) assert_checkbox(response, "events", 0, showcontext.show.pk, showcontext.show.e_title, prefix="event-select") assert_checkbox(response, "events", 1, anothershowcontext.show.pk, anothershowcontext.show.e_title, checked=False, prefix="event-select")
def test_send_email_success_email_sent(self): staffcontext = StaffAreaContext(conference=self.context.conference) volunteer, booking = staffcontext.book_volunteer() showcontext = ShowContext(conference=self.context.conference) showcontext.set_producer(producer=staffcontext.staff_lead) login_as(staffcontext.staff_lead, self) data = { 'to': volunteer.user_object.email, 'sender': staffcontext.staff_lead.user_object.email, 'subject': "Subject", 'html_message': "<p>Test Message</p>", 'email-select-conference': [self.context.conference.pk], 'email-select-roles': ["Volunteer", ], 'event-select-events': showcontext.show.pk, 'event-select-staff_areas': staffcontext.area.pk, 'event-select-event_collections': "Volunteer", 'send': True } response = self.client.post(self.url, data=data, follow=True) assert_queued_email( [volunteer.user_object.email, ], data['subject'], data['html_message'], data['sender'], )
def test_send_email_failure_preserve_choices(self): staffcontext = StaffAreaContext(conference=self.context.conference) volunteer, booking = staffcontext.book_volunteer() showcontext = ShowContext(conference=self.context.conference) showcontext.set_producer(producer=staffcontext.staff_lead) login_as(self.privileged_profile, self) data = { 'to': volunteer.user_object.email, 'sender': "*****@*****.**", 'html_message': "<p>Test Message</p>", 'email-select-conference': [self.context.conference.pk], 'email-select-roles': [ "Interested", ], 'event-select-events': showcontext.show.pk, 'event-select-staff_areas': staffcontext.area.pk, 'event-select-event_collections': "Volunteer", 'send': True } response = self.client.post(self.url, data=data, follow=True) assert_checkbox(response, "conference", 0, self.context.conference.pk, self.context.conference.conference_slug) assert_checkbox(response, "roles", 0, "Interested", "Interested") assert_checkbox(response, "events", 0, showcontext.show.pk, showcontext.show.e_title, prefix="event-select") assert_checkbox(response, "event_collections", 2, "Volunteer", "All Volunteer Events", prefix="event-select")
def test_get_act_w_label(self): context = ShowContext() act, booking = context.book_act() label = LabelFactory(allocation=booking) response = get_schedule( user=act.performer.performer_profile.user_object) self.assertEqual(response.schedule_items[0].label.text, label.text)
def test_get_eventcontainer(self): context = ShowContext() rehearsal, slot = context.make_rehearsal() response = self.client.get('/admin/scheduler/eventcontainer/', follow=True) self.assertContains(response, rehearsal.e_title) self.assertContains(response, context.show.e_title) self.assertContains(response, context.conference.conference_name)
def setUp(self): self.client = Client() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') self.context = ShowContext() self.url = reverse(self.view_name, urlconf="scheduler.urls", args=[self.context.show.pk])
def setUp(self): self.client = Client() Conference.objects.all().delete() self.conference = ConferenceFactory() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') self.url = reverse(self.view_name, urlconf="scheduler.urls") self.showcontext = ShowContext(conference=self.conference) self.classcontext = ClassContext(conference=self.conference)
def test_review_act_assigned_two_shows(self): context = ShowContext() context2 = ShowContext( conference=context.conference, act=context.acts[0]) login_as(self.privileged_user, self) response = self.client.get( self.url, data={'conf_slug': context.conference.conference_slug}) self.assertContains(response, context.acts[0].b_title) self.assertContains(response, context.show.e_title) self.assertContains(response, context2.show.e_title)
def test_interested_in_event(self): context = ShowContext(conference=self.conf) interested_profile = context.set_interest() url = reverse("event_list", urlconf="gbe.scheduling.urls", args=['Show']) login_as(interested_profile, self) response = self.client.get(url) set_fav_link = reverse("set_favorite", args=[context.sched_event.pk, "off"], urlconf="gbe.scheduling.urls") self.assertContains(response, "%s?next=%s" % (set_fav_link, url))
def test_authorized_user_can_access_rehearsal(self): self.context = ShowContext() rehearsal, slot = self.context.make_rehearsal() self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, slot.pk], urlconf='gbe.scheduling.urls') login_as(self.privileged_user, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertContains(response, "Finish") self.assertContains(response, rehearsal.e_title) self.assertNotContains(response, 'Display Staff')
def test_get_act_w_label(self): context = ShowContext() act, booking = context.book_act() label = LabelFactory(allocation=booking) response = get_people(labels=[context.conference.conference_slug], roles=["Performer"]) target_person = None for person in response.people: if act.performer.user_object == person.user: target_person = person else: self.assertNotEqual(person.label, label.text) self.assertIsNotNone(target_person) self.assertEqual(target_person.label, label.text)
def setUp(self): self.client = Client() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') grant_privilege(self.privileged_user, 'Volunteer Coordinator') self.room = RoomFactory() self.context = ShowContext() self.url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[ self.context.conference.conference_slug, self.context.sched_event.pk ])
def test_pick_performer_mismatch_show(self): showcontext = ShowContext() anothershowcontext = ShowContext() producer = showcontext.set_producer() login_as(producer, self) data = { 'email-select-conference': [anothershowcontext.conference.pk], 'email-select-roles': ['Performer', ], 'event-select-events': showcontext.show.pk, 'refine': True, } response = self.client.post(self.url, data=data, follow=True) self.assertContains( response, "%d is not one of the available choices." % showcontext.show.pk)
def test_copy_child_event(self): show_context = VolunteerContext() target_context = ShowContext() url = reverse( self.view_name, args=[show_context.sched_event.pk], urlconf='gbe.scheduling.urls') data = { 'copy_mode': 'copy_children_only', 'target_event': target_context.sched_event.pk, 'copied_event': show_context.opp_event.pk, 'pick_event': "Finish", } login_as(self.privileged_user, self) response = self.client.post(url, data=data, follow=True) max_pk = Event.objects.latest('pk').pk redirect_url = "%s?%s-day=%d&filter=Filter&new=%s" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[target_context.conference.conference_slug]), target_context.conference.conference_slug, target_context.days[0].pk, str([max_pk]),) self.assertRedirects(response, redirect_url) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s' % ( show_context.opportunity.e_title, datetime.combine( target_context.days[0].day, show_context.opp_event.starttime.time()).strftime( DATETIME_FORMAT)))
def test_send_for_show(self): start_time = datetime.combine( datetime.now().date() + timedelta(days=1), time(0, 0, 0, 0)) show_context = ShowContext(starttime=start_time) context = ActTechInfoContext(show=show_context.show, sched_event=show_context.sched_event, schedule_rehearsal=True) num = schedule_email() self.assertEqual(2, num) queued_email = Email.objects.filter( status=2, subject=self.subject, from_email=settings.DEFAULT_FROM_EMAIL, ) self.assertEqual(queued_email.count(), 2) first = queued_email.filter( to=show_context.performer.performer_profile.user_object.email)[0] self.assertTrue(show_context.show.e_title in first.html_message) self.assertTrue(self.unsub_link in queued_email[0].html_message) self.assertTrue(self.get_param in queued_email[0].html_message) second = queued_email.filter( to=context.performer.performer_profile.user_object.email)[0] self.assertTrue(context.show.e_title in second.html_message) self.assertTrue( context.rehearsal.eventitem.event.e_title in second.html_message)
def test_authorized_user_pick_mode_only_children(self): show_context = VolunteerContext() target_context = ShowContext() url = reverse( self.view_name, args=[show_context.sched_event.pk], urlconf='gbe.scheduling.urls') data = { 'copy_mode': 'copy_children_only', 'target_event': target_context.sched_event.pk, 'room': target_context.room.pk, 'pick_mode': "Next", } delta = target_context.sched_event.starttime.date( ) - show_context.sched_event.starttime.date() login_as(self.privileged_user, self) response = self.client.post(url, data=data, follow=True) self.assertContains( response, '<input type="radio" name="copy_mode" ' + 'value="copy_children_only" ' + 'id="id_copy_mode_0" required checked />', html=True) self.assertContains( response, '<option value="%d" selected>' % ( target_context.sched_event.pk)) self.assertContains(response, "Choose Sub-Events to be copied") self.assertContains(response, "%s - %s" % ( show_context.opportunity.e_title, (show_context.opp_event.start_time + delta).strftime( self.copy_date_format)))
def test_pick_performer_mismatch_show(self): showcontext = ShowContext() anothershowcontext = ShowContext() producer = showcontext.set_producer() login_as(producer, self) data = { 'email-select-conference': [anothershowcontext.conference.pk], 'email-select-roles': [ 'Performer', ], 'event-select-events': showcontext.show.pk, 'refine': True, } response = self.client.post(self.url, data=data, follow=True) self.assertContains( response, "%d is not one of the available choices." % showcontext.show.pk)
def test_review_act_assigned_show(self): context = ShowContext() login_as(self.privileged_user, self) response = self.client.get( self.url, data={'conf_slug': context.conference.conference_slug}) assert context.acts[0].b_title in response.content assert context.show.e_title in response.content
def test_review_act_assigned_show_role(self): context = ShowContext(act_role="Hosted By...") login_as(self.privileged_user, self) response = self.client.get( self.url, data={'conf_slug': context.conference.conference_slug}) self.assertContains(response, context.show.e_title) self.assertContains(response, "Hosted By...")
def test_interest_not_shown(self): context = ShowContext(conference=ConferenceFactory(status="completed")) url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[context.show.eventitem_id]) login_as(context.performer.performer_profile, self) response = self.client.get(url) self.assertNotContains(response, 'fa-star') self.assertNotContains(response, 'fa-star-o')
def test_disabled_interest(self): context = ShowContext() url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[context.show.eventitem_id]) login_as(context.performer.performer_profile, self) response = self.client.get(url) self.assertContains(response, 'cal-favorite detail_link-detail_disable')
def setUp(self): self.client = Client() clear_conferences() conference = ConferenceFactory() save_the_date = datetime(2016, 02, 06, 12, 00, 00) day = ConferenceDayFactory(conference=conference, day=date(2016, 02, 06)) self.staffcontext = StaffAreaContext(conference=conference, starttime=save_the_date) self.showcontext = ShowContext(conference=conference, starttime=save_the_date) self.other_conference = ConferenceFactory(status='completed') self.other_conf_day = ConferenceDayFactory( conference=self.other_conference, day=date(2015, 02, 06)) self.other_show = ShowContext(conference=self.other_conference) self.classcontext = ClassContext(conference=conference, starttime=save_the_date) self.volunteeropp = self.staffcontext.add_volunteer_opp()
def test_send_email_failure_preserve_choices(self): staffcontext = StaffAreaContext(conference=self.context.conference) volunteer, booking = staffcontext.book_volunteer() showcontext = ShowContext(conference=self.context.conference) showcontext.set_producer(producer=staffcontext.staff_lead) login_as(self.privileged_profile, self) data = { 'to': volunteer.user_object.email, 'sender': "*****@*****.**", 'html_message': "<p>Test Message</p>", 'email-select-conference': [self.context.conference.pk], 'email-select-roles': ["Interested", ], 'event-select-events': showcontext.show.pk, 'event-select-staff_areas': staffcontext.area.pk, 'event-select-event_collections': "Volunteer", 'send': True } response = self.client.post(self.url, data=data, follow=True) assert_checkbox( response, "conference", 0, self.context.conference.pk, self.context.conference.conference_slug) assert_checkbox( response, "roles", 0, "Interested", "Interested") assert_checkbox( response, "events", 0, showcontext.show.pk, showcontext.show.e_title, prefix="event-select") assert_checkbox( response, "event_collections", 2, "Volunteer", "All Volunteer Events", prefix="event-select")
def test_interest_not_shown(self): old_conf = ConferenceFactory(status="completed") context = ShowContext(conference=old_conf) url = reverse("event_list", urlconf="gbe.scheduling.urls", args=["Show"]) response = self.client.get( url, data={"conference": old_conf.conference_slug}) login_as(context.performer.performer_profile, self) response = self.client.get(url) self.assertNotContains(response, 'fa-star') self.assertNotContains(response, 'fa-star-o')
def test_get_show_w_no_acts(self): no_act_context = ShowContext() no_act_context.performer.delete() no_act_context.acts[0].delete() no_act_url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[no_act_context.sched_event.pk]) self.profile = ProfileFactory() grant_privilege(self.profile, 'Act Coordinator') login_as(self.profile, self) response = self.client.get(no_act_url) self.assertContains(response, "There are no available acts.")
def test_pick_performer_reduced_priv(self): showcontext = ShowContext() producer = showcontext.set_producer() anothershowcontext = ShowContext( conference=showcontext.conference, ) login_as(producer, self) data = { 'email-select-conference': [showcontext.conference.pk, self.context.conference.pk], 'email-select-roles': ['Performer', ], 'filter': True, } response = self.client.post(self.url, data=data, follow=True) self.assertNotContains( response, self.context.teacher.contact.user_object.email) self.assertContains( response, showcontext.performer.contact.user_object.email) self.assertContains( response, anothershowcontext.performer.contact.user_object.email) assert_checkbox( response, "events", 0, showcontext.show.pk, showcontext.show.e_title, checked=False, prefix="event-select") assert_checkbox( response, "events", 1, anothershowcontext.show.pk, anothershowcontext.show.e_title, checked=False, prefix="event-select")
def test_not_really_interested_in_event(self): context = ShowContext() interested_profile = ProfileFactory() url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[context.show.eventitem_id]) login_as(interested_profile, self) response = self.client.get(url) set_fav_link = reverse("set_favorite", args=[context.sched_event.pk, "on"], urlconf="gbe.scheduling.urls") self.assertContains(response, "%s?next=%s" % (set_fav_link, url)) self.assertNotContains(response, "fa-tachometer")
def test_authorized_user_get_show(self): show_context = VolunteerContext() target_context = ShowContext() url = reverse( self.view_name, args=[show_context.sched_event.pk], urlconf='gbe.scheduling.urls') login_as(self.privileged_user, self) response = self.client.get(url) self.assert_good_mode_form( response, target_context.show.e_title, target_context.sched_event.start_time)
def test_good_user_change_show(self): new_show = ShowContext(conference=self.context.conference) login_as(self.privileged_profile, self) allocation = self.context.sched_event.resources_allocated.filter( resource__actresource___item=self.context.acts[0]).first() data = self.get_basic_post() data['allocation_%d-show' % allocation.pk] = str( new_show.sched_event.pk) response = self.client.post(self.url, data=data) self.assertRedirects(response, reverse('home', urlconf='gbe.urls')) self.assertEqual(new_show.sched_event.volunteer_count, "2 acts") self.assertEqual(self.context.sched_event.volunteer_count, 0)
def test_pick_performer_reduced_priv(self): showcontext = ShowContext() showcontext.show.e_title = "0 Pick Perf" showcontext.show.save() producer = showcontext.set_producer() anothershowcontext = ShowContext(conference=showcontext.conference, ) anothershowcontext.show.e_title = "1 Pick Perf" anothershowcontext.show.save() login_as(producer, self) data = { 'email-select-conference': [showcontext.conference.pk, self.context.conference.pk], 'email-select-roles': [ 'Performer', ], 'filter': True, } response = self.client.post(self.url, data=data, follow=True) self.assertNotContains(response, self.context.teacher.contact.user_object.email) self.assertContains(response, showcontext.performer.contact.user_object.email) self.assertContains( response, anothershowcontext.performer.contact.user_object.email) self.assert_checkbox(response, "events", 0, showcontext.show.pk, showcontext.show.e_title, checked=False, prefix="event-select") self.assert_checkbox(response, "events", 1, anothershowcontext.show.pk, anothershowcontext.show.e_title, checked=False, prefix="event-select")
def setUp(self): self.client = Client() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') self.url = reverse(self.view_name, urlconf="gbe.scheduling.urls") self.volunteer_context = VolunteerContext() self.day = self.volunteer_context.conf_day self.class_context = ClassContext(conference=self.day.conference) self.show_context = ShowContext(conference=self.day.conference) self.staff_context = StaffAreaContext(conference=self.day.conference) booking, self.vol_opp = self.staff_context.book_volunteer()
def setUp(self): self.client = Client() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') grant_privilege(self.privileged_user, 'Volunteer Coordinator') self.room = RoomFactory() self.context = ShowContext() self.url = reverse( self.view_name, urlconf="gbe.scheduling.urls", args=[self.context.conference.conference_slug, self.context.sched_event.pk])
def test_authorized_user_can_access_rehearsal(self): self.context = ShowContext() rehearsal, slot = self.context.make_rehearsal() self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, slot.pk], urlconf='gbe.scheduling.urls') login_as(self.privileged_user, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertContains(response, "Finish") self.assertContains(response, rehearsal.e_title) self.assertNotContains(response, 'Staffing')
def test_volunteer_has_show_conflict(self): show_context = ShowContext( conference=self.context.conference, performer=PersonaFactory(performer_profile=self.context.profile), starttime=self.context.opp_event.start_time) login_as(self.privileged_profile, self) response = self.client.get(self.url, follow=True) assert ("no available volunteers" not in response.content) assert_link( response, reverse(self.view_name, args=[ self.context.conference.conference_slug, show_context.sched_event.pk ], urlconf="gbe.scheduling.urls"))
def setUp(self): self.context = VolunteerContext(event=GenericEventFactory()) self.context.sched_event.max_volunteer = 7 self.context.sched_event.save() self.context.event.duration = Duration(hours=1, minutes=30) self.context.event.save() self.room = self.context.room self.staff_lead = self.context.set_staff_lead() self.extra_day = ConferenceDayFactory( conference=self.context.conference, day=self.context.conf_day.day + timedelta(days=1)) self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, self.context.sched_event.pk], urlconf='gbe.scheduling.urls') self.client = Client() self.privileged_user = ProfileFactory().user_object grant_privilege(self.privileged_user, 'Scheduling Mavens')
class TestEditEventView(TestCase): '''This view edits classes that were made through the wizard''' view_name = 'edit_event' def setUp(self): self.context = VolunteerContext(event=GenericEventFactory()) self.context.sched_event.max_volunteer = 7 self.context.sched_event.save() self.context.event.duration = Duration(hours=1, minutes=30) self.context.event.save() self.room = self.context.room self.staff_lead = self.context.set_staff_lead() self.extra_day = ConferenceDayFactory( conference=self.context.conference, day=self.context.conf_day.day + timedelta(days=1)) self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, self.context.sched_event.pk], urlconf='gbe.scheduling.urls') self.client = Client() self.privileged_user = ProfileFactory().user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') def edit_event(self): data = { 'type': 'Special', 'e_title': "Test Event Wizard", 'e_description': 'Description', 'max_volunteer': 3, 'day': self.extra_day.pk, 'time': '11:00:00', 'duration': 2.5, 'location': self.room.pk, 'set_event': 'Any value', 'alloc_0-role': 'Staff Lead', } return data def test_edit_event_unauthorized_user(self): login_as(ProfileFactory(), self) response = self.client.get(self.url) self.assertEqual(403, response.status_code) def test_authorized_user_can_access_event(self): login_as(self.privileged_user, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) assert_role_choice(response, "Staff Lead") self.assertNotContains(response, "Volunteer Management") self.assertContains(response, "Finish") self.assertContains(response, self.context.event.e_title) self.assertContains(response, self.context.event.e_description) self.assertContains( response, '<option value="%d" selected="selected">%s</option>' % ( self.context.conf_day.pk, self.context.conf_day.day.strftime(DATE_FORMAT))) self.assertContains(response, 'name="max_volunteer" type="number" value="7" />') self.assertContains( response, 'name="duration" step="any" type="number" value="1.5" />') self.assertContains( response, '<option value="%d" selected="selected">%s</option>' % ( self.staff_lead.pk, str(self.staff_lead))) def test_authorized_user_can_also_get_volunteer_mgmt(self): grant_privilege(self.privileged_user, 'Volunteer Coordinator') login_as(self.privileged_user, self) response = self.client.get(self.url, follow=True) self.assertEqual(response.status_code, 200) self.assertContains(response, "Volunteer Management") self.assertContains(response, "Save and Continue") self.assertContains( response, '<option value="%d" selected="selected">%s</option>' % ( self.context.conf_day.pk, self.context.conf_day.day.strftime("%b. %-d, %Y"))) self.assertContains( response, 'name="new_opp-max_volunteer" type="number" value="7" />') self.assertContains( response, 'name="new_opp-duration" step="any" type="number" value="1.5" />') def test_authorized_user_can_access_rehearsal(self): self.context = ShowContext() rehearsal, slot = self.context.make_rehearsal() self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, slot.pk], urlconf='gbe.scheduling.urls') login_as(self.privileged_user, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertContains(response, "Finish") self.assertContains(response, rehearsal.e_title) self.assertNotContains(response, 'Staffing') def test_vol_opp_present(self): vol_context = VolunteerContext() vol_context.sched_event.max_volunteer = 7 vol_context.sched_event.save() vol_context.opp_event.set_locations([]) grant_privilege(self.privileged_user, 'Volunteer Coordinator') login_as(self.privileged_user, self) self.url = reverse( self.view_name, args=[vol_context.conference.conference_slug, vol_context.sched_event.pk], urlconf='gbe.scheduling.urls') response = self.client.get(self.url, follow=True) self.assertContains( response, 'name="opp_event_id" type="hidden" value="%d" />' % ( vol_context.opportunity.pk) ) self.assertContains( response, 'name="opp_sched_id" type="hidden" value="%d" />' % ( vol_context.opp_event.pk) ) self.assertContains( response, '<option value="%d" selected="selected">%s</option>' % ( vol_context.window.day.pk, vol_context.window.day.day.strftime("%b. %-d, %Y")), 3) self.assertContains( response, 'name="max_volunteer" type="number" value="2" />') self.assertContains( response, 'name="duration" step="any" type="number" value="1.0" />') def test_bad_conference(self): login_as(self.privileged_user, self) self.url = reverse( self.view_name, args=["BadConf", self.context.sched_event.pk], urlconf='gbe.scheduling.urls') response = self.client.get(self.url) self.assertEqual(response.status_code, 404) def test_bad_occurrence_id(self): login_as(self.privileged_user, self) self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, self.context.sched_event.pk+1000], urlconf='gbe.scheduling.urls') response = self.client.get(self.url, follow=True) self.assertRedirects( response, reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug])) self.assertContains( response, "Occurrence id %d not found" % (self.context.sched_event.pk+1000)) def test_edit_event_w_staffing(self): login_as(self.privileged_user, self) data = self.edit_event() data['alloc_0-worker'] = self.privileged_user.profile.pk response = self.client.post( self.url, data=data, follow=True) self.assertRedirects( response, "%s?%s-day=%d&filter=Filter&new=[%dL]" % ( reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug]), self.context.conference.conference_slug, self.extra_day.pk, self.context.sched_event.pk)) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s 11:00 AM' % ( data['e_title'], self.extra_day.day.strftime(DATE_FORMAT)) ) self.assertContains( response, '<tr class="bid-table success">\n ' + '<td class="bid-table">%s</td>' % data['e_title']) def test_edit_event_and_continue(self): grant_privilege(self.privileged_user, 'Volunteer Coordinator') login_as(self.privileged_user, self) data = self.edit_event() data['edit_event'] = "Save and Continue" response = self.client.post( self.url, data=data, follow=True) self.assertRedirects( response, "%s?volunteer_open=True" % self.url) assert_alert_exists( response, 'success', 'Success', 'Occurrence has been updated.<br>%s, Start Time: %s 11:00 AM' % ( data['e_title'], self.extra_day.day.strftime(DATE_FORMAT)) ) self.assertContains(response, data['e_title']) self.assertContains(response, data['e_description']) self.assertContains( response, '<option value="%d" selected="selected">%s</option>' % ( self.extra_day.pk, self.extra_day.day.strftime(DATE_FORMAT))) self.assertContains(response, 'name="max_volunteer" type="number" value="3" />') self.assertContains( response, 'name="duration" step="any" type="number" value="2.5" />') def test_auth_user_bad_user_assign(self): login_as(self.privileged_user, self) data = self.edit_event() data['alloc_0-role'] = "bad role" data['alloc_1-role'] = "bad role" response = self.client.post( self.url, data=data, follow=True) self.assertContains( response, "bad role is not one of the available choices.") def test_auth_user_bad_schedule_assign(self): login_as(self.privileged_user, self) data = self.edit_event() data['location'] = "" response = self.client.post( self.url, data=data, follow=True) self.assertContains(response, "This field is required.") def test_auth_user_bad_generic_booking_assign(self): login_as(self.privileged_user, self) data = self.edit_event() data['e_title'] = "" response = self.client.post( self.url, data=data, follow=True) self.assertContains( response, "This field is required.") def test_post_bad_occurrence(self): login_as(self.privileged_user, self) self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, self.context.sched_event.pk+1000], urlconf='gbe.scheduling.urls') response = self.client.post(self.url, follow=True) self.assertRedirects( response, reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug])) self.assertContains( response, "Occurrence id %d not found" % (self.context.sched_event.pk+1000))
class TestEditShowWizard(TestCase): view_name = 'manage_show_opp' def setUp(self): self.client = Client() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') grant_privilege(self.privileged_user, 'Volunteer Coordinator') self.room = RoomFactory() self.context = ShowContext() self.url = reverse( self.view_name, urlconf="gbe.scheduling.urls", args=[self.context.conference.conference_slug, self.context.sched_event.pk]) def get_new_slot_data(self, context): data = { 'create_slot': 'create_slot', 'new_slot-e_title': 'New Rehearsal Slot', 'new_slot-type': "Rehearsal Slot", 'new_slot-max_volunteer': '1', 'new_slot-duration': '1.0', 'new_slot-day': self.context.days[0].pk, 'new_slot-time': '10:00:00', 'new_slot-location': self.room.pk} return data def get_basic_data(self, context): data = { 'e_title': 'Copied Rehearsal Slot', 'type': 'Rehearsal Slot', 'max_volunteer': '1', 'duration': '1.0', 'day': self.context.days[0].pk, 'time': '10:00:00', 'location': self.room.pk} return data def get_basic_action_data(self, context, action): data = self.get_basic_data(context) rehearsal, slot = self.context.make_rehearsal() data['e_title'] = 'Modify Rehearsal Slot' data['opp_event_id'] = rehearsal.event_id data['opp_sched_id'] = slot.pk data[action] = action return data, rehearsal, slot def test_good_user_get(self): self.url = reverse( "edit_show", urlconf="gbe.scheduling.urls", args=[self.context.conference.conference_slug, self.context.sched_event.pk]) login_as(self.privileged_profile, self) response = self.client.get(self.url, follow=True) self.assertContains(response, "Edit Show Details") self.assertContains(response, "Manage Volunteer Opportunities") self.assertContains(response, "Manage Rehearsal Slots") self.assertContains(response, 'class="panel-collapse collapse in"', 3) def test_good_user_get_rehearsal_w_acts(self): act_techinfo_context = ActTechInfoContext( show=self.context.show, sched_event=self.context.sched_event, schedule_rehearsal=True) self.url = reverse( "edit_show", urlconf="gbe.scheduling.urls", args=[self.context.conference.conference_slug, self.context.sched_event.pk]) login_as(self.privileged_profile, self) response = self.client.get(self.url, follow=True) self.assertContains( response, '<input id="id_current_acts" name="current_acts" ' + 'readonly="readonly" type="number" value="1" />') def test_good_user_get_empty_room_rehearsal(self): rehearsal, slot = self.context.make_rehearsal(room=False) login_as(self.privileged_profile, self) response = self.client.get(self.url, follow=True) self.assertContains( response, '<option value="%d" selected="selected">%s</option>' % ( self.context.room.pk, str(self.context.room)), 4) def test_good_user_get_bad_occurrence_id(self): login_as(self.privileged_user, self) self.url = reverse( self.view_name, args=[self.context.conference.conference_slug, self.context.sched_event.pk+1000], urlconf='gbe.scheduling.urls') response = self.client.get(self.url, follow=True) self.assertRedirects( response, reverse('manage_event_list', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug])) self.assertContains( response, "Occurrence id %d not found" % (self.context.sched_event.pk+1000)) def test_create_slot(self): login_as(self.privileged_profile, self) response = self.client.post( self.url, data=self.get_new_slot_data(self.context), follow=True) self.assertContains( response, '<div id="collapse3" class="panel-collapse collapse in">') slots = EventContainer.objects.filter( parent_event=self.context.sched_event) self.assertTrue(slots.exists()) for slot in slots: self.assertEqual(slot.child_event.eventitem.child().e_title, 'New Rehearsal Slot') self.assertRedirects( response, "%s?changed_id=%d&rehearsal_open=True" % ( reverse('edit_show', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug, self.context.sched_event.pk]), slot.child_event.pk)) self.assertEqual(EventLabel.objects.filter( text=slot.child_event.eventitem.child( ).e_conference.conference_slug, event=slot.child_event).count(), 1) self.assertEqual(EventLabel.objects.filter( event=slot.child_event).count(), 1) self.assertContains( response, '<input id="id_e_title" maxlength="128" name="e_title" ' + 'type="text" value="New Rehearsal Slot" />') def test_create_slot_error(self): login_as(self.privileged_profile, self) data = self.get_new_slot_data(self.context) data['new_slot-max_volunteer'] = '' # number of volunteers is missing, it's required response = self.client.post( self.url, data=data, follow=True) self.assertEqual(response.status_code, 200) self.assertContains( response, '<div id="collapse3" class="panel-collapse collapse in">') slots = EventContainer.objects.filter( parent_event=self.context.sched_event).count() self.assertEqual(slots, 0) self.assertContains( response, '<ul class="errorlist"><li>This field is required.</li></ul>') def test_copy_opportunity(self): login_as(self.privileged_profile, self) data = self.get_basic_data(self.context) data['duplicate_slot'] = 'duplicate_slot' response = self.client.post( self.url, data=data, follow=True) self.assertContains( response, '<div id="collapse3" class="panel-collapse collapse in">') slots = EventContainer.objects.filter( parent_event=self.context.sched_event) self.assertTrue(len(slots), 1) for slot in slots: self.assertContains( response, '<input id="id_e_title" maxlength="128" ' 'name="e_title" type="text" value="%s" />' % ( slot.child_event.eventitem.child().e_title)) self.assertRedirects( response, "%s?changed_id=%d&rehearsal_open=True" % ( reverse( 'edit_show', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug, self.context.sched_event.pk]), slot.child_event.pk)) def test_edit_slot(self): login_as(self.privileged_profile, self) data, rehearsal, slot = self.get_basic_action_data(self.context, 'edit_slot') response = self.client.post( self.url, data=data, follow=True) self.assertRedirects( response, "%s?changed_id=%d&rehearsal_open=True" % ( reverse('edit_show', urlconf='gbe.scheduling.urls', args=[self.context.conference.conference_slug, self.context.sched_event.pk]), slot.pk)) slots = EventContainer.objects.filter( parent_event=self.context.sched_event) self.assertTrue(len(slots), 1) self.assertContains( response, '<input id="id_e_title" maxlength="128" name="e_title" ' + 'type="text" value="Modify Rehearsal Slot" />') self.assertContains(response, self.room.name) def test_edit_error(self): login_as(self.privileged_profile, self) data, rehearsal, slot = self.get_basic_action_data(self.context, 'edit_slot') data['max_volunteer'] = '' # number of volunteers is missing, it's required response = self.client.post( self.url, data=data, follow=True) self.assertEqual(response.status_code, 200) self.assertContains( response, '<input id="id_e_title" maxlength="128" name="e_title" ' + 'type="text" value="Modify Rehearsal Slot" />') self.assertContains( response, '<ul class="errorlist"><li>This field is required.</li></ul>') def test_delete_slot(self): login_as(self.privileged_profile, self) data, rehearsal, slot = self.get_basic_action_data(self.context, 'delete_slot') # number of volunteers is missing, it's required response = self.client.post( self.url, data=data, follow=True) self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'Modify Rehearsal Slot') slots = EventContainer.objects.filter( parent_event=self.context.sched_event) self.assertFalse(slots.exists())
class TestExportCalendar(TestCase): view_name = 'export_calendar' def setUp(self): self.client = Client() Conference.objects.all().delete() self.conference = ConferenceFactory() self.user = ProfileFactory.create().user_object self.privileged_profile = ProfileFactory() self.privileged_user = self.privileged_profile.user_object grant_privilege(self.privileged_user, 'Scheduling Mavens') self.url = reverse(self.view_name, urlconf="scheduler.urls") self.showcontext = ShowContext(conference=self.conference) self.classcontext = ClassContext(conference=self.conference) def make_three_day_spread(self): conference_events = [self.showcontext.sched_event, self.classcontext.sched_event] two_day = timedelta(2) ConferenceDayFactory(conference=self.conference, day=date(2016, 2, 6)) ConferenceDayFactory(conference=self.conference, day=date(2016, 2, 7)) conference_events += [self.showcontext.schedule_instance()] conference_events += [self.showcontext.schedule_instance( starttime=self.showcontext.sched_event.starttime+two_day)] conference_events += [self.classcontext.schedule_instance()] conference_events += [self.classcontext.schedule_instance( starttime=self.classcontext.sched_event.starttime+two_day)] return conference_events def test_no_login(self): response = self.client.get(self.url, follow=True) redirect_url = reverse( 'login', urlconf='gbe.urls') + "/?next=" + self.url self.assertRedirects(response, redirect_url) self.assertTrue(is_login_page(response)) def test_no_schedule(self): Conference.objects.all().delete() show = ShowFactory() SchedEventFactory.create(eventitem=show.eventitem_ptr) login_as(ProfileFactory(), self) response = self.client.get(self.url) self.assertTrue(response.content.count('\n') == 1) self.assertTrue('Session Title' in response.content) def test_schedule(self): login_as(ProfileFactory(), self) response = self.client.get(self.url) self.assertTrue(response.content.count('\n') > 1) self.assertTrue(len( (response.content.split('\r\n')[1].split('","'))) >= 8) self.assertIn(self.showcontext.show.e_title, response.content) def test_guidebook(self): login_as(ProfileFactory(), self) response = self.client.get(self.url) self.assertIn(self.showcontext.show.e_title, response.content) self.assertIn(self.classcontext.bid.b_title, response.content) def test_ical(self): login_as(ProfileFactory(), self) response = self.client.get(self.url + '?cal_format=ical') self.assertTrue('BEGIN:VCALENDAR' in response.content.split('\r\n')[0]) vevent_count = 0 for line in response.content.split('\r\n'): if 'BEGIN:VEVENT' in line: vevent_count = vevent_count + 1 self.assertTrue(vevent_count > 0) def test_type_class(self): login_as(ProfileFactory(), self) response = self.client.get(self.url + '?event_types=Class') self.assertNotIn(self.showcontext.show.e_title, response.content) self.assertIn(self.classcontext.bid.b_title, response.content) def test_type_show(self): login_as(ProfileFactory(), self) response = self.client.get(self.url + '?event_types=Show') self.assertIn(self.showcontext.show.e_title, response.content) self.assertNotIn(self.classcontext.bid.b_title, response.content) def test_day_all(self): login_as(ProfileFactory(), self) event_set = self.make_three_day_spread() response = self.client.get(self.url + '?day=All') fri_count, sat_count, sun_count = 0, 0, 0 for line in response.content.split('\r\n'): if 'Feb. 5' in line: fri_count = fri_count + 1 elif 'Feb. 6' in line: sat_count = sat_count + 1 elif 'Feb. 7' in line: sun_count = sun_count + 1 self.assertTrue(fri_count == 2 and sat_count == 2 and sun_count == 2) def test_day_sat(self): login_as(ProfileFactory(), self) event_set = self.make_three_day_spread() response = self.client.get(self.url + '?day=Saturday') fri_count, sat_count, sun_count = 0, 0, 0 for line in response.content.split('\r\n'): if 'Feb. 5' in line: fri_count = fri_count + 1 elif 'Feb. 6' in line: sat_count = sat_count + 1 elif 'Feb. 7' in line: sun_count = sun_count + 1 self.assertTrue(fri_count == 0 and sat_count == 2 and sun_count == 0)