Example #1
0
    def test_get_tickets_for_class(self):
        '''get one ticket for everything but master, and one for classes
        '''
        event = ClassFactory()
        ws_bpt_event = BrownPaperEventsFactory(
            conference=event.e_conference,
            include_most=True,
            title="The Whole Shebang 2016")
        sch_bpt_event = BrownPaperEventsFactory(
            conference=event.e_conference,
            include_conference=True,
            title="The Scholar 2016")
        whole_shebang = TicketItemFactory(
            bpt_event=ws_bpt_event,
            live=True,
            has_coupon=False)
        scholar = TicketItemFactory(
            bpt_event=sch_bpt_event,
            live=True,
            has_coupon=False)
        tickets = event.get_tickets()

        self.assertEqual(len(tickets), 2)
        self.assertEqual(
            tickets[0],
            ws_bpt_event)
        self.assertEqual(
            tickets[1],
            sch_bpt_event)
Example #2
0
    def test_transactions_sync(self, m_urlopen):
        '''
           privileged user syncs orders
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        BrownPaperSettingsFactory()
        event = BrownPaperEventsFactory(bpt_event_id="1")
        ticket = TicketItemFactory(bpt_event=event,
                                   ticket_id='%s-%s' %
                                   (event.bpt_event_id, '3255985'))

        limbo, created = User.objects.get_or_create(username='******')

        a = Mock()
        order_filename = open("tests/ticketing/orderlist.xml", 'r')
        a.read.side_effect = [File(order_filename).read()]
        m_urlopen.return_value = a

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        nt.assert_equal(response.status_code, 200)

        transaction = get_object_or_404(Transaction, reference='A12345678')
        nt.assert_equal(str(transaction.order_date),
                        "2014-08-16 00:26:56+00:00")
        nt.assert_equal(transaction.shipping_method, 'Will Call')
        nt.assert_equal(transaction.order_notes, 'None')
        nt.assert_equal(transaction.payment_source, 'Brown Paper Tickets')
        nt.assert_equal(transaction.purchaser.email, '*****@*****.**')
        nt.assert_equal(transaction.purchaser.phone, '111-222-3333')
        nt.assert_equal(transaction.purchaser.matched_to_user, limbo)
        nt.assert_equal(transaction.purchaser.first_name, 'John')
        nt.assert_equal(transaction.purchaser.last_name, 'Smith')
    def test_get_transaction_purchase_email(self, m_urlopen):
        '''
           get a transaction for a real user via the purchase_email
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = BrownPaperEventsFactory()
        ticket = TicketItemFactory(bpt_event=event,
                                   ticket_id='%s-%s' %
                                   (event.bpt_event_id, '3255985'))
        BrownPaperSettingsFactory()
        profile = ProfileFactory(purchase_email='*****@*****.**')

        a = Mock()
        order_filename = open("tests/ticketing/orderlist.xml", 'r')
        a.read.side_effect = [File(order_filename).read()]
        m_urlopen.return_value = a

        nt.assert_equal(process_bpt_order_list(), 1)
        transaction = get_object_or_404(Transaction, reference='A12345678')
        nt.assert_equal(str(transaction.order_date),
                        "2014-08-16 00:26:56+00:00")
        nt.assert_equal(transaction.shipping_method, 'Will Call')
        nt.assert_equal(transaction.order_notes, 'None')
        nt.assert_equal(transaction.payment_source, 'Brown Paper Tickets')
        nt.assert_equal(transaction.purchaser.email, '*****@*****.**')
        nt.assert_equal(transaction.purchaser.phone, '111-222-3333')
        nt.assert_equal(transaction.purchaser.matched_to_user,
                        profile.user_object)
        nt.assert_equal(transaction.purchaser.first_name, 'John')
        nt.assert_equal(transaction.purchaser.last_name, 'Smith')
        profile.user_object.delete()
Example #4
0
def make_vendor_app_purchase(conference, user_object):
    bpt_event = BrownPaperEventsFactory(conference=conference,
                                        vendor_submission_event=True)
    purchaser = PurchaserFactory(matched_to_user=user_object)
    ticket_id = "%s-1111" % (bpt_event.bpt_event_id)
    ticket = TicketItemFactory(ticket_id=ticket_id)
    transaction = TransactionFactory(ticket_item=ticket, purchaser=purchaser)
