示例#1
0
 def setUpTestData(cls):
     cls.alice = create_user(email_addr='*****@*****.**')
     cls.bob = create_user(email_addr='*****@*****.**')
     cls.clara = create_user(email_addr='*****@*****.**')
     cls.proposal_1 = create_proposal(cls.alice, state='accept')
     cls.proposal_2 = create_proposal(cls.alice, state='reject')
     cls.proposal_3 = create_proposal(cls.bob, state='accept')
     cls.proposal_4 = create_proposal(cls.clara, state='')
示例#2
0
 def test_when_not_paid(self):
     bob = factories.create_user('Bob')
     order = factories.create_pending_order_for_self(user=bob)
     self.client.force_login(bob)
     rsp = self.client.get(f'/orders/{order.order_id}/receipt/', follow=True)
     self.assertRedirects(rsp, f'/orders/{order.order_id}/')
     self.assertContains(rsp, 'This order has not been paid')
示例#3
0
 def test_when_not_authorized(self):
     order = factories.create_confirmed_order_for_self()
     bob = factories.create_user('Bob')
     self.client.force_login(bob)
     rsp = self.client.get(f'/orders/{order.order_id}/', follow=True)
     self.assertRedirects(rsp, '/')
     self.assertContains(rsp, 'Only the purchaser of an order can view the order')
示例#4
0
 def test_for_pending_order_for_self_when_already_has_ticket(self):
     user = factories.create_user(email_addr='*****@*****.**')
     factories.create_confirmed_order_for_self(user)
     order = factories.create_pending_order_for_self(user)
     self.client.force_login(user)
     rsp = self.client.get(f'/orders/{order.order_id}/', follow=True)
     self.assertRedirects(rsp, f'/tickets/orders/{order.order_id}/edit/')
     self.assertContains(rsp, 'You already have a ticket.  Please amend your order.')
示例#5
0
 def test_when_not_authorized(self):
     bob = factories.create_user('Bob')
     self.client.force_login(bob)
     rsp = self.client.post(
         self.url,
         {'stripeToken': 'tok_abcdefghijklmnopqurstuvwx'},
         follow=True,
     )
     self.assertRedirects(rsp, '/')
     self.assertContains(rsp, 'Only the purchaser of an order can pay for the order')
示例#6
0
    def handle(self, *args, **kwargs):
        if Order.objects.count() > 0:
            raise CommandError('The database is already populated')

        users = [
            factories.create_user(name)
            for name in ['Alice', 'Beatrice', 'Benedict']
        ]

        with override_settings(
                EMAIL_BACKEND='django.core.mail.backends.dummy.EmailBackend'):
            factories.create_ticket(users[0], num_days=5)
            factories.create_pending_order_for_others(users[0])
            factories.create_confirmed_order_for_self_and_others(
                users[1], rate='corporate')
            factories.create_confirmed_order_for_self(users[2], num_days=5)
示例#7
0
    def test_for_pending_order(self):
        user = factories.create_user(email_addr='*****@*****.**')
        order = factories.create_pending_order_for_self(user)
        self.client.force_login(user)
        rsp = self.client.get(f'/orders/{order.order_id}/', follow=True)
        self.assertContains(rsp, f'Details of your order ({order.order_id})')
        self.assertContains(rsp, '<div id="stripe-form">')
        self.assertContains(rsp, 'data-amount="15000"')
        self.assertContains(rsp, 'data-email="*****@*****.**"')

        self.assertContains(rsp, '''
        <tr>
            <td>Alice</td>
            <td>3-day individual-rate ticket</td>
            <td>Saturday, Sunday, Monday</td>
            <td>£150.00</td>
        </tr>
        ''', html=True)
示例#8
0
    def test_ticket_purchase_after_refund(self):
        user = factories.create_user()
        factories.create_confirmed_order_for_self(user)
        ticket = user.get_ticket()

        order = factories.create_pending_order_for_self(user)
        token = 'tok_abcdefghijklmnopqurstuvwx'
        with utils.patched_charge_creation_success(), utils.patched_refund_creation():
            actions.process_stripe_charge(order, token)
        self.assertEqual(order.status, 'errored')

        with utils.patched_refund_creation():
            actions.refund_item(ticket, 'Refund requested by user')

        user.refresh_from_db()
        self.assertIsNone(user.get_ticket())

        order = factories.create_pending_order_for_self(user)
        with utils.patched_charge_creation_success():
            actions.process_stripe_charge(order, token)
        self.assertEqual(order.status, 'successful')

        user.refresh_from_db()
        self.assertIsNotNone(user.get_ticket())
示例#9
0
    def setUpTestData(cls):
        cls.alice = create_user(email_addr='*****@*****.**')
        cls.bob = create_user(email_addr='*****@*****.**')
        cls.clara = create_user(email_addr='*****@*****.**')
        cls.donald = create_user(email_addr='*****@*****.**')
        cls.erica = create_user(email_addr='*****@*****.**')
        cls.frederick = create_user(email_addr='*****@*****.**')

        # Ticket and money awarded but not full amount
        cls.proposal_1 = create_application(cls.alice)
        cls.proposal_1.ticket_awarded = True
        cls.proposal_1.amount_awarded = 23.5
        cls.proposal_1.save()

        # Ticket and full amount of money awarded
        cls.proposal_2 = create_application(cls.bob)
        cls.proposal_2.ticket_awarded = True
        cls.proposal_2.amount_awarded = 23.5
        cls.proposal_2.full_amount_awarded = True
        cls.proposal_2.save()

        # No decisions made yet
        cls.proposal_3 = create_application(cls.clara)

        # Rejected
        cls.proposal_4 = create_application(cls.donald)
        cls.proposal_4.application_declined = True
        cls.proposal_4.save()

        # Ticket only wanted and ticket only given
        cls.proposal_5 = create_application(cls.erica)
        cls.proposal_5.requested_ticket_only = True
        cls.proposal_5.ticket_awarded = True
        cls.proposal_5.save()

        # Ticket and money wanted but ticket only given
        cls.proposal_6 = create_application(cls.frederick)
        cls.proposal_6.ticket_awarded = True
        cls.proposal_6.save()
示例#10
0
 def test_when_not_authorized(self):
     bob = factories.create_user('Bob')
     self.client.force_login(bob)
     rsp = self.client.get(self.url, follow=True)
     self.assertRedirects(rsp, '/')
     self.assertContains(rsp, 'Only the purchaser of an order can view a credit note')
示例#11
0
 def setUpTestData(cls):
     cls.alice = factories.create_user(email_addr='*****@*****.**')