def test_get_eb_inventory_ticket_pagination(self, m_eventbrite):
        # privileged user gets the inventory of tickets from (fake) EB
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = TicketingEventsFactory()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()
        simple_event_dict = copy.deepcopy(event_dict)
        simple_event_dict['events'] = [event_dict['events'][0]]
        continue_ticket_page = copy.deepcopy(ticket_dict1)
        continue_ticket_page['pagination']['has_more_items'] = True
        continue_ticket_page['pagination']['continuation'] = "eyJwYWdlIjogMn0"
        m_eventbrite.side_effect = [
            simple_event_dict, continue_ticket_page, ticket_dict3
        ]

        response = self.import_tickets()
        assert_alert_exists(response, 'success', 'Success',
                            ("Successfully imported %d events, %d tickets" %
                             (1, 4)))
        assert_alert_exists(response, 'success', 'Success',
                            ("BPT: imported %d tickets") % (0))
        ticket = get_object_or_404(TicketItem, ticket_id='987987987')
        self.assertEqual(ticket.cost, Decimal('0.00'))
        ticket = get_object_or_404(TicketItem, ticket_id='098098098')
        self.assertEqual(ticket.cost, Decimal('100.00'))
Exemple #2
0
 def test_transactions_sync_no_sources_on(self):
     TicketingEvents.objects.all().delete()
     BrownPaperSettings.objects.all().delete()
     EventbriteSettings.objects.all().delete()
     BrownPaperSettingsFactory(active_sync=False)
     EventbriteSettingsFactory(active_sync=False)
     login_as(self.privileged_user, self)
     response = self.client.post(self.url, data={'Sync': 'Sync'})
     assert_alert_exists(
         response, 'success', 'Success',
         "%s   Transactions imported: %s - BPT" %
         (import_transaction_message, "0"))
     assert_alert_exists(response, 'success', 'Success',
                         sync_off_instructions % "Eventbrite")
    def test_get_eb_no_org(self, m_eventbrite):
        # privileged user gets the inventory of tickets from (fake) EB
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = TicketingEventsFactory()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory(organization_id=None)

        m_eventbrite.side_effect = [org_dict]

        response = self.import_tickets()
        assert_alert_exists(
            response, 'danger', 'Error',
            "%s<br>%s - %s" % (org_id_instructions, "547440371489", "GBE Dev"))
    def test_get_eb_debug_server(self, m_eventbrite):
        # test case for debug server being different, w no events to sync
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        BrownPaperSettingsFactory(active_sync=False)
        EventbriteSettingsFactory(system=0)
        empty_event_dict = copy.deepcopy(event_dict)
        empty_event_dict['events'] = []
        m_eventbrite.side_effect = [empty_event_dict]

        response = self.import_tickets()
        assert_alert_exists(response, 'success', 'Success',
                            ("Successfully imported %d events, %d tickets") %
                            (0, 0))
        assert_alert_exists(response, 'success', 'Success',
                            ("BPT: imported %d tickets") % (0))
    def test_get_eb_org_fail(self, m_eventbrite):
        # privileged user gets the inventory of tickets from (fake) EB
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = TicketingEventsFactory()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory(organization_id=None)

        m_eventbrite.side_effect = [{
            "status_code": 403,
            "error_description": "Made up error",
            "error": "NOT_ALLOWED"
        }]

        response = self.import_tickets()
        assert_alert_exists(response, 'danger', 'Error',
                            eventbrite_error % (403, "Made up error"))
Exemple #6
0
    def test_transactions_sync_eb_w_purchaser(self, m_eventbrite):
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        EventbriteSettings.objects.all().delete()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()
        event = TicketingEventsFactory(event_id="1", source=2)
        ticket = TicketItemFactory(ticketing_event=event, ticket_id='3255985')
        purchaser = PurchaserFactory()
        known_buyer_order = order_dict
        known_buyer_order['attendees'][0]["profile"]["email"] = purchaser.email
        m_eventbrite.return_value = known_buyer_order

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        assert_alert_exists(
            response, 'success', 'Success',
            "%s  Transactions imported: %d -- Eventbrite" %
            (import_transaction_message, 1))
Exemple #7
0
    def test_transactions_sync_eb_match_prior_purchaser(self, m_eventbrite):
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        EventbriteSettings.objects.all().delete()
        BrownPaperSettingsFactory(active_sync=False)
        EventbriteSettingsFactory()
        event = TicketingEventsFactory(event_id="1", source=2)
        ticket = TicketItemFactory(ticketing_event=event, ticket_id='3255985')

        limbo, created = User.objects.get_or_create(username='******')
        purchaser = PurchaserFactory(matched_to_user=limbo)
        user = UserFactory(email=purchaser.email)
        m_eventbrite.return_value = order_dict

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        print(response.content)
        test_purchaser = Purchaser.objects.get(pk=purchaser.pk)
        self.assertEqual(test_purchaser.matched_to_user, user)
    def test_get_eb_inventory_ticket_fail(self, m_eventbrite):
        # privileged user gets the inventory of tickets from (fake) EB
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = TicketingEventsFactory()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()
        simple_event_dict = copy.deepcopy(event_dict)
        simple_event_dict['events'] = [event_dict['events'][0]]
        error_ticket_page = {
            "status_code": 403,
            "error_description": "Made up error",
            "error": "NOT_ALLOWED"
        }
        m_eventbrite.side_effect = [simple_event_dict, error_ticket_page]

        response = self.import_tickets()
        assert_alert_exists(response, 'danger', 'Error',
                            eventbrite_error % (403, "Made up error"))
