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.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. 4
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()
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()
Esempio n. 6
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()
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()