def test_get_tickets_for_volunteer_opp(self): '''should get no tickets, volunteer opportunities are free ''' event = GenericEventFactory() tickets = event.get_tickets() self.assertEqual(tickets, [])
def test_review_volunteer_has_old_commitments(self): ''' when a volunteer is booked in old conference, it should not show''' past_conference = ConferenceFactory(accepting_bids=False, status='completed') past_opportunity = GenericEventFactory( e_conference=past_conference, volunteer_type=AvailableInterestFactory(interest='Security/usher'), type='Volunteer') past_opportunity.save() booked_sched = sEvent( eventitem=past_opportunity, starttime=datetime(2016, 2, 6, 9, 0, 0, 0, pytz.utc), max_volunteer=1) booked_sched.save() worker = Worker(_item=self.volunteer.profile, role='Volunteer') worker.save() volunteer_assignment = ResourceAllocationFactory( event=booked_sched, resource=worker ) login_as(self.privileged_user, self) response = self.client.get( self.url, {'conf_slug': self.volunteer.b_conference.conference_slug}) nt.assert_equal(response.status_code, 200) nt.assert_true('Bid Information' in response.content) nt.assert_false(str(past_opportunity) in response.content, msg="The commitment %s is showing up" % ( str(past_opportunity)))
def test_get_tickets_for_master_class(self): '''get the one ticket that is active for the Master Class ''' event = GenericEventFactory( type='Master') bpt_event = BrownPaperEventsFactory(conference=event.e_conference, title="Master Class 2017") bpt_event.linked_events.add(event) bpt_event.save() TicketItemFactory(bpt_event=bpt_event, live=True, has_coupon=False) tickets = event.get_tickets() self.assertEqual(len(tickets), 1) self.assertEqual( tickets[0].title, "Master Class 2017")
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_get_tickets_for_special_event(self): '''get the one ticket that is active for all except master classes ''' event = GenericEventFactory( type='Special') 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 test_review_volunteer_has_commitments(self): ''' when a volunteer is already booked somewhere, it should show up''' current_opportunity = GenericEventFactory( e_conference=self.volunteer.b_conference, volunteer_type=AvailableInterestFactory(interest='Security/usher'), type='Volunteer') current_opportunity.save() booked_sched = sEvent( eventitem=current_opportunity, starttime=datetime(2016, 2, 6, 9, 0, 0, 0, pytz.utc), max_volunteer=1) booked_sched.save() worker = Worker(_item=self.volunteer.profile, role='Volunteer') worker.save() volunteer_assignment = ResourceAllocationFactory( event=booked_sched, resource=worker ) login_as(self.privileged_user, self) response = self.client.get( self.url, {'conf_slug': self.volunteer.b_conference.conference_slug}) nt.assert_equal(response.status_code, 200) nt.assert_true('Bid Information' in response.content) nt.assert_equal( response.content.count(str(current_opportunity)), 1, msg="The commitment %s is not showing up" % ( str(current_opportunity))) nt.assert_in( date_format(booked_sched.start_time, "DATETIME_FORMAT"), response.content, msg="start time for commitment (%s) didn't show up" % ( date_format(booked_sched.start_time, "DATETIME_FORMAT"))) nt.assert_in( date_format(booked_sched.end_time, "TIME_FORMAT"), response.content, msg="end time for commitment (%s) didn't show up" % ( date_format(booked_sched.end_time, "TIME_FORMAT")))
def test_authorized_user_get_w_child_events_special(self): original_event = GenericEventFactory(type='Special') target_event = GenericEventFactory(type='Special') target_context = VolunteerContext(event=target_event) original_context = VolunteerContext(event=original_event) original_context.add_opportunity() url = reverse( self.view_name, args=[original_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.event.e_title, target_context.sched_event.start_time) assert_option_state( response, target_context.room.pk, target_context.room.name) self.assertContains(response, target_event.e_title)
def setUp(self): self.room = RoomFactory() self.show_volunteer = VolunteerContext() self.current_conference = self.show_volunteer.conference self.special_volunteer = VolunteerContext(event=GenericEventFactory( e_conference=self.current_conference)) self.staff_area = StaffAreaContext(conference=self.current_conference) self.url = reverse(self.view_name, args=[self.current_conference.conference_slug], urlconf='gbe.scheduling.urls') self.factory = RequestFactory() self.client = Client() self.privileged_user = ProfileFactory().user_object grant_privilege(self.privileged_user, 'Scheduling Mavens')
def make_rehearsal(self, room=True): rehearsal = GenericEventFactory(e_conference=self.conference, type='Rehearsal Slot') start_time = datetime.combine(self.days[0].day, (self.sched_event.start_time - timedelta(hours=4)).time()) slot = SchedEventFactory(eventitem=rehearsal.eventitem_ptr, starttime=start_time, max_volunteer=10) if room: ResourceAllocationFactory( event=slot, resource=LocationFactory(_item=self.room)) EventContainerFactory(parent_event=self.sched_event, child_event=slot) EventLabelFactory(event=slot, text=self.conference.conference_slug) return rehearsal, slot
def test_role_exclusion(self): ''' a condition matches this circumstance, but is excluded ''' exclusion = NoEventRoleExclusionFactory(condition=self.role_condition, role="Staff Lead") booking = book_worker_item_for_role( self.teacher.performer_profile, exclusion.role, GenericEventFactory(e_conference=self.conference)) checklist_items = get_checklist_items_for_roles( self.teacher.performer_profile, self.conference, []) nt.assert_equal(len(checklist_items), 0)
def _schedule_rehearsal(self, s_event, act=None): rehearsal = GenericEventFactory(type="Rehearsal Slot", e_conference=self.conference) rehearsal_event = SchedEventFactory( eventitem=rehearsal.eventitem_ptr, max_volunteer=10, starttime=self.sched_event.starttime) event_container = EventContainerFactory(child_event=rehearsal_event, parent_event=s_event) EventLabelFactory(event=rehearsal_event, text=self.conference.conference_slug) if act: ResourceAllocationFactory( resource=ActResourceFactory(_item=act.actitem_ptr), event=rehearsal_event) return rehearsal_event
def test_view_volunteers(self): this_class = ClassFactory.create(accepted=3, e_conference=self.conf, b_conference=self.conf) generic_event = GenericEventFactory(e_conference=self.conf, type="Volunteer") login_as(ProfileFactory(), self) url = reverse("event_list", urlconf="gbe.scheduling.urls", args=["Volunteer"]) response = self.client.get( url, data={"conference": self.conf.conference_slug}) self.assertContains(response, generic_event.e_title) self.assertNotContains(response, this_class.e_title) self.assertNotContains(response, 'fa-star') self.assertNotContains(response, 'fa-star-o')
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.assertFalse(show.e_title in response.content) self.assertTrue(accepted_class.e_title in response.content)
def add_opportunity(self, opportunity=None, start_time=None): opportunity = opportunity or GenericEventFactory( e_conference=self.conference, type='Volunteer') start_time = start_time or datetime.combine(self.conf_day.day, time(12, 0, 0)) opp_event = SchedEventFactory(eventitem=opportunity.eventitem_ptr, starttime=start_time, max_volunteer=2) ResourceAllocationFactory(event=opp_event, resource=LocationFactory(_item=self.room)) EventContainerFactory(parent_event=self.sched_event, child_event=opp_event) EventLabelFactory(event=opp_event, text=self.conference.conference_slug) EventLabelFactory(event=opp_event, text="Volunteer") return opportunity, opp_event
def test_weird_action(self): special_context = VolunteerContext(event=GenericEventFactory()) self.url = reverse( self.view_name, urlconf="gbe.scheduling.urls", args=[special_context.conference.conference_slug, special_context.sched_event.pk]) grant_privilege(self.privileged_user, 'Scheduling Mavens') login_as(self.privileged_profile, self) # number of volunteers is missing, it's required response = self.client.post( self.url, data=self.get_basic_action_data(special_context, 'inflate'), follow=True) self.assertEqual(response.status_code, 200) self.assertNotContains(response, 'Modify Volunteer Opportunity') self.assertContains(response, "This is an unknown action.")
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.opp_event.pk], urlconf='gbe.scheduling.urls') self.client = Client() self.privileged_user = ProfileFactory().user_object grant_privilege(self.privileged_user, 'Scheduling Mavens')
def test_multiple_role_match_happens(self): ''' profile meets 2 role conditions ''' another_role = RoleEligibilityConditionFactory(role="Staff Lead") booking = book_worker_item_for_role( self.teacher.performer_profile, another_role.role, GenericEventFactory(e_conference=self.conference)) checklist_items = get_checklist_items_for_roles( self.teacher.performer_profile, self.conference, []) nt.assert_equal(len(checklist_items), 2) nt.assert_equal(checklist_items['Teacher'], [self.role_condition.checklistitem]) nt.assert_equal(checklist_items["Staff Lead"], [another_role.checklistitem]) another_role.delete()
def test_pick_all_vol_reduced_priv(self): staffcontext = StaffAreaContext() volunteer, booking = staffcontext.book_volunteer() special = GenericEventFactory(e_conference=staffcontext.conference) specialstaffcontext = VolunteerContext(event=special, ) login_as(staffcontext.staff_lead, self) data = { 'email-select-conference': [ staffcontext.conference.pk, ], 'email-select-roles': [ 'Volunteer', ], 'event-select-event_collections': "Volunteer", 'refine': True, } response = self.client.post(self.url, data=data, follow=True) self.assertNotContains(response, self.context.teacher.contact.user_object.email) self.assertContains(response, volunteer.user_object.email) self.assertContains(response, specialstaffcontext.profile.user_object.email) assert_checkbox(response, "events", 0, special.pk, special.e_title, checked=False, prefix="event-select") assert_checkbox(response, "staff_areas", 0, staffcontext.area.pk, staffcontext.area.title, checked=False, prefix="event-select") assert_checkbox(response, "event_collections", 0, "Volunteer", "All Volunteer Events", prefix="event-select")
def add_volunteer_opp(self): if not self.conference.conferenceday_set.exists(): self.conf_day = ConferenceDayFactory(conference=self.conference) else: self.conf_day = self.conference.conferenceday_set.first() vol_event = GenericEventFactory(e_conference=self.conference, type="Volunteer") volunteer_sched_event = SchedEventFactory( eventitem=vol_event, max_volunteer=self.area.default_volunteers, starttime=noon(self.conf_day)) room = self.get_room() ResourceAllocationFactory(event=volunteer_sched_event, resource=LocationFactory(_item=room)) EventLabelFactory(event=volunteer_sched_event, text=self.area.slug) EventLabelFactory(event=volunteer_sched_event, text=self.conference.conference_slug) EventLabelFactory(event=volunteer_sched_event, text="Volunteer") return volunteer_sched_event
def _schedule_rehearsal(self, s_event, act=None): rehearsal = GenericEventFactory(type="Rehearsal Slot", e_conference=self.conference) rehearsal_event = SchedEventFactory( eventitem=rehearsal.eventitem_ptr, max_commitments=10, starttime=self.sched_event.starttime) event_container = EventContainerFactory(child_event=rehearsal_event, parent_event=s_event) EventLabelFactory(event=rehearsal_event, text=self.conference.conference_slug) if act: booking = ResourceAllocationFactory(event=rehearsal_event, resource=WorkerFactory( _item=act.performer, role="Performer")) OrderingFactory(allocation=booking, class_id=act.pk, class_name="Act") return rehearsal_event
def test_get_event_subclass(self): obj = GenericEventFactory() response = self.client.get('/admin/gbe/event/') assert "GenericEvent" in response.content
def test_get_event_subclass(self): obj = GenericEventFactory() response = self.client.get('/admin/gbe/event/', follow=True) self.assertContains(response, "GenericEvent")
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) # 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(profile=self.profile, submitted=True, b_conference=self.current_conf) self.previous_vendor = VendorFactory(profile=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) self.current_volunteer = VolunteerFactory( profile=self.profile, submitted=True, b_conference=self.current_conf) self.previous_volunteer = VolunteerFactory( 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, pytz.utc), max_volunteer=10) self.previous_sched = SchedEventFactory(eventitem=previous_opportunity, starttime=datetime( 2015, 2, 25, 12, 30, 0, 0, pytz.utc), max_volunteer=10) self.current_class_sched = SchedEventFactory( eventitem=self.current_class, starttime=datetime(2016, 2, 5, 2, 30, 0, 0, pytz.utc), max_volunteer=10) self.previous_class_sched = SchedEventFactory( eventitem=self.previous_class, starttime=datetime(2015, 2, 25, 2, 30, 0, 0, pytz.utc), 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)