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 setUp(self):
     self.role_condition = RoleEligibilityConditionFactory()
     self.teacher = PersonaFactory()
     booking = book_worker_item_for_role(self.teacher,
                                         self.role_condition.role)
     self.conference = booking.event.eventitem.get_conference()
     self.schedule = get_schedule(
         self.teacher.performer_profile.user_object,
         labels=[self.conference.conference_slug]).schedule_items
    def test_role_match_two_conditions(self):
        '''
            two conditions match this circumstance
        '''

        another_match = RoleEligibilityConditionFactory()

        checklist_items = get_checklist_items_for_roles(self.schedule, [])

        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(
            checklist_items["Teacher"],
            [self.role_condition.checklistitem, another_match.checklistitem])
        another_match.delete()
    def test_role_match_two_conditions(self):
        '''
            two conditions match this circumstance
        '''

        another_match = RoleEligibilityConditionFactory()

        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile,
            self.conference,
            [])

        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(checklist_items["Teacher"],
                        [self.role_condition.checklistitem,
                         another_match.checklistitem])
        another_match.delete()
Esempio n. 5
0
 def setUp(self):
     self.client = Client()
     self.privileged_user = ProfileFactory.create().user_object
     grant_privilege(self.privileged_user, 'Ticketing - Admin',
                     'view_checklistitem')
     self.url = reverse(self.view_name, urlconf='ticketing.urls')
     self.role_condition = RoleEligibilityConditionFactory()
     self.ticket_condition = TicketingEligibilityConditionFactory()
     self.ticket_item = TicketItemFactory()
     self.ticket_condition.tickets.add(self.ticket_item)
Esempio n. 6
0
    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()
Esempio n. 7
0
 def test_w_role_condition(self):
     '''loads with the default conference selection.
     '''
     role_condition = RoleEligibilityConditionFactory(
         checklistitem__badge_title="Other Badge Name", role="Teacher")
     login_as(self.privileged_user, self)
     response = self.client.get(self.url)
     self.assertContains(
         response,
         self.class_context.teacher.performer_profile.user_object.username)
     self.assertContains(response, "Role Condition: Teacher")
     self.assertContains(response, "Other Badge Name")
Esempio n. 8
0
    def test_personal_schedule_teacher_booking(self):
        '''a teacher booked into a class, with an active role condition
           should have a booking
        '''
        role_condition = RoleEligibilityConditionFactory()
        context = ClassContext()

        login_as(self.priv_profile, self)
        response = self.client.get(
            self.url, data={"conf_slug": context.conference.conference_slug})
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, str(context.teacher.performer_profile))
        self.assertContains(response, context.bid.e_title)
        self.assertContains(response, str(context.room))
        self.assertContains(response, "dedicated-sched")
Esempio n. 9
0
    def test_personal_schedule_only_active(self):
        '''a teacher booked into a class, with an active role condition
           should have a booking
        '''
        role_condition = RoleEligibilityConditionFactory()
        teacher = PersonaFactory(contact__user_object__is_active=False)
        context = ClassContext(teacher=teacher)

        login_as(self.priv_profile, self)
        response = self.client.get(
            self.url, data={"conf_slug": context.conference.conference_slug})

        self.assertEqual(response.status_code, 200)
        self.assertNotContains(response, str(teacher.performer_profile))
        self.assertNotContains(response, context.bid.e_title)
Esempio n. 10
0
    def test_personal_schedule_teacher_checklist(self):
        '''a teacher booked into a class, with an active role condition
           should get a checklist item
        '''
        role_condition = RoleEligibilityConditionFactory()
        context = ClassContext()

        login_as(self.priv_profile, self)
        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)
        nt.assert_true(str(role_condition.checklistitem) in response.content,
                       msg="Role condition for teacher was not found")
        nt.assert_true(str(context.teacher.performer_profile)
                       in response.content,
                       msg="Teacher is not in the list")
Esempio n. 11
0
 def test_there_can_be_only_one(self):
     ticket_condition = TicketingEligibilityConditionFactory(
         checklistitem__badge_title="Badge Name")
     ticket_condition.tickets.add(
         self.ticket_context.transaction.ticket_item)
     role_condition = RoleEligibilityConditionFactory(
         checklistitem__badge_title="Other Badge Name", role="Teacher")
     login_as(self.privileged_user, self)
     response = self.client.get(self.url)
     self.assertContains(response,
                         self.ticket_context.profile.get_badge_name(), 1)
     self.assertContains(response,
                         self.ticket_context.transaction.ticket_item.title)
     self.assertContains(response, "Badge Name")
     self.assertNotContains(response, "Role Condition: Teacher")
     self.assertNotContains(response, "Other Badge Name")
