def __init__(self, performer=None, act=None, show=None, sched_event=None, conference=None, room_name=None, schedule_rehearsal=False, act_role="Regular Act", set_waitlist=False): if conference: self.show = show or ShowFactory(e_conference=conference) else: self.show = show or ShowFactory() self.conference = conference or self.show.e_conference self.performer = performer or PersonaFactory() self.act = act or ActFactory(performer=self.performer, b_conference=self.conference, accepted=3, submitted=True) role = "Performer" if set_waitlist: self.act.accepted = 2 self.act.save() act_role = "Waitlisted" role = "Waitlisted" self.tech = self.act.tech # schedule the show if sched_event: self.sched_event = sched_event else: self.sched_event = SchedEventFactory( eventitem=self.show.eventitem_ptr) EventLabelFactory(event=self.sched_event, text=self.conference.conference_slug) room_name = room_name or "Dining Room" self.room = RoomFactory(name=room_name) self.room.conferences.add(self.conference) if not sched_event: ResourceAllocationFactory( event=self.sched_event, resource=LocationFactory(_item=self.room.locationitem_ptr)) # schedule the act into the show self.booking = ResourceAllocationFactory(event=self.sched_event, resource=WorkerFactory( _item=self.act.performer, role=role)) self.order = OrderingFactory(allocation=self.booking, class_id=self.act.pk, class_name="Act", role=act_role) if schedule_rehearsal: self.rehearsal = self._schedule_rehearsal(self.sched_event, self.act)
def test_get_tickets_for_show(self): '''just gets 1 ticket for Whole Shebang ''' event = ShowFactory() ticketing_event = TicketingEventsFactory( conference=event.e_conference, include_most=True, title="The Whole Shebang 2016") TicketItemFactory(ticketing_event=ticketing_event, live=True, has_coupon=False) tickets = event.get_tickets() self.assertEqual(len(tickets), 1) self.assertEqual(tickets[0].title, "The Whole Shebang 2016")
def test_view_list_default_view_current_conf_exists(self): ''' /scheduler/view_list/ should return all events in the current conference, assuming a current conference exists ''' other_conf = ConferenceFactory(status='completed') show = ShowFactory(e_conference=self.conf) generic_event = GenericEventFactory(e_conference=self.conf) accepted_class = ClassFactory(accepted=3, e_conference=self.conf, b_conference=self.conf) previous_class = ClassFactory(accepted=3, e_conference=other_conf, b_conference=other_conf) rejected_class = ClassFactory(accepted=1, e_conference=self.conf, b_conference=self.conf) url = reverse("event_list", urlconf="gbe.scheduling.urls") login_as(ProfileFactory(), self) response = self.client.get(url) self.assertContains(response, generic_event.e_title) self.assertContains(response, show.e_title) self.assertContains(response, accepted_class.e_title) self.assertNotContains(response, rejected_class.e_title) self.assertNotContains(response, previous_class.e_title)
def test_view_list_only_classes(self): ''' /scheduler/view_list/ should return all events in the current conference, assuming a current conference exists ''' show = ShowFactory(e_conference=self.conf) generic_event = GenericEventFactory(e_conference=self.conf) accepted_class = ClassFactory(accepted=3, e_conference=self.conf, b_conference=self.conf) url = reverse("event_list", urlconf="gbe.scheduling.urls", args=['Class']) login_as(ProfileFactory(), self) response = self.client.get(url) self.assertNotContains(response, show.e_title) self.assertNotContains(response, generic_event.e_title) self.assertContains(response, accepted_class.e_title) url = reverse("event_list", urlconf="gbe.scheduling.urls", args=['class']) response = self.client.get(url) self.assertNotContains(response, show.e_title) self.assertNotContains(response, generic_event.e_title) self.assertContains(response, accepted_class.e_title)
def __init__(self, act=None, performer=None, conference=None, room=None, starttime=None, act_role=''): self.performer = performer or PersonaFactory() self.conference = conference or ConferenceFactory() if not self.conference.conferenceday_set.exists(): day = ConferenceDayFactory(conference=self.conference) if starttime: day.day = starttime.date() day.save() self.days = self.conference.conferenceday_set.all() act = act or ActFactory(b_conference=self.conference, performer=self.performer, accepted=3, submitted=True) self.acts = [act] self.show = ShowFactory(e_conference=self.conference) self.room = room or RoomFactory() self.sched_event = None self.sched_event = self.schedule_instance(room=self.room, starttime=starttime) self.book_act(act, act_role)
def test_good_user_get_success_not_scheduled(self): show = ShowFactory() login_as(self.privileged_profile, self) response = self.client.get(self.url) self.assertEqual(response.status_code, 200) self.assertNotIn('<ul class="errorlist">', response.content) self.assertIn('Performer', response.content)
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_get_tickets_for_show(self): '''just gets 1 ticket for Whole Shebang ''' event = ShowFactory() bpt_event = BrownPaperEventsFactory( conference=event.e_conference, include_most=True, title="The Whole Shebang 2016") TicketItemFactory(bpt_event=bpt_event, live=True, has_coupon=False) tickets = event.get_tickets() self.assertEqual(len(tickets), 1) self.assertEqual( tickets[0].title, "The Whole Shebang 2016")
def setUp(self): self.client = Client() self.context = ActTechInfoContext() self.show = ShowFactory() self.sched_event = SchedEventFactory(eventitem=self.show.eventitem_ptr) self.privileged_user = ProfileFactory().user_object grant_privilege(self.privileged_user, 'Act Coordinator') grant_privilege(self.privileged_user, 'Act Reviewers') self.data = {'show': self.show.pk, 'casting': '', 'accepted': '2'}
def test_booked_performer(self): ''' has the role of performer from being booked in a show ''' act = ActFactory(accepted=3) show = ShowFactory() booking = book_act_item_for_show(act, show) profile = act.performer.performer_profile result = profile.has_role_in_event("Performer", show) nt.assert_true(result)
def test_show_approval_needed_event(self): show = ShowFactory() context = VolunteerContext(event=show) context.opp_event.approval_needed = True context.opp_event.save() grant_privilege(self.profile, 'Act Reviewers') 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_booked_performer(self): ''' has the role of performer from being booked in a show ''' act = ActFactory(b_conference=self.conference, accepted=3) show = ShowFactory(e_conference=self.conference) booking = book_act_item_for_show(act, show) profile = act.performer.performer_profile result = profile.get_roles(self.conference) nt.assert_equal(result, ["Performer"])
def test_staff_area_path_fail(self): '''staff_area view should fail for non-authenticated users ''' show = ShowFactory() login_as(self.profile, self) response = self.client.get("%s?area=Show" % reverse('staff_area', urlconf="gbe.reporting.urls", args=[show.eventitem_id])) self.assertEqual(response.status_code, 403)
def test_ticket_linked_event(self): active_ticket = TicketItemFactory(live=True) gbe_event = ShowFactory( e_conference=active_ticket.ticketing_event.conference) active_ticket.ticketing_event.linked_events.add(gbe_event) active_ticket.ticketing_event.save() url = reverse(self.view_name, urlconf='ticketing.urls') login_as(self.privileged_user, self) response = self.client.get(url) self.assertEqual(response.status_code, 200)
def test_show_bad_event(self): '''staff_area view should fail for non-authenticated users ''' show = ShowFactory() grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get("%s?area=Show" % reverse('staff_area', urlconf="gbe.reporting.urls", args=[show.eventitem_id + 100])) self.assertContains(response, "Staff Schedules for None")
def setUp(self): self.client = Client() self.ticketing_event = TicketingEventsFactory() self.gbe_event = ShowFactory() self.privileged_user = ProfileFactory().user_object grant_privilege(self.privileged_user, 'Ticketing - Admin') self.url = reverse('set_ticket_to_event', urlconf='ticketing.urls', args=[self.ticketing_event.event_id, "on", self.gbe_event.eventitem_id])
def test_staff_area_path(self): '''staff_area view should load ''' show = ShowFactory() context = VolunteerContext(event=show) grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get("%s?area=Show" % reverse('staff_area', urlconf="gbe.reporting.urls", args=[show.eventitem_id])) self.assertEqual(response.status_code, 200)
def test_volunteer_type_path_fail(self): '''staff_area view should fail for non-authenticated users ''' show = ShowFactory() context = VolunteerContext(event=show) login_as(self.profile, self) response = self.client.get( reverse('volunteer_type', urlconf="gbe.reporting.urls", args=[context.opportunity.e_conference.conference_slug, context.interest.interest.pk])) self.assertEqual(response.status_code, 403)
def __init__(self, profile=None, bid=None, event=None, opportunity=None, role=None): if not event: self.window = VolunteerWindowFactory() self.conference = self.window.day.conference else: self.conference = event.e_conference if not VolunteerWindow.objects.filter( day__conference=self.conference).exists(): self.window = VolunteerWindowFactory( day__conference=self.conference) else: self.window = VolunteerWindow.objects.all().first() self.conf_day = self.window.day self.profile = profile or ProfileFactory() if not hasattr(self.profile, 'preferences'): ProfilePreferencesFactory(profile=self.profile) if bid is False: self.bid = None elif bid: self.bid = bid self.profile = self.bid.profile else: self.bid = VolunteerFactory( b_conference=self.conference, profile=self.profile) self.interest = VolunteerInterestFactory( volunteer=self.bid) self.event = event or ShowFactory( e_conference=self.conference) self.role = role or "Volunteer" self.room = RoomFactory() self.sched_event = SchedEventFactory( eventitem=self.event.eventitem_ptr, starttime=datetime.combine(self.window.day.day, self.window.start)) ResourceAllocationFactory( event=self.sched_event, resource=LocationFactory(_item=self.room)) EventLabelFactory(event=self.sched_event, text="General") EventLabelFactory(event=self.sched_event, text=self.conference.conference_slug) self.worker = WorkerFactory(_item=self.profile.workeritem, role=self.role) self.opportunity, self.opp_event = self.add_opportunity(opportunity) self.allocation = ResourceAllocationFactory(resource=self.worker, event=self.opp_event)
def test_volunteer_type_path(self): '''staff_area view should load ''' show = ShowFactory() context = VolunteerContext(event=show) grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get( reverse('volunteer_type', urlconf="gbe.reporting.urls", args=[context.opportunity.e_conference.conference_slug, context.interest.interest.pk])) self.assertEqual(response.status_code, 200)
def test_show_with_inactive(self): ''' view should load ''' show = ShowFactory() inactive = ProfileFactory(display_name="Inactive User", user_object__is_active=False) context = VolunteerContext(event=show, profile=inactive) grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get(self.url) self.assertContains(response, show.e_title) self.assertContains(response, context.opportunity.e_title) self.assertContains(response, '<div class="gbe-form-error">') self.assertContains(response, inactive.display_name)
def _create_scheduled_show_with_acts(conference=None, qty=6): if not conference: conference = ConferenceFactory() conf_day = ConferenceDayFactory(conference=conference) show = ShowFactory(e_conference=conference) sEvent = SchedEventFactory(eventitem=show.eventitem_ptr, starttime=utc.localize( datetime.combine(conf_day.day, time(20, 0)))) acts = [ActFactory(accepted=3) for i in range(qty)] for act in acts: ar = ActResourceFactory(_item=act.actitem_ptr) ResourceAllocationFactory(event=sEvent, resource=ar) return show, sEvent, acts
def test_show_with_inactive(self): '''staff_area view should load ''' show = ShowFactory() inactive = ProfileFactory(display_name="DON'T SEE THIS", user_object__is_active=False) context = VolunteerContext(event=show, profile=inactive) grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get("%s?area=Show" % reverse('staff_area', urlconf="gbe.reporting.urls", args=[show.eventitem_id])) self.assertEqual(response.status_code, 200) self.assertTrue('<tr style="color:red;">' in response.content)
def test_review_act_update_notes(self): notes = ActBidEvaluationFactory() show = ShowFactory() login_as(self.privileged_user, self) url = reverse('act_review', urlconf='gbe.urls', args=[notes.bid.pk]) data = self.get_post_data(notes.bid, reviewer=self.privileged_profile, show=show) response = self.client.post(url, data, follow=True) self.assertEqual(response.status_code, 200) new_notes = ActBidEvaluation.objects.filter( evaluator=self.privileged_profile, bid=notes.bid) self.assertTrue(len(new_notes), 1) self.assertTrue(new_notes[0].notes, "some notes") expected_string = default_act_review_success_msg % ( notes.bid.b_title, str(notes.bid.performer)) self.assertContains(response, expected_string)
def test_repeated_lead_shows_once(self): show = ShowFactory() sched_events = [ SchedEventFactory.create(eventitem=show.eventitem_ptr) for i in range(2) ] staff_lead = ProfileFactory() lead_worker = WorkerFactory(_item=staff_lead.workeritem_ptr, role="Staff Lead") for se in sched_events: ResourceAllocationFactory.create(event=se, resource=lead_worker) response = self.client.get( reverse(self.view_name, urlconf="gbe.scheduling.urls", args=[show.eventitem_id])) self.assertEqual(200, response.status_code) self.assertEqual(1, response.content.count(staff_lead.display_name))
def test_review_act_update_review(self): eval = FlexibleEvaluationFactory(evaluator=self.privileged_profile, category=self.eval_cat) show = ShowFactory() login_as(self.privileged_user, self) url = reverse('act_review', urlconf='gbe.urls', args=[eval.bid.pk]) data = self.get_post_data(eval.bid, reviewer=self.privileged_profile, show=show) response = self.client.post(url, data, follow=True) self.assertEqual(response.status_code, 200) evals = FlexibleEvaluation.objects.filter( evaluator=self.privileged_profile, bid=eval.bid) self.assertTrue(len(evals), 1) self.assertTrue(evals[0].ranking, 4) expected_string = default_act_review_success_msg % ( eval.bid.b_title, str(eval.bid.performer)) self.assertContains(response, expected_string)
def test_overcommitment_addict(self): ''' 1 of every permutation possible to link people to roles ''' persona = PersonaFactory() this_class = GenericEventFactory(e_conference=self.conference) book_worker_item_for_role(persona, "Teacher", this_class) event = GenericEventFactory(e_conference=self.conference) book_worker_item_for_role(persona.performer_profile, "Staff Lead", event) act = ActFactory(b_conference=self.conference, accepted=3, performer=persona) show = ShowFactory(e_conference=self.conference) booking = book_act_item_for_show(act, show) result = persona.performer_profile.get_roles(self.conference) nt.assert_equal(sorted(result), ["Performer", "Staff Lead", "Teacher"])
def test_volunteer_type_with_inactive(self): '''staff_area view should load ''' show = ShowFactory() inactive = ProfileFactory( display_name="DON'T SEE THIS", user_object__is_active=False ) context = VolunteerContext(event=show, profile=inactive) grant_privilege(self.profile, 'Act Reviewers') login_as(self.profile, self) response = self.client.get( reverse('volunteer_type', urlconf="gbe.reporting.urls", args=[context.opportunity.e_conference.conference_slug, context.interest.interest.pk])) self.assertEqual(response.status_code, 200) self.assertTrue( '<tr style="color:red;">' in response.content)
def __init__(self, profile=None, event=None, sched_event=None, opportunity=None, role=None, conference=None): if not event: self.conference = conference or ConferenceFactory() else: self.conference = event.e_conference if ConferenceDay.objects.filter(conference=self.conference).exists(): self.conf_day = ConferenceDay.objects.filter( conference=self.conference).first() else: self.conf_day = ConferenceDayFactory(conference=self.conference) self.profile = profile or ProfileFactory() if not hasattr(self.profile, 'preferences'): ProfilePreferencesFactory(profile=self.profile) self.role = role or "Volunteer" self.room = RoomFactory() self.room.conferences.add(self.conference) self.event = event or ShowFactory(e_conference=self.conference) if not sched_event: self.sched_event = SchedEventFactory( eventitem=self.event.eventitem_ptr, starttime=datetime.combine(self.conf_day.day, time(12, 0, 0))) ResourceAllocationFactory( event=self.sched_event, resource=LocationFactory(_item=self.room)) EventLabelFactory(event=self.sched_event, text="General") EventLabelFactory(event=self.sched_event, text=self.conference.conference_slug) else: self.sched_event = sched_event self.worker = WorkerFactory(_item=self.profile.workeritem, role=self.role) self.opportunity, self.opp_event = self.add_opportunity(opportunity) self.allocation = ResourceAllocationFactory(resource=self.worker, event=self.opp_event)
def test_ticket_includes_most(self): active_ticket = TicketItemFactory(live=True, ticketing_event__include_most=True) gbe_event = ShowFactory( e_conference=active_ticket.ticketing_event.conference) url = reverse(self.view_name, urlconf='ticketing.urls') login_as(self.privileged_user, self) response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains(response, "All Conference Classes") self.assertContains(response, gbe_event.e_title) self.assertContains(response, "fas fa-check", 2) self.assertNotContains(response, "set_ticket_to_event") self.assertContains( response, "To change, edit ticket and remove 'Includes Most'") self.assertContains( response, "To change, edit ticket and remove 'Includes Most' or " + "'Includes Conference'") self.assertContains(response, "Includes all events except Master Classes")
def test_edit_act_techinfo_post_two_shows_same_title(self): context = ActTechInfoContext(schedule_rehearsal=True) context.show.cue_sheet = "Alternate" context.show.save() context.rehearsal.max_volunteer = 1 context.rehearsal.save() another_rehearsal = context._schedule_rehearsal(context.sched_event) ShowFactory(e_title=context.show.e_title) url = reverse('act_techinfo_edit', urlconf='gbe.urls', args=[context.act.pk]) login_as(context.performer.contact, self) data = self.get_full_post(another_rehearsal, context.show).copy() data.update(self.get_cues(context.act.tech, 3, False)) response = self.client.post(url, data=data) self.assertRedirects(response, reverse('home', urlconf='gbe.urls')) self.assertEqual(len(context.act.get_scheduled_rehearsals()), 1) self.assertEqual(context.act.get_scheduled_rehearsals()[0], another_rehearsal)