Exemplo n.º 1
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)
 def test_get_ticketing_eligibility(self):
     ticket = TicketItemFactory()
     match_condition = TicketingEligibilityConditionFactory(
         tickets=[ticket])
     response = self.client.get(
         '/admin/ticketing/ticketingeligibilitycondition/', follow=True)
     self.assertContains(response, ticket.ticketing_event.title)
     self.assertContains(response, ticket.title)
Exemplo n.º 3
0
    def test_ticket_match_two_conditions(self):
        '''
            two conditions match this circumstance
        '''
        match_condition = TicketingEligibilityConditionFactory(
            tickets=[self.transaction.ticket_item])
        another_match = TicketingEligibilityConditionFactory(
            tickets=[self.transaction.ticket_item])

        checklist_items = get_checklist_items_for_tickets(
            self.purchaser, self.conference, [self.transaction.ticket_item])
        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(checklist_items[0]['count'], 1)
        nt.assert_equal(checklist_items[0]['ticket'],
                        self.transaction.ticket_item.title)
        nt.assert_equal(
            checklist_items[0]['items'],
            [match_condition.checklistitem, another_match.checklistitem])
 def test_get_ticketing_eligibility_edit_role_exclude_event(self):
     ticket = TicketItemFactory()
     match_condition = TicketingEligibilityConditionFactory(
         tickets=[ticket])
     exclusion = RoleExclusionFactory(condition=match_condition,
                                      role="Performer")
     response = self.client.get(reverse(
         "admin:ticketing_ticketingeligibilitycondition_change",
         args=(match_condition.id, )),
                                follow=True)
     self.assertContains(response, "Performer in %s" % exclusion.event)
Exemplo n.º 5
0
    def test_ticket_is_excluded(self):
        '''
            there's a match, but also an exclusion
        '''
        match_condition = TicketingEligibilityConditionFactory(
            tickets=[self.transaction.ticket_item])
        exclusion = TicketingExclusionFactory(
            condition=match_condition, tickets=[self.transaction.ticket_item])

        checklist_items = get_checklist_items_for_tickets(
            self.purchaser, self.conference, [])
        nt.assert_equal(len(checklist_items), 0)
 def test_get_ticketing_eligibility_cond_changelist(self):
     ticket = TicketItemFactory()
     ticket2 = TicketItemFactory()
     ticket3 = TicketItemFactory()
     match_condition = TicketingEligibilityConditionFactory(
         tickets=[ticket])
     exclusion = TicketingExclusionFactory(condition=match_condition,
                                           tickets=[ticket2, ticket3])
     response = self.client.get(reverse(
         "admin:ticketing_ticketingeligibilitycondition_changelist"),
                                follow=True)
     self.assertContains(response,
                         match_condition.checklistitem.description)
 def test_get_ticketing_eligibility_edit_ticket_exclude(self):
     ticket = TicketItemFactory()
     ticket2 = TicketItemFactory(ticketing_event__title=None)
     ticket3 = TicketItemFactory()
     match_condition = TicketingEligibilityConditionFactory(
         tickets=[ticket])
     exclusion = TicketingExclusionFactory(condition=match_condition,
                                           tickets=[ticket2, ticket3])
     response = self.client.get(reverse(
         "admin:ticketing_ticketingeligibilitycondition_change",
         args=(match_condition.id, )),
                                follow=True)
     self.assertContains(response, "%s, %s" % (ticket2, ticket3))
Exemplo n.º 8
0
    def test_ticket_match_happens(self):
        '''
            feeding in the matching ticket, gives an item
        '''
        match_condition = TicketingEligibilityConditionFactory(
            tickets=[self.transaction.ticket_item])

        checklist_items = get_checklist_items_for_tickets(
            self.purchaser, self.conference, [self.transaction.ticket_item])
        nt.assert_equal(len(checklist_items), 1)
        nt.assert_equal(checklist_items[0]['count'], 1)
        nt.assert_equal(checklist_items[0]['ticket'],
                        self.transaction.ticket_item.title)
        nt.assert_equal(checklist_items[0]['items'],
                        [match_condition.checklistitem])
Exemplo n.º 9
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")
Exemplo n.º 10
0
 def test_w_ticket_condition(self):
     '''loads with the default conference selection.
     '''
     ticket_condition = TicketingEligibilityConditionFactory(
         checklistitem__badge_title="Badge Name")
     ticket_condition.tickets.add(
         self.ticket_context.transaction.ticket_item)
     login_as(self.privileged_user, self)
     response = self.client.get(self.url)
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.get('Content-Disposition'),
                      "attachment; filename=print_badges.csv")
     self.assertContains(
         response,
         "First,Last,username,Badge Name,Badge Type,Ticket Purchased,Date")
     self.assertContains(response,
                         self.ticket_context.profile.user_object.username)
     self.assertContains(response,
                         self.ticket_context.transaction.ticket_item.title)
     self.assertContains(response, "Badge Name")
