def setUpTestData(cls): super().setUpTestData() tickets_factories.create_ticket(num_days=1) tickets_factories.create_ticket(num_days=2, rate='corporate') tickets_factories.create_ticket(num_days=3) tickets_factories.create_ticket(num_days=4, rate='corporate') tickets_factories.create_ticket(num_days=5)
def test_ticket(self): user = User.objects.create_user( email_addr='*****@*****.**', name='Alice', password='******', ) tickets_factories.create_ticket(user) self.assertIsNotNone(user.get_ticket())
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)
def test_when_has_ticket_and_full_profile(self): user = account_factories.create_user_with_full_profile() ticket = ticket_factories.create_ticket(user) self.client.force_login(user) rsp = self.client.get('/') self.assertContains( rsp, f'<a href="/tickets/tickets/{ticket.ticket_id}/">View your conference ticket</a>', html=True) self.assertContains(rsp, '<a href="/profile/">Update your profile</a>', html=True) self.assertNotContains(rsp, 'Your profile is incomplete')
def test_when_has_ticket(self): ticket = ticket_factories.create_ticket(self.alice) rsp = self.client.get('/') self.assertContains( rsp, 'You have a ticket for Thursday, Friday, Saturday') self.assertContains( rsp, f'<a href="/tickets/tickets/{ticket.ticket_id}/">View your conference ticket</a>', html=True) self.assertContains(rsp, '<a href="/profile/">Update your profile</a>', html=True) self.assertContains(rsp, 'Your profile is incomplete') self.assertContains(rsp, 'We look forward to seeing you in Cardiff')
def test_refund_item(self): ticket = factories.create_ticket() order_row = ticket.order_row with utils.patched_refund_creation(): actions.refund_item(ticket, 'Refund requested by user') with self.assertRaises(Ticket.DoesNotExist): ticket.refresh_from_db() order_row.refresh_from_db() self.assertIsNone(order_row.item) self.assertEqual(order_row.cost_excl_vat, 125) self.assertEqual(order_row.item_descr, '3-day individual-rate ticket') self.assertEqual(order_row.item_descr_extra, 'Saturday, Sunday, Monday') self.assertIsNotNone(order_row.refund) self.assertEqual(order_row.refund.reason, 'Refund requested by user') self.assertEqual(order_row.refund.credit_note_number, 1)