示例#1
0
    def test_send_email_after_create_sponsoring(self):
        create_organizer_set()
        associate_events_organizers()
        create_sponsors_set()
        sponsor = Sponsor.objects.filter(enabled=True).first()
        event = Event.objects.filter(name='MyTest01').first()
        sponsor_category = SponsorCategory.objects.filter(event=event).first()
        url = reverse('sponsoring_create', kwargs={'event_pk': event.pk})
        # To complete the test we need, an event, an enabled sponsor, event_category
        self.client.login(username='******', password='******')

        data = {
            'comments': ''
        }
        data['sponsorcategory'] = sponsor_category.pk
        data['sponsor'] = sponsor.pk
        response = self.client.post(url, data)

        sponsoring = Sponsoring.objects.last()
        redirect_url = reverse('sponsoring_detail', kwargs={'pk': sponsoring.pk})
        self.assertRedirects(response, redirect_url)
        count = User.objects.filter(is_superuser=True).exclude(email__exact='').count()
        self.assertEqual(len(mail.outbox), count)
        self.assertEqual(mail.outbox[0].subject,
                         render_to_string('mails/sponsoring_just_created_subject.txt'))
示例#2
0
 def setUp(self):
     user = User.objects.first()
     create_organizer_set(auto_create_user_set=True)
     create_event_set(user)
     associate_events_organizers()
     create_sponsoring_invoice(auto_create_sponsoring_and_sponsor=True)
     create_provider()
示例#3
0
 def test_send_email_after_create_provider_expense(self, mock_save):
     create_organizer_set()
     associate_events_organizers()
     create_provider()
     mock_save.return_value = 'expense.pdf'
     provider_expense_data = {
         'provider': Provider.objects.first().pk,
         'amount': '1200',
         'invoice_type': 'A',
         'invoice_date': '12/01/2019',
         'invoice': StringIO('test'),
         'description': 'test'
     }
     url = reverse('provider_expense_create',
                   kwargs={
                       'event_pk':
                       Event.objects.filter(name='MyTest01').first().pk
                   })
     self.client.login(username='******', password='******')
     self.client.post(url, data=provider_expense_data)
     count = User.objects.filter(is_superuser=True).exclude(
         email__exact='').count()
     self.assertEqual(len(mail.outbox), count)
     self.assertEqual(
         mail.outbox[0].subject,
         render_to_string('mails/expense_just_created_subject.txt'))
示例#4
0
    def test_send_email_after_create_invoice(self, mock_save):
        mock_save.return_value = 'invoice.pdf'
        create_organizer_set()
        associate_events_organizers()
        create_sponsoring_set(auto_create_sponsors_set=True)
        event = Event.objects.filter(name='MyTest01').first()
        sponsoring = Sponsoring.objects.filter(
            sponsorcategory__event=event).first()
        # To complete the test we need, an event, an enabled sponsor, event_category
        self.client.login(username='******', password='******')
        data = {
            'amount': '40000',
            'document': StringIO('test'),
        }
        url = reverse('sponsoring_invoice_create',
                      kwargs={'pk': sponsoring.pk})
        response = self.client.post(url, data)

        redirect_url = reverse('sponsoring_detail',
                               kwargs={'pk': sponsoring.pk})
        self.assertRedirects(response, redirect_url)
        count = event.organizers.count()
        self.assertEqual(len(mail.outbox), count)
        self.assertEqual(
            mail.outbox[0].subject,
            render_to_string('mails/invoice_just_created_subject.txt'))
示例#5
0
 def setUp(self):
     create_organizer_set(auto_create_user_set=True)
     self.user = User.objects.first()
     create_event_set(self.user)
     associate_events_organizers()
     self.invoice = create_sponsoring_invoice(auto_create_sponsoring_and_sponsor=True)
     create_invoice_affect_set(self.invoice, total_amount=False)
     self.invoice.invoice_ok = True
     self.invoice.partial_payment = True
     self.invoice.save()
示例#6
0
    def test_send_organizer_associated_to_event_sends_mails_with_subject(self):
        """ Testing that function 'send_organizer_associated_to_event' sends emails to the
        listed organizers with the correct subject."""

        event = Event.objects.filter(name='MyTest01').first()
        create_organizer_set()

        email_notifier.send_organizer_associated_to_event(
            event,
            Organizer.objects.all(),
            {'domain': 'testserver', 'protocol': 'http'}
        )
        self.assertEqual(len(mail.outbox), Organizer.objects.all().count())

        send_to = []
        for email in mail.outbox:
            send_to.extend(email.to)
            self.assertEqual(email.subject,
                             render_to_string('mails/organizer_associated_to_event_subject.txt'))

        self.assertIn('*****@*****.**', send_to)
        self.assertIn('*****@*****.**', send_to)
示例#7
0
    def test_send_email_after_create_invoice_affect(self):
        create_organizer_set()
        associate_events_organizers()
        invoice = create_sponsoring_invoice(auto_create_sponsoring_and_sponsor=True)
        invoice.invoice_ok = True
        invoice.save()

        url = reverse('sponsoring_invoice_affect_create', kwargs={'pk': invoice.pk})
        # To complete the test we need, an event, an enabled sponsor, event_category
        self.client.login(username='******', password='******')
        data = {
            'amount': '1000',
            'category': 'Pay'
        }
        response = self.client.post(url, data)

        redirect_url = reverse('sponsoring_detail', kwargs={'pk': invoice.sponsoring.pk})
        self.assertRedirects(response, redirect_url)
        count = User.objects.filter(is_superuser=True).exclude(email__exact='').count()
        self.assertEqual(len(mail.outbox), count)
        self.assertEqual(mail.outbox[0].subject,
                         render_to_string('mails/invoice_affect_just_created_subject.txt'))
示例#8
0
 def setUp(self):
     create_organizer_set(auto_create_user_set=True)
示例#9
0
 def setUp(self):
     create_organizer_set(auto_create_user_set=True)
     user = User.objects.first()
     create_event_set(user)
     associate_events_organizers()
示例#10
0
 def setUp(self):
     super().setUp()
     create_organizer_set(auto_create_user_set=True)
示例#11
0
    def setUp(self):
        create_user_set()
        user = User.objects.first()
        create_event_set(user)

        create_organizer_set()