mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2024-12-24 18:22:24 +00:00
Add tests for payment management commands
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
parent
9829541289
commit
348004320c
@ -4,10 +4,13 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core import mail
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.core.management import call_command
|
||||
from django.test import LiveServerTestCase, override_settings, TestCase
|
||||
from django.urls import reverse
|
||||
from django.utils import translation
|
||||
|
||||
from registration.models import CoachRegistration, Payment, StudentRegistration
|
||||
|
||||
from .models import Participation, Team, Tournament
|
||||
@ -874,6 +877,30 @@ class TestPayment(TestCase):
|
||||
payment.refresh_from_db()
|
||||
self.assertFalse(payment.valid)
|
||||
|
||||
def test_payment_reminder(self):
|
||||
"""
|
||||
Check that the payment reminder command works correctly.
|
||||
"""
|
||||
translation.activate('fr')
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
call_command('remind_payments')
|
||||
self.assertEqual(len(mail.outbox), 2)
|
||||
self.assertEqual(mail.outbox[0].subject, "[TFJM²] Rappel pour votre paiement")
|
||||
|
||||
payment = Payment.objects.get(registrations=self.user.registration, final=False)
|
||||
payment2 = Payment.objects.get(registrations=self.second_user.registration, final=False)
|
||||
payment.type = 'other'
|
||||
payment.valid = True
|
||||
payment.save()
|
||||
payment2.type = 'bank_transfer'
|
||||
payment2.valid = None
|
||||
payment2.save()
|
||||
|
||||
mail.outbox = []
|
||||
call_command('remind_payments')
|
||||
self.assertEqual(len(mail.outbox), 0)
|
||||
|
||||
|
||||
@override_settings(HELLOASSO_TEST_ENDPOINT=True, ROOT_URLCONF="tfjm.helloasso.test_urls")
|
||||
class TestHelloAssoPayment(LiveServerTestCase):
|
||||
@ -1076,6 +1103,32 @@ class TestHelloAssoPayment(LiveServerTestCase):
|
||||
checkout_intent = payment.get_checkout_intent()
|
||||
self.assertIn('order', checkout_intent)
|
||||
|
||||
def test_hello_asso_payment_verification(self):
|
||||
"""
|
||||
Check that a payment that is pending verification can be verified.
|
||||
"""
|
||||
with self.settings(HELLOASSO_TEST_ENDPOINT_URL=self.live_server_url):
|
||||
payment = Payment.objects.get(registrations=self.user.registration, final=False)
|
||||
self.assertFalse(payment.valid)
|
||||
|
||||
call_command('check_hello_asso')
|
||||
payment.refresh_from_db()
|
||||
self.assertFalse(payment.valid)
|
||||
|
||||
self.client.get(reverse('registration:payment_hello_asso', args=(payment.pk,)),
|
||||
follow=True)
|
||||
|
||||
payment.refresh_from_db()
|
||||
payment.valid = None
|
||||
payment.additional_information = ""
|
||||
payment.save()
|
||||
self.assertIsNone(payment.valid)
|
||||
|
||||
call_command('check_hello_asso')
|
||||
payment.refresh_from_db()
|
||||
self.assertTrue(payment.valid)
|
||||
self.assertTrue(payment.additional_information)
|
||||
|
||||
|
||||
class TestAdmin(TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
Loading…
Reference in New Issue
Block a user