Exemple #9
0
    def test_transactions_sync_eb_bad_auth_token(self, m_eventbrite):
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        EventbriteSettings.objects.all().delete()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()
        event = TicketingEventsFactory(event_id="1", source=2)
        ticket = TicketItemFactory(ticketing_event=event, ticket_id='3255985')

        m_eventbrite.side_effect = [{
            "status_code": 401,
            "error_description": "The OAuth token you provided was invalid.",
            "error": "NOT_AUTH"
        }]

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        assert_alert_exists(
            response, 'danger', 'Error', eventbrite_error %
            (401, "The OAuth token you provided was invalid."))
 def test_get_eb_inventory_event_continuation(self, m_eventbrite):
     # privileged user gets the inventory of tickets from (fake) EB
     TicketingEvents.objects.all().delete()
     BrownPaperSettings.objects.all().delete()
     event = TicketingEventsFactory()
     BrownPaperSettingsFactory()
     EventbriteSettingsFactory()
     simple_event_dict = copy.deepcopy(event_dict)
     simple_event_dict['pagination']['has_more_items'] = True
     simple_event_dict['pagination']['continuation'] = "eyJwYWdlIjogMn0"
     m_eventbrite.side_effect = [
         simple_event_dict, event_dict, ticket_dict1, ticket_dict2,
         ticket_dict3
     ]
     response = self.import_tickets()
     assert_alert_exists(response, 'success', 'Success',
                         ("Successfully imported %d events, %d tickets" %
                          (3, 6)))
     assert_alert_exists(response, 'success', 'Success',
                         ("BPT: imported %d tickets" % 0))
Exemple #11
0
    def test_transactions_sync_ticket_missing(self, m_eventbrite):
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        EventbriteSettings.objects.all().delete()
        SyncStatus.objects.all().delete()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()
        event = TicketingEventsFactory(event_id="1", source=2)

        m_eventbrite.return_value = order_dict

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        assert_alert_exists(response, 'danger', 'Error',
                            "Ticket Item for id 3255985 does not exist")
        error_status = SyncStatus.objects.filter(is_success=False).first()
        success_status = SyncStatus.objects.filter(is_success=True).first()
        self.assertEqual(error_status.error_msg,
                         "Ticket Item for id 3255985 does not exist")
        self.assertEqual(success_status.import_type, "EB Transaction")
        self.assertEqual(success_status.import_number, 0)
Exemple #12
0
    def test_transactions_sync_eb_pagination(self, m_eventbrite):
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        EventbriteSettings.objects.all().delete()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()
        event = TicketingEventsFactory(event_id="1", source=2)
        ticket = TicketItemFactory(ticketing_event=event, ticket_id='3255985')

        limbo, created = User.objects.get_or_create(username='******')
        continue_order_page = copy.deepcopy(order_dict)
        continue_order_page['pagination']['has_more_items'] = True
        continue_order_page['pagination']['continuation'] = "eyJwYWdlIjogMn0"
        m_eventbrite.side_effect = [continue_order_page, order_dict]

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        assert_alert_exists(
            response, 'success', 'Success',
            "%s  Transactions imported: %d -- Eventbrite" %
            (import_transaction_message, 1))
Exemple #13
0
    def test_transactions_sync_eb_only(self, m_eventbrite):
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        EventbriteSettings.objects.all().delete()
        SyncStatus.objects.all().delete()
        BrownPaperSettingsFactory(active_sync=False)
        EventbriteSettingsFactory()
        event = TicketingEventsFactory(event_id="1", source=2)
        ticket = TicketItemFactory(ticketing_event=event, ticket_id='3255985')

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

        login_as(self.privileged_user, self)
        response = self.client.post(self.url, data={'Sync': 'Sync'})
        assert_alert_exists(
            response, 'success', 'Success',
            "%s  Transactions imported: %d -- Eventbrite" %
            (import_transaction_message, 1))
        success_status = SyncStatus.objects.filter(is_success=True).first()
        self.assertEqual(success_status.import_type, "EB Transaction")
        self.assertEqual(success_status.import_number, 1)
    def test_get_eb_inventory(self, m_eventbrite):
        # privileged user gets the inventory of tickets from (fake) EB
        TicketingEvents.objects.all().delete()
        BrownPaperSettings.objects.all().delete()
        event = TicketingEventsFactory()
        BrownPaperSettingsFactory()
        EventbriteSettingsFactory()

        m_eventbrite.side_effect = [
            event_dict, ticket_dict1, ticket_dict2, ticket_dict3
        ]

        response = self.import_tickets()
        assert_alert_exists(response, 'success', 'Success',
                            ("Successfully imported %d events, %d tickets") %
                            (3, 6))
        assert_alert_exists(response, 'success', 'Success',
                            ("BPT: imported %d tickets") % (0))
        ticket = get_object_or_404(TicketItem, ticket_id='987987987')
        self.assertEqual(ticket.cost, Decimal('0.00'))
        ticket = get_object_or_404(TicketItem, ticket_id='098098098')
        self.assertEqual(ticket.cost, Decimal('100.00'))
 def setUp(self):
     self.client = Client()
     EventbriteSettingsFactory()
 def test_get_ebsettings_active(self):
     settings = EventbriteSettingsFactory()
     response = self.client.get('/admin/ticketing/eventbritesettings/',
                                follow=True)
     self.assertContains(response, str(settings))