Replace assertEquals by assertEqual (deprecated and removed in Python 3.12)

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-02-24 23:10:06 +01:00
parent 207af441a0
commit 01ba0a1df9
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 47 additions and 47 deletions

View File

@ -614,17 +614,17 @@ class TestPayment(TestCase):
Ensure that the payment page loads correctly.
"""
response = self.client.get(reverse('participation:team_detail', args=(self.team.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.get(reverse('registration:user_detail', args=(self.user.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.get(reverse('participation:tournament_payments', args=(self.tournament.pk,)))
self.assertEquals(response.status_code, 403)
self.assertEqual(response.status_code, 403)
payment = Payment.objects.get(registrations=self.user.registration, final=False)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
def test_bank_transfer_payment(self):
"""
@ -632,28 +632,28 @@ class TestPayment(TestCase):
"""
payment = Payment.objects.get(registrations=self.user.registration, final=False)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "bank_transfer",
'additional_information': "This is a bank transfer"})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'receipt',
["This field is required.", "You must upload your receipt."])
payment.refresh_from_db()
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEqual(payment.type, "")
# README is not a valid PDF file
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "bank_transfer",
'additional_information': "This is a bank transfer",
'receipt': open("README.md", "rb")})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'receipt',
["The uploaded file must be a PDF, PNG of JPEG file."])
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEqual(payment.type, "")
# Don't send too large files
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
@ -664,11 +664,11 @@ class TestPayment(TestCase):
content=int(0).to_bytes(2000001, "big"),
content_type="application/pdf"),
})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'receipt',
["The uploaded file size must be under 2 Mo."])
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEqual(payment.type, "")
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "bank_transfer",
@ -677,12 +677,12 @@ class TestPayment(TestCase):
self.assertRedirects(response, reverse('participation:team_detail', args=(self.team.pk,)), 302, 200)
payment.refresh_from_db()
self.assertIsNone(payment.valid)
self.assertEquals(payment.type, "bank_transfer")
self.assertEquals(payment.additional_information, "This is a bank transfer")
self.assertEqual(payment.type, "bank_transfer")
self.assertEqual(payment.additional_information, "This is a bank transfer")
self.assertIsNotNone(payment.receipt)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
def test_scholarship(self):
"""
@ -690,30 +690,30 @@ class TestPayment(TestCase):
"""
payment = Payment.objects.get(registrations=self.user.registration, final=False)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "scholarship",
'additional_information': "I don't have to pay because I have a scholarship"})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'receipt',
["This field is required.", "You must upload your receipt."])
payment.refresh_from_db()
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEquals(payment.amount, self.tournament.price)
self.assertEqual(payment.type, "")
self.assertEqual(payment.amount, self.tournament.price)
# README is not a valid PDF file
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "scholarship",
'additional_information': "I don't have to pay because I have a scholarship",
'receipt': open("README.md", "rb")})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'receipt',
["The uploaded file must be a PDF, PNG of JPEG file."])
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEquals(payment.amount, self.tournament.price)
self.assertEqual(payment.type, "")
self.assertEqual(payment.amount, self.tournament.price)
# Don't send too large files
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
@ -724,12 +724,12 @@ class TestPayment(TestCase):
content=int(0).to_bytes(2000001, "big"),
content_type="application/pdf"),
})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'receipt',
["The uploaded file size must be under 2 Mo."])
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEquals(payment.amount, self.tournament.price)
self.assertEqual(payment.type, "")
self.assertEqual(payment.amount, self.tournament.price)
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "scholarship",
@ -738,13 +738,13 @@ class TestPayment(TestCase):
self.assertRedirects(response, reverse('participation:team_detail', args=(self.team.pk,)), 302, 200)
payment.refresh_from_db()
self.assertIsNone(payment.valid)
self.assertEquals(payment.type, "scholarship")
self.assertEquals(payment.additional_information, "I don't have to pay because I have a scholarship")
self.assertEqual(payment.type, "scholarship")
self.assertEqual(payment.additional_information, "I don't have to pay because I have a scholarship")
self.assertIsNotNone(payment.receipt)
self.assertEquals(payment.amount, 0)
self.assertEqual(payment.amount, 0)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
def test_other(self):
"""
@ -752,17 +752,17 @@ class TestPayment(TestCase):
"""
payment = Payment.objects.get(registrations=self.user.registration, final=False)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "other"})
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.assertFormError(response.context['form'], 'additional_information',
["This field is required."])
payment.refresh_from_db()
self.assertFalse(payment.valid)
self.assertEquals(payment.type, "")
self.assertEquals(payment.amount, self.tournament.price)
self.assertEqual(payment.type, "")
self.assertEqual(payment.amount, self.tournament.price)
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'type': "other",
@ -770,29 +770,29 @@ class TestPayment(TestCase):
self.assertRedirects(response, reverse('participation:team_detail', args=(self.team.pk,)), 302, 200)
payment.refresh_from_db()
self.assertIsNone(payment.valid)
self.assertEquals(payment.type, "other")
self.assertEquals(payment.additional_information, "Why should I pay")
self.assertEqual(payment.type, "other")
self.assertEqual(payment.additional_information, "Why should I pay")
self.assertIsNotNone(payment.receipt)
self.assertEquals(payment.amount, self.tournament.price)
self.assertEqual(payment.amount, self.tournament.price)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
def test_group(self):
payment = Payment.objects.get(registrations=self.user.registration, final=False)
self.assertFalse(payment.grouped)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.get(reverse('registration:update_payment_group_mode', args=(payment.pk,)))
self.assertRedirects(response, reverse('registration:update_payment', args=(payment.pk,)), 302, 200)
payment.refresh_from_db()
self.assertTrue(payment.grouped)
self.assertEquals(Payment.objects.count(), 1)
self.assertEqual(Payment.objects.count(), 1)
self.assertIn(self.user.registration, payment.registrations.all())
self.assertIn(self.second_user.registration, payment.registrations.all())
self.assertEquals(payment.amount, 2 * self.tournament.price)
self.assertEqual(payment.amount, 2 * self.tournament.price)
def test_ungroup(self):
"""
@ -804,16 +804,16 @@ class TestPayment(TestCase):
self.assertTrue(payment.grouped)
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.get(reverse('registration:update_payment_group_mode', args=(payment.pk,)))
self.assertRedirects(response, reverse('registration:update_payment', args=(payment.pk,)), 302, 200)
payment.refresh_from_db()
self.assertFalse(payment.grouped)
self.assertEquals(Payment.objects.count(), 2)
self.assertEqual(Payment.objects.count(), 2)
self.assertIn(self.user.registration, payment.registrations.all())
self.assertNotIn(self.second_user.registration, payment.registrations.all())
self.assertEquals(payment.amount, self.tournament.price)
self.assertEqual(payment.amount, self.tournament.price)
def test_group_forbidden(self):
"""
@ -824,10 +824,10 @@ class TestPayment(TestCase):
payment.save()
payment2 = Payment.objects.get(registrations=self.second_user.registration, final=False)
response = self.client.get(reverse('registration:update_payment_group_mode', args=(payment.pk,)))
self.assertEquals(response.status_code, 403)
self.assertEqual(response.status_code, 403)
response = self.client.get(reverse('registration:update_payment_group_mode', args=(payment2.pk,)))
self.assertEquals(response.status_code, 403)
self.assertEqual(response.status_code, 403)
def test_validate_payment(self):
"""
@ -839,11 +839,11 @@ class TestPayment(TestCase):
payment.save()
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
response = self.client.post(reverse('registration:update_payment', args=(payment.pk,)),
data={'valid': True})
self.assertEquals(response.status_code, 403)
self.assertEqual(response.status_code, 403)
self.assertFalse(payment.valid)
self.client.force_login(self.superuser)
@ -864,7 +864,7 @@ class TestPayment(TestCase):
payment.save()
response = self.client.get(reverse('registration:update_payment', args=(payment.pk,)))
self.assertEquals(response.status_code, 200)
self.assertEqual(response.status_code, 200)
self.client.force_login(self.superuser)