Esempio n. 12
0
    def test_personal_schedule_interest_booking(self):
        '''a teacher booked into a class, with an active role condition
           should have a booking
        '''
        role_condition = RoleEligibilityConditionFactory()
        context = ClassContext()
        profile = ProfileFactory()
        booking = ResourceAllocationFactory(resource=WorkerFactory(
            _item=profile, role="Interested"),
                                            event=context.sched_event)

        login_as(self.priv_profile, self)
        response = self.client.get(
            self.url, data={"conf_slug": context.conference.conference_slug})
        self.assertContains(response, str(profile))
        self.assertContains(response, context.bid.e_title, 2)
        self.assertContains(response, "interested-sched")
class TestGetCheckListForRoles(TestCase):
    '''Tests that checklists are built based on roles'''

    def setUp(self):
        self.role_condition = RoleEligibilityConditionFactory()
        self.teacher = PersonaFactory()
        booking = book_worker_item_for_role(self.teacher,
                                            self.role_condition.role)
        self.conference = booking.event.eventitem.get_conference()

    def test_no_role(self):
        '''
            purchaser has no roles
        '''
        no_match_profile = ProfileFactory()

        checklist_items = get_checklist_items_for_roles(
            no_match_profile,
            self.conference,
            [])

        nt.assert_equal(len(checklist_items), 0)

    def test_no_role_this_conference(self):
        '''
            purchaser has no roles in this conference
        '''
        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile,
            ConferenceFactory(),
            [])

        nt.assert_equal(len(checklist_items), 0)

    def test_role_match_happens(self):
        '''
            the profile fits the role, item is given
        '''

        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile,
            self.conference,
            [])

        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(checklist_items["Teacher"],
                        [self.role_condition.checklistitem])

    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_role_match_two_conditions(self):
        '''
            two conditions match this circumstance
        '''

        another_match = RoleEligibilityConditionFactory()

        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile,
            self.conference,
            [])

        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(checklist_items["Teacher"],
                        [self.role_condition.checklistitem,
                         another_match.checklistitem])
        another_match.delete()

    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 tearDown(self):
        self.role_condition.delete()
Esempio n. 14
0
 def setUp(self):
     self.role_condition = RoleEligibilityConditionFactory()
     self.teacher = PersonaFactory()
     booking = book_worker_item_for_role(self.teacher,
                                         self.role_condition.role)
     self.conference = booking.event.eventitem.get_conference()
Esempio n. 15
0
class TestGetCheckListForRoles(TestCase):
    '''Tests that checklists are built based on roles'''
    def setUp(self):
        self.role_condition = RoleEligibilityConditionFactory()
        self.teacher = PersonaFactory()
        booking = book_worker_item_for_role(self.teacher,
                                            self.role_condition.role)
        self.conference = booking.event.eventitem.get_conference()

    def test_no_role(self):
        '''
            purchaser has no roles
        '''
        no_match_profile = ProfileFactory()

        checklist_items = get_checklist_items_for_roles(
            no_match_profile, self.conference, [])

        nt.assert_equal(len(checklist_items), 0)

    def test_no_role_this_conference(self):
        '''
            purchaser has no roles in this conference
        '''
        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile, ConferenceFactory(), [])

        nt.assert_equal(len(checklist_items), 0)

    def test_role_match_happens(self):
        '''
            the profile fits the role, item is given
        '''

        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile, self.conference, [])

        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(checklist_items["Teacher"],
                        [self.role_condition.checklistitem])

    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_role_match_two_conditions(self):
        '''
            two conditions match this circumstance
        '''

        another_match = RoleEligibilityConditionFactory()

        checklist_items = get_checklist_items_for_roles(
            self.teacher.performer_profile, self.conference, [])

        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(
            checklist_items["Teacher"],
            [self.role_condition.checklistitem, another_match.checklistitem])
        another_match.delete()

    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 tearDown(self):
        self.role_condition.delete()
 def test_get_role_eligibility(self):
     role_condition = RoleEligibilityConditionFactory()
     response = self.client.get(
         '/admin/ticketing/roleeligibilitycondition/', follow=True)
     self.assertContains(response, role_condition.role)
     self.assertContains(response, role_condition.checklistitem)
