def test_complete_wout_rehearsals_act(self): ''' view should load ''' complete_act_context = ActTechInfoContext() complete_act_context.act.tech = TechInfoFactory( confirm_no_music=True, confirm_no_rehearsal=True, prop_setup="text", starting_position="Onstage", primary_color="text", feel_of_act="text", pronouns="text", introduction_text="text") complete_act_context.act.accepted = 3 complete_act_context.act.save() self.profile = complete_act_context.make_priv_role() login_as(self.profile, self) response = self.client.get( reverse(self.view_name, urlconf='gbe.scheduling.urls', args=[complete_act_context.sched_event.pk])) self.assertContains(response, complete_act_context.act.b_title) self.assertNotContains(response, 'class="gbe-table-row gbe-table-danger"') self.assertContains(response, "No audio track needed") self.assertContains(response, "Acknowledged No Rehearsal") self.assertContains( response, '<i class="fas fa-check-circle gbe-text-success"></i>')
class TestIndex(TestCase): '''Tests for index view''' view_name = 'home' def setUp(self): self.client = Client() # Conference Setup self.factory = RequestFactory() self.current_conf = ConferenceFactory(accepting_bids=True, status='upcoming') self.previous_conf = ConferenceFactory(accepting_bids=False, status='completed') # User/Human setup self.profile = ProfileFactory() self.performer = PersonaFactory(performer_profile=self.profile, contact=self.profile, label="Test Index Label") # Bid types previous and current self.current_act = ActFactory(performer=self.performer, submitted=True, b_conference=self.current_conf) self.previous_act = ActFactory(performer=self.performer, submitted=True, b_conference=self.previous_conf) self.current_class = ClassFactory(teacher=self.performer, submitted=True, accepted=3, b_conference=self.current_conf, e_conference=self.current_conf) self.previous_class = ClassFactory(teacher=self.performer, submitted=True, accepted=3, b_conference=self.previous_conf, e_conference=self.previous_conf) self.current_vendor = VendorFactory( business__owners=[self.profile], submitted=True, b_conference=self.current_conf) self.previous_vendor = VendorFactory( business__owners=[self.profile], submitted=True, b_conference=self.previous_conf) self.current_costume = CostumeFactory( profile=self.profile, submitted=True, b_conference=self.current_conf) self.previous_costume = CostumeFactory( profile=self.profile, submitted=True, b_conference=self.previous_conf) # Event assignments, previous and current current_opportunity = GenericEventFactory( e_conference=self.current_conf, type='Volunteer') previous_opportunity = GenericEventFactory( e_conference=self.previous_conf) self.current_sched = SchedEventFactory( eventitem=current_opportunity, starttime=datetime(2016, 2, 5, 12, 30, 0, 0), max_volunteer=10) self.previous_sched = SchedEventFactory( eventitem=previous_opportunity, starttime=datetime(2015, 2, 25, 12, 30, 0, 0), max_volunteer=10) self.current_class_sched = SchedEventFactory( eventitem=self.current_class, starttime=datetime(2016, 2, 5, 2, 30, 0, 0), max_volunteer=10) self.previous_class_sched = SchedEventFactory( eventitem=self.previous_class, starttime=datetime(2015, 2, 25, 2, 30, 0, 0), max_volunteer=10) worker = WorkerFactory(_item=self.profile, role='Volunteer') for schedule_item in [self.current_sched, self.previous_sched]: volunteer_assignment = ResourceAllocationFactory( event=schedule_item, resource=worker ) LabelFactory(text="label %d" % volunteer_assignment.pk, allocation=volunteer_assignment) persona_worker = WorkerFactory(_item=self.performer, role='Teacher') for schedule_item in [self.current_class_sched, self.previous_class_sched]: volunteer_assignment = ResourceAllocationFactory( event=schedule_item, resource=worker ) def assert_event_is_present(self, response, event): ''' test all parts of the event being on the landing page schedule''' self.assertContains(response, event.eventitem.e_title) self.assertContains(response, date_format(event.start_time, "DATETIME_FORMAT")) self.assertContains(response, reverse( 'detail_view', urlconf="gbe.scheduling.urls", args=[event.eventitem.eventitem_id])) def assert_event_is_not_present(self, response, event): ''' test all parts of the event being on the landing page schedule''' self.assertNotContains(response, event.eventitem.e_title) self.assertNotContains( response, date_format(event.start_time, "DATETIME_FORMAT")) self.assertNotContains(response, reverse( 'detail_view', urlconf="gbe.scheduling.urls", args=[event.eventitem.eventitem_id])) def get_landing_page(self): self.url = reverse('home', urlconf='gbe.urls') login_as(self.profile, self) return self.client.get(self.url) def test_no_profile(self): url = reverse('home', urlconf="gbe.urls") login_as(UserFactory(), self) response = self.client.get(url, follow=True) self.assertRedirects(response, '%s?next=%s' % ( reverse('profile_update', urlconf="gbe.urls"), url)) def test_landing_page_path(self): '''Basic test of landing_page view ''' response = self.get_landing_page() self.assertEqual(response.status_code, 200) content = str(response.content, 'utf-8') does_not_show_previous = ( self.previous_act.b_title not in content and self.previous_class.b_title not in content and "%s - %s" % ( self.previous_vendor.business.name, self.previous_conf.conference_slug) not in content and self.previous_costume.b_title not in content) shows_all_current = ( self.current_act.b_title in content and self.current_class.b_title in content and "%s - %s" % ( self.current_vendor.business.name, self.current_conf.conference_slug) in content and self.current_costume.b_title in content) assert does_not_show_previous assert shows_all_current self.assert_event_is_present(response, self.current_sched) self.assert_event_is_not_present(response, self.previous_sched) self.assert_event_is_present(response, self.current_class_sched) self.assert_event_is_not_present(response, self.previous_class_sched) self.assertNotContains(response, "text-danger") self.assertContains(response, reverse( "volunteer_signup", urlconf="gbe.scheduling.urls")) def test_historical_view(self): url = reverse('home', urlconf='gbe.urls') login_as(self.profile, self) response = self.client.get( url, data={'historical': 1}) content = str(response.content, 'utf-8') self.assertEqual(response.status_code, 200) shows_all_previous = ( self.previous_act.b_title in content and self.previous_class.b_title in content and "%s - %s" % ( self.previous_vendor.business.name, self.previous_conf.conference_slug) in content and self.previous_costume.b_title in content in content) does_not_show_current = ( self.current_act.b_title not in content and self.current_class.b_title not in content and "%s - %s" % ( self.current_vendor.business.name, self.current_conf.conference_slug) not in content and self.current_costume.b_title not in content) assert shows_all_previous assert does_not_show_current self.assert_event_is_present(response, self.previous_sched) self.assert_event_is_not_present(response, self.current_sched) self.assert_event_is_present(response, self.previous_class_sched) self.assert_event_is_not_present(response, self.current_class_sched) self.assertNotContains(response, reverse( "volunteer_signup", urlconf="gbe.scheduling.urls")) def test_as_privileged_user(self): staff_profile = ProfileFactory() grant_privilege(staff_profile, "Ticketing - Admin") login_as(staff_profile, self) url = reverse('admin_landing_page', urlconf='gbe.urls', args=[staff_profile.pk]) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains(response, "You are viewing a") def test_acts_to_review(self): staff_profile = ProfileFactory(user_object__is_staff=True) grant_privilege(staff_profile, "Act Reviewers") login_as(staff_profile, self) act = ActFactory(submitted=True, b_conference=self.current_conf) url = reverse('home', urlconf='gbe.urls') response = self.client.get(url) self.assertContains(response, act.b_title) def test_act_was_reviewed(self): staff_profile = ProfileFactory(user_object__is_staff=True) grant_privilege(staff_profile, "Act Reviewers") login_as(staff_profile, self) reviewed_act = ActFactory(submitted=True, b_conference=self.current_conf) FlexibleEvaluationFactory(bid=reviewed_act, evaluator=staff_profile) url = reverse('home', urlconf='gbe.urls') response = self.client.get(url) self.assertNotContains(response, reviewed_act.b_title) def test_classes_to_review(self): staff_profile = ProfileFactory(user_object__is_staff=True) grant_privilege(staff_profile, "Class Reviewers") login_as(staff_profile, self) klass = ClassFactory(submitted=True, b_conference=self.current_conf, e_conference=self.current_conf) url = reverse('home', urlconf='gbe.urls') response = self.client.get(url) self.assertContains(response, klass.b_title) def test_vendors_to_review(self): staff_profile = ProfileFactory(user_object__is_staff=True) grant_privilege(staff_profile, "Vendor Reviewers") login_as(staff_profile, self) vendor = VendorFactory(submitted=True, b_conference=self.current_conf) url = reverse('home', urlconf='gbe.urls') response = self.client.get(url) self.assertContains(response, vendor.business.name) def test_costumes_to_review(self): staff_profile = ProfileFactory(user_object__is_staff=True) grant_privilege(staff_profile, "Costume Reviewers") login_as(staff_profile, self) costume = CostumeFactory(submitted=True, b_conference=self.current_conf) url = reverse('home', urlconf='gbe.urls') response = self.client.get(url) self.assertContains(response, costume.b_title) def test_profile_image(self): set_image(self.performer) response = self.get_landing_page() self.assertContains(response, self.performer.name) self.assertContains(response, self.performer.label) self.assertContains(response, self.performer.img.url) def test_cannot_edit_troupe_if_not_contact(self): troupe = TroupeFactory() member = PersonaFactory() troupe.membership.add(member) url = reverse("home", urlconf="gbe.urls") login_as(member.performer_profile, self) response = self.client.get(url) self.assertContains(response, "(Click to edit)", 1) def test_review_act_w_troupe(self): # causes a check on act complete state that is different from soloist troupe = TroupeFactory() member = PersonaFactory() troupe.membership.add(member) act = ActFactory(performer=troupe, submitted=True, b_conference=self.current_conf) login_as(member.performer_profile, self) url = reverse("home", urlconf="gbe.urls") response = self.client.get(url) self.assertContains(response, act.b_title) def test_act_tech_troupe_member_view(self): troupe = TroupeFactory() member = PersonaFactory() troupe.membership.add(member) act = ActFactory(performer=troupe, submitted=True, b_conference=self.current_conf, accepted=3) current_act_context = ActTechInfoContext( performer=troupe, act=act, conference=self.current_conf, schedule_rehearsal=True) act.tech = TechInfoFactory( track_artist="", track=SimpleUploadedFile("file.mp3", b"file_content"), prop_setup="text", starting_position="Onstage", primary_color="text", feel_of_act="text", pronouns="text", introduction_text="text") act.tech.save() event_id = make_act_app_ticket(self.current_conf) login_as(member.performer_profile, self) url = reverse("home", urlconf="gbe.urls") response = self.client.get(url) self.assertContains( response, reverse("act_techinfo_detail", urlconf="gbe.reporting.urls", args=[act.pk])) def test_two_acts_one_show(self): '''Basic test of landing_page view ''' url = reverse('home', urlconf='gbe.urls') login_as(self.profile, self) # Bid types previous and current current_act_context = ActTechInfoContext( performer=self.performer, act=self.current_act, conference=self.current_conf) second_act_context = ActTechInfoContext( performer=self.performer, conference=self.current_conf, show=current_act_context.show, sched_event=current_act_context.sched_event) self.current_act.accepted = 3 self.current_act.save() response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains(response, second_act_context.act.b_title, count=3) self.assertContains(response, current_act_context.act.b_title, count=3) self.assertContains(response, second_act_context.show.e_title, count=2) def test_interest(self): '''Basic test of landing_page view ''' context = ClassContext( conference=self.current_conf) context.set_interest(self.profile) response = self.get_landing_page() 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, self.url)) def test_teacher_interest(self): '''Basic test of landing_page view ''' context = ClassContext( conference=self.current_conf, teacher=PersonaFactory(performer_profile=self.profile)) interested = [] for i in range(0, 3): interested += [context.set_interest()] response = self.get_landing_page() for person in interested: self.assertContains( response, "%s <%s>;" % (person.display_name, person.user_object.email)) self.assertContains(response, interested_explain_msg) def test_historical_no_interest(self): context = ClassContext( conference=self.previous_conf, teacher=PersonaFactory(performer_profile=self.profile)) interested = [] for i in range(0, 3): interested += [context.set_interest()] url = reverse('home', urlconf='gbe.urls') login_as(self.profile, self) response = self.client.get( url, data={'historical': 1}) for person in interested: self.assertNotContains( response, "%s <%s>;<br>" % (person.display_name, person.user_object.email)) self.assertNotContains(response, interested_explain_msg) def test_eval_ready(self): '''Basic test of landing_page view ''' context = ClassContext( conference=self.current_conf, starttime=datetime.now()-timedelta(days=1)) context.set_interest(self.profile) context.setup_eval() response = self.get_landing_page() eval_link = reverse( "eval_event", args=[context.sched_event.pk, ], urlconf="gbe.scheduling.urls") self.assertContains(response, "%s?next=%s" % ( eval_link, self.url)) def test_eval_answered(self): '''Basic test of landing_page view ''' context = ClassContext( conference=self.current_conf, starttime=datetime.now()-timedelta(days=1)) context.set_interest(self.profile) context.set_eval_answerer(self.profile) response = self.get_landing_page() eval_link = reverse( "eval_event", args=[context.sched_event.pk, ], urlconf="gbe.scheduling.urls") self.assertNotContains(response, "%s?next=%s" % ( eval_link, self.url)) self.assertContains(response, "You have already rated this class") def test_unpaid_act_draft(self): self.unpaid_act = ActFactory(performer=self.performer, submitted=False, b_conference=self.current_conf) expected_string = ( '<b>%s</b></span> - Not submitted' ) % self.unpaid_act.b_title event_id = make_act_app_ticket(self.current_conf) response = self.get_landing_page() self.assertContains(response, expected_string) def test_paid_act_draft(self): make_act_app_purchase(self.current_conf, self.profile.user_object) make_act_app_purchase(self.current_conf, self.profile.user_object) self.paid_act = ActFactory(performer=self.performer, submitted=False, b_conference=self.current_conf) event_id = make_act_app_ticket(self.current_conf) response = self.get_landing_page() self.assertContains(response, "Fee has been paid, submit NOW!") def test_unpaid_vendor_draft(self): self.unpaid_vendor = VendorFactory( business__owners=[self.profile], submitted=False, b_conference=self.current_conf) expected_string = ( '<i class="fas fa-arrow-alt-circle-right"></i> <b>%s - %s</b>' ) % (self.unpaid_vendor.business.name, self.current_conf.conference_slug) event_id = make_vendor_app_ticket(self.current_conf) response = self.get_landing_page() self.assertContains(response, expected_string) def test_paid_vendor_draft(self): make_vendor_app_purchase(self.current_conf, self.profile.user_object) make_vendor_app_purchase(self.current_conf, self.profile.user_object) self.paid_vendor = VendorFactory( business__owners=[self.profile], submitted=False, b_conference=self.current_conf) expected_string = ( '<i class="fas fa-arrow-alt-circle-right"></i> <b>%s - %s</b>' ) % (self.paid_vendor.business.name, self.current_conf.conference_slug) event_id = make_vendor_app_ticket(self.current_conf) response = self.get_landing_page() self.assertContains(response, expected_string) self.assertNotContains(response, "%d/%s" % ( self.profile.user_object.id, event_id)) self.assertContains(response, "Fee has been paid, submit NOW!") def test_act_tech_alert(self): current_act_context = ActTechInfoContext( performer=self.performer, act=self.current_act, conference=self.current_conf, schedule_rehearsal=True) self.current_act.tech.track_artist = "" self.current_act.tech.save() self.current_act.accepted = 3 self.current_act.save() event_id = make_act_app_ticket(self.current_conf) response = self.get_landing_page() self.assertContains( response, SCHEDULE_REHEARSAL % ( self.current_act.b_title, reverse('act_tech_wizard', urlconf='gbe.urls', args=[self.current_act.id]))) def test_stage_manager_button(self): self.context = ActTechInfoContext(schedule_rehearsal=True) self.profile = self.context.make_priv_role() response = self.get_landing_page() self.assertContains(response, reverse( 'show_dashboard', urlconf='gbe.scheduling.urls', args=[self.context.sched_event.pk])) def test_staff_lead_button(self): show_context = ActTechInfoContext(schedule_rehearsal=True) vol_context = VolunteerContext(event=show_context.show, sched_event=show_context.sched_event) context = StaffAreaContext(conference=show_context.conference) EventLabelFactory(event=vol_context.opp_event, text=context.area.slug) vol1, opp1 = context.book_volunteer( volunteer_sched_event=vol_context.opp_event, volunteer=context.staff_lead) self.profile = context.staff_lead response = self.get_landing_page() self.assertContains(response, reverse( 'show_dashboard', urlconf='gbe.scheduling.urls', args=[show_context.sched_event.pk])) def test_no_act_tech_alert(self): current_act_context = ActTechInfoContext( performer=self.performer, act=self.current_act, conference=self.current_conf, schedule_rehearsal=True) self.current_act.tech = TechInfoFactory( track_artist="", track=SimpleUploadedFile("file.mp3", b"file_content"), prop_setup="text", starting_position="Onstage", primary_color="text", feel_of_act="text", pronouns="text", introduction_text="text") self.current_act.accepted = 3 self.current_act.save() event_id = make_act_app_ticket(self.current_conf) response = self.get_landing_page() self.assertNotContains( response, SCHEDULE_REHEARSAL % ( self.current_act.b_title, reverse('act_tech_wizard', urlconf='gbe.urls', args=[self.current_act.id])))
class TestShowDashboard(TestCase): '''Tests for index view''' view_name = 'show_dashboard' def setUp(self): self.client = Client() self.context = ActTechInfoContext(schedule_rehearsal=True) self.other_context = ActTechInfoContext( conference=self.context.conference) self.profile = self.context.make_priv_role() self.url = reverse(self.view_name, urlconf='gbe.scheduling.urls', args=[self.context.sched_event.pk]) def get_basic_post(self, order_value=1): data = {"%d-order" % self.context.booking.pk: order_value} return data def test_no_permission(self): profile = ProfileFactory() login_as(profile, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 403) def test_good_user_get_bad_show(self): login_as(self.profile, self) bad_url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[self.other_context.sched_event.pk + 100]) response = self.client.get(bad_url, follow=True) self.assertContains( response, "OCCURRENCE_NOT_FOUND Occurrence id %d not found" % (self.other_context.sched_event.pk + 100)) def test_not_this_show(self): '''Stage Managers get to update act tech, volunteers, and act order ''' login_as(self.profile, self) response = self.client.get(self.url) self.url = reverse(self.view_name, urlconf='gbe.scheduling.urls', args=[self.other_context.sched_event.pk]) response = self.client.get(self.url, follow=True) self.assertContains(response, no_scope_error) self.assertRedirects(response, reverse('home', urlconf='gbe.urls')) def test_has_datatable(self): '''Stage Managers get to update act tech, volunteers, and act order ''' login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, "var table = $('#gbe-table').DataTable({", msg_prefix="Can't find script for table") self.assertContains(response, '<table id="gbe-table"', msg_prefix="Can't find table header") self.assertContains(response, self.context.act.b_title) self.assertContains(response, self.url) self.assertNotContains( response, reverse(self.view_name, urlconf='gbe.scheduling.urls', args=[self.other_context.sched_event.pk])) self.assertContains( response, reverse("act_tech_wizard", urlconf='gbe.urls', args=[self.context.act.id])) self.assertContains( response, date_format(self.context.rehearsal.start_time, "DATETIME_FORMAT")) self.assertContains( response, ('<input type="number" name="%d-order" value="%d" ' + 'style="width: 3.5em" required id="id_%d-order">') % (self.context.booking.pk, self.context.order.order, self.context.booking.pk), html=True) def test_no_techinfo_edit_no_order_change(self): '''Act Coordinator can't edit act tech, or the order This should be an act w/out tech info. ''' self.context.order_act(self.context.act, "3") self.profile = ProfileFactory() grant_privilege(self.profile, 'Act Coordinator') login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, self.context.act.b_title) self.assertContains(response, 'class="gbe-table-row gbe-table-danger"', 1) self.assertContains( response, '<i class="fas fa-window-close gbe-text-danger"></i>') self.assertNotContains( response, reverse("act_tech_wizard", urlconf='gbe.urls', args=[self.context.act.id])) self.assertContains(response, "<td data-order=\'3\'>\n 3\n </td>") def test_show_inactive(self): ''' show red when user is deactivated ''' self.context.act.performer.contact.user_object.is_active = False self.context.act.performer.contact.user_object.save() login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, "- INACTIVE", msg_prefix="Can't find inactive user") def test_has_video(self): ''' view a video link if act has it. ''' video_act = self.context.act video_act.video_link = "http://www.test.com" video_act.video_choice = 2 video_act.save() login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, video_act.video_link) def test_rebook_perm(self): ''' Producers can book act into a different show ''' self.profile = self.context.make_priv_role('Producer') login_as(self.profile, self) response = self.client.get(self.url) self.assertContains( response, reverse("act_changestate", urlconf="gbe.urls", args=[self.context.act.id])) def test_cross_show(self): ''' Scheduling Mavens can see all the shows in the conference ''' self.profile = ProfileFactory() grant_privilege(self.profile, 'Scheduling Mavens') login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, self.context.act.b_title) self.assertNotContains( response, reverse("act_tech_wizard", urlconf='gbe.urls', args=[self.context.act.id])) self.assertContains( response, reverse(self.view_name, urlconf='gbe.scheduling.urls', args=[self.other_context.sched_event.pk])) 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_show_volunteer(self): '''staff_area view should load ''' vol_context = VolunteerContext(event=self.context.show, sched_event=self.context.sched_event) self.profile = ProfileFactory() grant_privilege(self.profile, 'Scheduling Mavens') login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, vol_context.opportunity.e_title) self.assertContains( response, reverse('mail_to_individual', urlconf='gbe.email.urls', args=[vol_context.profile.resourceitem_id])) self.assertContains( response, reverse('detail_view', urlconf='gbe.scheduling.urls', args=[vol_context.opp_event.eventitem_id])) def test_show_with_inactive(self): ''' view should load ''' inactive = ProfileFactory(display_name="Inactive User", user_object__is_active=False) context = VolunteerContext(event=self.context.show, sched_event=self.context.sched_event, profile=inactive) login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, context.opportunity.e_title) self.assertContains(response, '<div class="gbe-form-error">') self.assertContains(response, inactive.display_name) def test_complete_wout_rehearsals_act(self): ''' view should load ''' complete_act_context = ActTechInfoContext() complete_act_context.act.tech = TechInfoFactory( confirm_no_music=True, confirm_no_rehearsal=True, prop_setup="text", starting_position="Onstage", primary_color="text", feel_of_act="text", pronouns="text", introduction_text="text") complete_act_context.act.accepted = 3 complete_act_context.act.save() self.profile = complete_act_context.make_priv_role() login_as(self.profile, self) response = self.client.get( reverse(self.view_name, urlconf='gbe.scheduling.urls', args=[complete_act_context.sched_event.pk])) self.assertContains(response, complete_act_context.act.b_title) self.assertNotContains(response, 'class="gbe-table-row gbe-table-danger"') self.assertContains(response, "No audio track needed") self.assertContains(response, "Acknowledged No Rehearsal") self.assertContains( response, '<i class="fas fa-check-circle gbe-text-success"></i>') def test_show_approval_needed_event(self): context = VolunteerContext(event=self.context.show, sched_event=self.context.sched_event) context.opp_event.approval_needed = True context.opp_event.save() login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, context.opportunity.e_title) self.assertContains(response, 'class="approval_needed"') def test_staff_area_role_display(self): vol_context = VolunteerContext(event=self.context.show, sched_event=self.context.sched_event) context = StaffAreaContext(conference=self.context.conference) EventLabelFactory(event=vol_context.opp_event, text=context.area.slug) vol1, opp1 = context.book_volunteer( volunteer_sched_event=vol_context.opp_event) vol2, opp2 = context.book_volunteer( volunteer_sched_event=vol_context.opp_event, role="Pending Volunteer") vol3, opp3 = context.book_volunteer( volunteer_sched_event=vol_context.opp_event, role="Waitlisted") vol4, opp4 = context.book_volunteer( volunteer_sched_event=vol_context.opp_event, role="Rejected") login_as(self.profile, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertContains(response, str(vol1)) self.assertContains(response, str(vol2)) self.assertContains(response, str(vol3)) self.assertNotContains(response, str(vol4)) self.assertNotContains( response, reverse("approve_volunteer", urlconf='gbe.scheduling.urls', args=['approve', vol1.pk, opp1.pk])) self.assertContains( response, reverse("approve_volunteer", urlconf='gbe.scheduling.urls', args=['approve', vol2.pk, opp2.pk])) self.assertContains( response, reverse("approve_volunteer", urlconf='gbe.scheduling.urls', args=['approve', vol3.pk, opp3.pk])) self.assertContains(response, context.area.title) def test_post_success(self): login_as(self.profile, self) response = self.client.post(self.url, data=self.get_basic_post(), follow=True) self.assertContains(response, act_order_submit_success) self.assertContains(response, "%s Dashboard" % self.context.show.e_title) def test_post_invalid(self): login_as(self.profile, self) response = self.client.post(self.url, data=self.get_basic_post(-1), follow=True) self.assertContains(response, act_order_form_invalid) self.assertContains(response, "%s Dashboard" % self.context.show.e_title) def test_good_user_post_bad_show(self): login_as(self.profile, self) bad_url = reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[self.other_context.sched_event.pk + 100]) response = self.client.post(bad_url, data=self.get_basic_post(), follow=True) self.assertContains( response, "OCCURRENCE_NOT_FOUND Occurrence id %d not found" % (self.other_context.sched_event.pk + 100))