def test_sends_slack_message(self): backend = get_slack_backend() order = factories.create_pending_order_for_self() backend.reset_messages() actions.confirm_order(order, 'ch_abcdefghijklmnopqurstuvw', 1495355163) messages = backend.retrieve_messages() self.assertEqual(len(messages), 1) text = messages[0]['text'] self.assertIn( 'Alice has just placed an order for 1 ticket at the individual rate', text)
def test_after_order_marked_as_failed(self): order = factories.create_pending_order_for_self() actions.mark_order_as_failed(order, 'There was a problem') actions.confirm_order(order, 'ch_abcdefghijklmnopqurstuvw', 1495355163) self.assertEqual(order.stripe_charge_id, 'ch_abcdefghijklmnopqurstuvw') self.assertEqual(order.stripe_charge_created.timestamp(), 1495355163) self.assertEqual(order.stripe_charge_failure_reason, '') self.assertEqual(order.status, 'successful') self.assertEqual(order.purchaser.orders.count(), 1) self.assertIsNotNone(order.purchaser.get_ticket()) ticket = order.purchaser.get_ticket() self.assertEqual(ticket.days(), ['Thursday', 'Friday', 'Saturday'])
def test_order_for_others(self): order = factories.create_pending_order_for_others() actions.confirm_order(order, 'ch_abcdefghijklmnopqurstuvw', 1495355163) self.assertEqual(order.stripe_charge_id, 'ch_abcdefghijklmnopqurstuvw') self.assertEqual(order.stripe_charge_created.timestamp(), 1495355163) self.assertEqual(order.stripe_charge_failure_reason, '') self.assertEqual(order.status, 'successful') self.assertEqual(order.purchaser.orders.count(), 1) self.assertIsNone(order.purchaser.get_ticket()) ticket = TicketInvitation.objects.get( email_addr='*****@*****.**').ticket self.assertEqual(ticket.days(), ['Friday', 'Saturday']) ticket = TicketInvitation.objects.get( email_addr='*****@*****.**').ticket self.assertEqual(ticket.days(), ['Saturday', 'Sunday']) self.assertEqual(len(mail.outbox), 3)
def confirm_order(order): actions.confirm_order(order, 'ch_abcdefghijklmnopqurstuvw', 1495355163)