class TestGetCheckListItems(TestCase):
    '''Tests for the biggest method to get all types of checklist items'''
    def setUp(self):
        self.role_condition = RoleEligibilityConditionFactory()
        self.ticket_condition = TicketingEligibilityConditionFactory()

    def test_no_checklist(self):
        '''
            profile matches no conditions
        '''
        no_match_profile = ProfileFactory()
        transaction = TransactionFactory()
        conf = transaction.ticket_item.ticketing_event.conference
        self.ticket_condition.tickets.add(transaction.ticket_item)
        no_schedule = get_schedule(no_match_profile.user_object,
                                   labels=[conf.conference_slug
                                           ]).schedule_items
        ticket_items, role_items = get_checklist_items(
            no_match_profile,
            transaction.ticket_item.ticketing_event.conference, no_schedule)

        nt.assert_equal(len(ticket_items), 0)
        nt.assert_equal(len(role_items), 0)

    def test_role_match(self):
        '''
            profile has a role match condition
        '''
        teacher = PersonaFactory()
        booking = book_worker_item_for_role(teacher, self.role_condition.role)
        conference = booking.event.eventitem.get_conference()
        self.schedule = get_schedule(teacher.performer_profile.user_object,
                                     labels=[conference.conference_slug
                                             ]).schedule_items

        ticket_items, role_items = get_checklist_items(
            teacher.performer_profile, conference, self.schedule)
        nt.assert_equal(len(role_items), 1)
        nt.assert_equal(role_items[self.role_condition.role],
                        [self.role_condition.checklistitem])

    def test_ticket_match(self):
        '''
            profile has a ticket match condition
        '''
        transaction = TransactionFactory()
        purchaser = ProfileFactory(
            user_object=transaction.purchaser.matched_to_user)
        conference = transaction.ticket_item.ticketing_event.conference
        self.ticket_condition.tickets.add(transaction.ticket_item)
        self.ticket_condition.save()
        self.schedule = get_schedule(purchaser.user_object,
                                     labels=[conference.conference_slug
                                             ]).schedule_items

        ticket_items, role_items = get_checklist_items(purchaser, conference,
                                                       self.schedule)

        nt.assert_equal(len(ticket_items), 1)
        nt.assert_equal(ticket_items[0]['items'],
                        [self.ticket_condition.checklistitem])

    def test_both_match(self):
        '''
            profile meets role and ticket
        '''
        teacher = PersonaFactory()
        booking = book_worker_item_for_role(teacher, self.role_condition.role)
        conference = booking.event.eventitem.get_conference()

        purchaser = PurchaserFactory(
            matched_to_user=teacher.performer_profile.user_object)
        transaction = TransactionFactory(purchaser=purchaser)
        transaction.ticket_item.ticketing_event.conference = conference
        transaction.ticket_item.ticketing_event.save()
        self.ticket_condition.tickets.add(transaction.ticket_item)
        self.ticket_condition.save()

        self.schedule = get_schedule(teacher.performer_profile.user_object,
                                     labels=[conference.conference_slug
                                             ]).schedule_items
        ticket_items, role_items = get_checklist_items(
            teacher.performer_profile, conference, self.schedule)
        nt.assert_equal(len(ticket_items), 1)
        nt.assert_equal(len(role_items), 1)
        nt.assert_equal(ticket_items[0]['ticket'],
                        transaction.ticket_item.title)
        nt.assert_equal(role_items[self.role_condition.role],
                        [self.role_condition.checklistitem])

    def tearDown(self):
        self.role_condition.delete()
        self.ticket_condition.delete()
 def setUp(self):
     self.role_condition = RoleEligibilityConditionFactory()
     self.ticket_condition = TicketingEligibilityConditionFactory()
 def setUp(self):
     self.role_condition = RoleEligibilityConditionFactory()
     self.teacher = PersonaFactory()
     booking = book_worker_item_for_role(self.teacher,
                                         self.role_condition.role)
     self.conference = booking.event.eventitem.get_conference()