Skip to content

Commit

Permalink
tests: fix assertion py3.11 deprecations (EsupPortail#1138)
Browse files Browse the repository at this point in the history
  • Loading branch information
azmeuk authored and LoanR committed Jun 18, 2024
1 parent addd773 commit 8803f55
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions pod/bbb/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def test_update_attributes(self):
# Test delete object
def test_delete_object(self):
Meeting.objects.filter(meeting_id="id1").delete()
self.assertEquals(Meeting.objects.all().count(), 1)
self.assertEqual(Meeting.objects.all().count(), 1)
Meeting.objects.filter(meeting_id="id2").delete()
self.assertEquals(Meeting.objects.all().count(), 0)
self.assertEqual(Meeting.objects.all().count(), 0)

print(" ---> test_delete_object of MeetingTestCase: OK!")

Expand Down Expand Up @@ -137,9 +137,9 @@ def test_update_attributes(self):
# Test delete object
def test_delete_object(self):
Attendee.objects.filter(id=1).delete()
self.assertEquals(Attendee.objects.all().count(), 1)
self.assertEqual(Attendee.objects.all().count(), 1)
Attendee.objects.filter(id=2).delete()
self.assertEquals(Attendee.objects.all().count(), 0)
self.assertEqual(Attendee.objects.all().count(), 0)

print(" ---> test_delete_object of AttendeeTestCase: OK!")

Expand Down Expand Up @@ -202,6 +202,6 @@ def test_update_attributes(self):
# Test delete object
def test_delete_object(self):
Livestream.objects.filter(id=1).delete()
self.assertEquals(Livestream.objects.all().count(), 0)
self.assertEqual(Livestream.objects.all().count(), 0)

print(" ---> test_delete_object of LivestreamTestCase: OK!")
8 changes: 4 additions & 4 deletions pod/live/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,27 +316,27 @@ def test_add_video_on_hold(self):
event = Event.objects.get(id=1)
event.video_on_hold = video
event.save()
self.assertEquals(event.video_on_hold.id, video.id)
self.assertEqual(event.video_on_hold.id, video.id)
print(" ---> test_add_video_on_hold of EventTestCase: OK!")

def test_add_video(self):
event = Event.objects.get(id=1)
event = add_video(event)
self.assertEquals(event.videos.count(), 1)
self.assertEqual(event.videos.count(), 1)
print(" ---> test_add_video of EventTestCase: OK!")

def test_delete_object(self):
event = Event.objects.get(id=1)
event.delete()
self.assertEquals(Event.objects.all().count(), 0)
self.assertEqual(Event.objects.all().count(), 0)
print(" ---> test_delete_object of EventTestCase: OK!")

def test_delete_object_keep_video(self):
event = Event.objects.get(id=1)
add_video(event)
event.delete()
# video is not deleted with event
self.assertEquals(Video.objects.all().count(), 1)
self.assertEqual(Video.objects.all().count(), 1)
print(" ---> test_delete_object_keep_video of EventTestCase: OK!")

def test_event_filters(self):
Expand Down
30 changes: 15 additions & 15 deletions pod/live/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ def test_send_email(self):
event = Event.objects.get(id=1)

bcc = get_bcc(1)
self.assertEquals(bcc, [])
self.assertEqual(bcc, [])
print(" ---> test_utils get_bcc ok")

expected = ["first", "second"]
bcc = get_bcc(expected)
self.assertEquals(bcc, expected)
self.assertEqual(bcc, expected)
print(" ---> test_utils get_bcc liste or tuple ok")

expected = "first"
bcc = get_bcc(expected)
self.assertEquals(bcc, expected.split())
self.assertEqual(bcc, expected.split())
print(" ---> test_utils get_bcc string ok")

expected = ["emailadduser1", "emailadduser2"]
Expand All @@ -55,7 +55,7 @@ def test_send_email(self):

event.additional_owners.set([additional_user1, additional_user2])
cc = get_cc(event)
self.assertEquals(cc, expected)
self.assertEqual(cc, expected)
print(" ---> test_utils get_cc ok")

# TODO test this for real
Expand All @@ -66,17 +66,17 @@ def test_date_string_to_second(self):
"""Teste la conversion d'une chaine de caractère en nombre de secondes."""
from pod.live.utils import date_string_to_second

self.assertEquals(0, date_string_to_second("a"))
self.assertEquals(0, date_string_to_second("1:1:1"))
self.assertEquals(0, date_string_to_second("00:00:61"))
self.assertEquals(0, date_string_to_second("00:61:00"))
self.assertEquals(0, date_string_to_second("24:00:00"))
self.assertEquals(0, date_string_to_second("00:00:00"))
self.assertEquals(1, date_string_to_second("00:00:01"))
self.assertEquals(60, date_string_to_second("00:01:00"))
self.assertEquals(3600, date_string_to_second("01:00:00"))
self.assertEquals(3661, date_string_to_second("01:01:01"))
self.assertEquals(86399, date_string_to_second("23:59:59"))
self.assertEqual(0, date_string_to_second("a"))
self.assertEqual(0, date_string_to_second("1:1:1"))
self.assertEqual(0, date_string_to_second("00:00:61"))
self.assertEqual(0, date_string_to_second("00:61:00"))
self.assertEqual(0, date_string_to_second("24:00:00"))
self.assertEqual(0, date_string_to_second("00:00:00"))
self.assertEqual(1, date_string_to_second("00:00:01"))
self.assertEqual(60, date_string_to_second("00:01:00"))
self.assertEqual(3600, date_string_to_second("01:00:00"))
self.assertEqual(3661, date_string_to_second("01:01:01"))
self.assertEqual(86399, date_string_to_second("23:59:59"))
print(" ---> test_utils date_string_to_second ok")

def test_get_event_id_and_broadcaster_id(self):
Expand Down
4 changes: 2 additions & 2 deletions pod/main/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_attributs(self):

def test_delete_object(self):
Configuration.objects.filter(key="maintenance_mode").delete()
self.assertEquals(Configuration.objects.filter(key="maintenance_mode").count(), 0)
self.assertEqual(Configuration.objects.filter(key="maintenance_mode").count(), 0)
print("---> test_delete_object of ConfigurationTestCase: OK!")


Expand Down Expand Up @@ -140,7 +140,7 @@ def test_attributs(self):

def test_delete_object(self):
AdditionalChannelTab.objects.filter(name="Tab0").delete()
self.assertEquals(AdditionalChannelTab.objects.filter(name="Tab0").count(), 0)
self.assertEqual(AdditionalChannelTab.objects.filter(name="Tab0").count(), 0)

print("---> test_delete_object of AdditionalChannelTabTestCase: OK!")

Expand Down
2 changes: 1 addition & 1 deletion pod/meeting/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_meeting_TestView_get_request_restrict(self):
self.user = User.objects.get(username="pod")
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEquals(response.context["access_not_allowed"], True)
self.assertEqual(response.context["access_not_allowed"], True)
self.user.is_staff = True
self.user.save()
response = self.client.get(url)
Expand Down
2 changes: 1 addition & 1 deletion pod/recorder/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def test_StudioPodTestView_get_request_restrict(self):
self.user = User.objects.get(username="pod")
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEquals(response.context["access_not_allowed"], True)
self.assertEqual(response.context["access_not_allowed"], True)
self.user.is_staff = True
self.user.save()
response = self.client.get(url)
Expand Down
2 changes: 1 addition & 1 deletion pod/video/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_Type_with_attributs(self) -> None:
def test_delete_object(self) -> None:
"""Test delete object."""
Type.objects.get(id=1).delete()
self.assertEquals(Type.objects.all().count(), 0)
self.assertEqual(Type.objects.all().count(), 0)
print(" ---> test_delete_object of TypeTestCase: OK!")


Expand Down
2 changes: 1 addition & 1 deletion pod/video/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ def test_video_edit_post_request(self) -> None:
self.assertTrue(b"The changes have been saved." in response.content)
v = Video.objects.get(title="VideoTest1")
p = re.compile(r"^videos/([\d\w]+)/file([_\d\w]*).mp4$")
self.assertRegexpMatches(v.video.name, p)
self.assertRegex(v.video.name, p)
# new one
videofile = SimpleUploadedFile(
"file.mp4", b"file_content", content_type="video/mp4"
Expand Down

0 comments on commit 8803f55

Please sign in to comment.