From 187e6abcba0d2511cb81795ec775b6c27dddcb43 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Sat, 10 Jun 2023 18:58:17 +0500 Subject: [PATCH 1/3] competition delete test added --- src/apps/api/tests/test_competitions.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apps/api/tests/test_competitions.py b/src/apps/api/tests/test_competitions.py index 7617dfbd2..df01d177b 100644 --- a/src/apps/api/tests/test_competitions.py +++ b/src/apps/api/tests/test_competitions.py @@ -75,6 +75,14 @@ def test_adding_organizer_accepts_them_if_they_were_existing_participant(self): status=CompetitionParticipant.APPROVED ).count() == 1 + def test_delete_own_competition(self): + + self.client.login(username='creator', password='creator') + url = reverse('competition-detail', kwargs={"pk": self.comp.pk}) + + resp = self.client.delete(url) + assert resp.status_code == 200 + class PhaseMigrationTests(APITestCase): def setUp(self): From 3470655f0f4415fe21cf43f9b428d34c76acc8a8 Mon Sep 17 00:00:00 2001 From: Ihsan Ullah Date: Sat, 10 Jun 2023 19:13:22 +0500 Subject: [PATCH 2/3] Delete competition test --- src/apps/api/tests/test_competitions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/apps/api/tests/test_competitions.py b/src/apps/api/tests/test_competitions.py index df01d177b..843db85bf 100644 --- a/src/apps/api/tests/test_competitions.py +++ b/src/apps/api/tests/test_competitions.py @@ -8,7 +8,7 @@ from rest_framework.test import APITestCase from api.serializers.competitions import CompetitionSerializer -from competitions.models import CompetitionParticipant, Submission +from competitions.models import CompetitionParticipant, Submission, Competition from factories import UserFactory, CompetitionFactory, CompetitionParticipantFactory, PhaseFactory, LeaderboardFactory, \ ColumnFactory, SubmissionFactory, SubmissionScoreFactory, TaskFactory @@ -81,7 +81,9 @@ def test_delete_own_competition(self): url = reverse('competition-detail', kwargs={"pk": self.comp.pk}) resp = self.client.delete(url) - assert resp.status_code == 200 + + assert resp.status_code == 204 + assert not Competition.objects.filter(pk=self.comp.pk).exists() class PhaseMigrationTests(APITestCase): From 2a2e6f3206567f41816bb2fa326aae8d8eb2629a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Pav=C3=A3o?= Date: Mon, 12 Jun 2023 14:42:24 +0200 Subject: [PATCH 3/3] Update test_competitions.py --- src/apps/api/tests/test_competitions.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/apps/api/tests/test_competitions.py b/src/apps/api/tests/test_competitions.py index 843db85bf..989f668f4 100644 --- a/src/apps/api/tests/test_competitions.py +++ b/src/apps/api/tests/test_competitions.py @@ -76,12 +76,9 @@ def test_adding_organizer_accepts_them_if_they_were_existing_participant(self): ).count() == 1 def test_delete_own_competition(self): - self.client.login(username='creator', password='creator') url = reverse('competition-detail', kwargs={"pk": self.comp.pk}) - resp = self.client.delete(url) - assert resp.status_code == 204 assert not Competition.objects.filter(pk=self.comp.pk).exists()