Exemplo n.º 11
0
    def test_ticket_purchase(self):
        '''a ticket purchaser gets a checklist item
        '''
        transaction = TransactionFactory()
        purchaser = ProfileFactory(
            user_object=transaction.purchaser.matched_to_user)
        conference = transaction.ticket_item.bpt_event.conference
        ticket_condition = TicketingEligibilityConditionFactory(
            tickets=[transaction.ticket_item])
        context = ClassContext(
            conference=transaction.ticket_item.bpt_event.conference)
        context.set_interest(interested_profile=purchaser)

        request = self.factory.get('reports/schedule_all?conf_slug=' +
                                   conference.conference_slug)
        login_as(self.priv_profile, self)
        response = self.client.get(
            self.url, data={"conf_slug": conference.conference_slug})
        self.assertEqual(response.status_code, 200)
        nt.assert_true(str(purchaser) in response.content,
                       msg="Buyer is not in the list")
        nt.assert_true(str(ticket_condition.checklistitem) in response.content)
Exemplo n.º 12
0
    def test_ticket_purchase_solo_profile(self):
        '''a ticket purchaser gets a checklist item
        '''
        transaction = TransactionFactory()
        purchaser = ProfileFactory(
            user_object=transaction.purchaser.matched_to_user)
        conference = transaction.ticket_item.ticketing_event.conference
        ticket_condition = TicketingEligibilityConditionFactory(
            tickets=[transaction.ticket_item])

        request = self.factory.get('reports/schedule_all?conf_slug=' +
                                   conference.conference_slug)
        login_as(self.priv_profile, self)
        response = self.client.get(
            reverse('welcome_letter',
                    urlconf='gbe.reporting.urls',
                    args=[purchaser.pk]),
            data={"conf_slug": conference.conference_slug})
        self.assertEqual(response.status_code, 200)
        self.assertContains(response,
                            str(purchaser),
                            msg_prefix="Buyer is not in the list")
        self.assertContains(response, str(ticket_condition.checklistitem))
Exemplo n.º 13
0
 def setUp(self):
     self.ticketingcondition = TicketingEligibilityConditionFactory()
     self.transaction = TransactionFactory()
     self.purchaser = ProfileFactory(
         user_object=self.transaction.purchaser.matched_to_user)
     self.conference = self.transaction.ticket_item.bpt_event.conference
 def setUp(self):
     self.role_condition = RoleEligibilityConditionFactory()
     self.ticket_condition = TicketingEligibilityConditionFactory()
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()
Exemplo n.º 16
0
class TestCheckListItemList(TestCase):
    view_name = 'checklistitem_list'

    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)

    def test_get_success(self):
        login_as(self.privileged_user, self)
        response = self.client.get(self.url)
        self.assertContains(response, intro_role_cond_message)
        self.assertContains(response, intro_ticket_cond_message)
        self.assertContains(response,
                            self.role_condition.checklistitem.description)
        self.assertContains(response,
                            self.ticket_condition.checklistitem.description)
        self.assertContains(response, self.role_condition.role)
        self.assertContains(response, self.ticket_item.title)
        self.assertContains(response, self.ticket_item.ticketing_event.title)
        self.assertContains(response, "No Override")

    def test_two_tickets_one_event(self):
        second_ticket_item = TicketItemFactory(
            ticketing_event=self.ticket_item.ticketing_event)
        self.ticket_condition.tickets.add(second_ticket_item)
        login_as(self.privileged_user, self)
        response = self.client.get(self.url)
        self.assertContains(response, self.ticket_item.title)
        self.assertContains(response, self.ticket_item.ticketing_event.title)
        self.assertContains(response, second_ticket_item.title)
        self.assertContains(response, second_ticket_item.ticketing_event.title)

    def test_no_conditions(self):
        RoleEligibilityCondition.objects.all().delete()
        TicketingEligibilityCondition.objects.all().delete()
        login_as(self.privileged_user, self)
        response = self.client.get(self.url)
        self.assertContains(response, intro_role_cond_message)
        self.assertContains(response, intro_ticket_cond_message)

    def test_ticket_exclusion(self):
        self.ticket_condition.delete()
        self.ticketingexclusion = TicketingExclusionFactory(
            condition=self.role_condition)
        self.ticketingexclusion.tickets.add(self.ticket_item)

        login_as(self.privileged_user, self)
        response = self.client.get(self.url)
        print(response.content)
        self.assertContains(response, intro_role_cond_message)
        self.assertContains(response, intro_ticket_cond_message)
        self.assertContains(response,
                            self.role_condition.checklistitem.description)
        self.assertContains(response, self.role_condition.role)
        self.assertContains(response, str(self.ticket_item), 1)

    def test_role_exclusion(self):
        self.roleexclusion = RoleExclusionFactory(
            condition=self.role_condition)

        login_as(self.privileged_user, self)
        response = self.client.get(self.url)
        self.assertContains(response, intro_role_cond_message)
        self.assertContains(response, intro_ticket_cond_message)
        self.assertContains(response,
                            self.role_condition.checklistitem.description)
        self.assertContains(response, self.role_condition.role)
        self.assertContains(response, str(self.roleexclusion))