Example #5
0
    def test_reimport_inventory(self, m_urlopen):
        '''
           privileged user gets the inventory of tickets from (fake) BPT
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = BrownPaperEventsFactory()
        BrownPaperSettingsFactory()
        TicketItemFactory(
            ticket_id='%s-4513068' % (event.bpt_event_id),
            has_coupon=True,
            live=False,
            bpt_event=event)
        a = Mock()
        date_filename = open("tests/ticketing/datelist.xml", 'r')
        price_filename = open("tests/ticketing/pricelist.xml", 'r')
        a.read.side_effect = [File(date_filename).read(),
                              File(price_filename).read()]
        m_urlopen.return_value = a

        response = self.import_tickets()
        nt.assert_equal(response.status_code, 200)
        ticket = get_object_or_404(
            TicketItem,
            ticket_id='%s-4513068' % (event.bpt_event_id))
        assert ticket.live
        assert ticket.has_coupon
Example #6
0
    def test_get_event_detail(self, m_urlopen):
        '''
           privileged user gets the inventory of tickets from (fake) BPT
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = BrownPaperEventsFactory(title='', description='')
        BrownPaperSettingsFactory()

        a = Mock()
        event_filename = open("tests/ticketing/eventlist.xml", 'r')
        date_filename = open("tests/ticketing/datelist.xml", 'r')
        price_filename = open("tests/ticketing/pricelist.xml", 'r')
        a.read.side_effect = [File(event_filename).read(),
                              File(date_filename).read(),
                              File(price_filename).read()]
        m_urlopen.return_value = a

        response = self.import_tickets()
        nt.assert_equal(response.status_code, 200)
        reload_event = get_object_or_404(
            BrownPaperEvents,
            bpt_event_id='%s' % (event.bpt_event_id))
        nt.assert_equal(response.status_code, 200)
        nt.assert_in(
            "The Great Burlesque Exposition of 2016 takes place Feb. 5-7",
            reload_event.description)
Example #7
0
    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")
Example #8
0
def make_admission_purchase(conference,
                            user_object,
                            include_most=False,
                            include_conference=False):
    bpt_event = BrownPaperEventsFactory(conference=conference,
                                        include_most=include_most,
                                        include_conference=include_conference)
    purchaser = PurchaserFactory(matched_to_user=user_object)
    ticket_id = "%s-1111" % (bpt_event.bpt_event_id)
    ticket = TicketItemFactory(ticket_id=ticket_id, bpt_event=bpt_event)
    transaction = TransactionFactory(ticket_item=ticket, purchaser=purchaser)
Example #9
0
    def test_get_tickets_for_class_three_ways(self):
        '''the ticket is linked to the class event three ways - 'most',
        'conference', and a direct link.  It only should appear once.
        '''
        event = ClassFactory()
        bpt_event = BrownPaperEventsFactory(
            conference=event.e_conference,
            include_most=True,
            include_conference=True,
            title="The Whole Shebang 2016")
        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,
            "The Whole Shebang 2016")
Example #10
0
 def test_transactions_w_privilege(self):
     '''
        privileged user gets the list
     '''
     BrownPaperEvents.objects.all().delete()
     BrownPaperSettings.objects.all().delete()
     event = BrownPaperEventsFactory()
     ticket = TicketItemFactory(bpt_event=event,
                                ticket_id='%s-%s' %
                                (event.bpt_event_id, '3255985'))
     BrownPaperSettingsFactory()
     login_as(self.privileged_user, self)
     response = self.client.get(self.url)
     nt.assert_equal(response.status_code, 200)
Example #11
0
    def test_no_settings(self, m_urlopen):
        '''
           not date list comes when getting inventory
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = BrownPaperEventsFactory(title="", description="")

        a = Mock()
        event_filename = open("tests/ticketing/eventlist.xml", 'r')
        a.read.side_effect = [File(event_filename).read()]
        m_urlopen.return_value = a

        response = self.import_tickets()
        nt.assert_equal(response.status_code, 200)
Example #12
0
    def test_urlerror(self, m_urlopen):
        '''
           first read from BPT has a URL read error
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = BrownPaperEventsFactory(title="", description="")
        BrownPaperSettingsFactory()

        a = Mock()
        a.read.side_effect = urllib2.URLError("test url error")
        m_urlopen.return_value = a

        response = self.import_tickets()
        nt.assert_equal(response.status_code, 200)
Example #13
0
    def test_no_event_list(self, m_urlopen):
        '''
           not event list comes when getting inventory
        '''
        BrownPaperEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = BrownPaperEventsFactory(title="", description="")
        BrownPaperSettingsFactory()

        a = Mock()
        a.read.side_effect = []
        m_urlopen.return_value = a

        response = self.import_tickets()
        nt.assert_equal(response.status_code, 200)
Example #14
0
    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")
Example #15
0
    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")
Example #16
0
    def test_get_tickets_nothing_active(self):
        '''the ticket is linked to the class and there are two active prices
        only the most expensive is shown
        '''
        event = ClassFactory()
        bpt_event = BrownPaperEventsFactory(
            conference=event.e_conference,
            include_conference=True)
        TicketItemFactory(bpt_event=bpt_event,
                          live=False,
                          has_coupon=False,
                          title="The Whole Shebang 2016")
        TicketItemFactory(bpt_event=bpt_event,
                          live=True,
                          has_coupon=True,
                          cost=299.99,
                          title="The Whole Shebang 2016 - expensive")

        tickets = event.get_tickets()

        self.assertEqual(len(tickets), 0)