From dcd592ed117bf001f717dcba68aca14a5ed4be1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sun, 30 Aug 2020 18:49:22 +0200 Subject: [PATCH] Fix 100 tests wrt. 754a0b70e (big url changes) --- bda/tests/test_views.py | 24 ++++++++------- gestioncof/tests/test_views.py | 52 +++++++++++++++++---------------- kfet/auth/tests.py | 6 ++-- kfet/tests/test_statistic.py | 2 +- kfet/tests/test_views.py | 24 +++++++++++---- kfet/tests/testcases.py | 2 +- petitscours/tests/test_views.py | 14 ++++----- 7 files changed, 70 insertions(+), 54 deletions(-) diff --git a/bda/tests/test_views.py b/bda/tests/test_views.py index 7082725c..b223203f 100644 --- a/bda/tests/test_views.py +++ b/bda/tests/test_views.py @@ -29,7 +29,7 @@ class InscriptionViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/inscription/{}".format(self.tirage.id) + return "/gestion/bda/inscription/{}".format(self.tirage.id) def test_get_opened(self): self.tirage.ouverture = timezone.now() - timedelta(days=1) @@ -149,7 +149,7 @@ class PlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/places/{}".format(self.tirage.id) + return "/gestion/bda/places/{}".format(self.tirage.id) class EtatPlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @@ -166,7 +166,7 @@ class EtatPlacesViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/etat-places/{}".format(self.tirage.id) + return "/gestion/bda/etat-places/{}".format(self.tirage.id) class TirageViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @@ -185,7 +185,7 @@ class TirageViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/tirage/{}".format(self.tirage.id) + return "/gestion/bda/tirage/{}".format(self.tirage.id) def test_perform_tirage_disabled(self): # Cannot be performed if disabled @@ -225,7 +225,7 @@ class SpectacleListViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/spectacles/{}".format(self.tirage.id) + return "/gestion/bda/spectacles/{}".format(self.tirage.id) class SpectacleViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @@ -242,7 +242,7 @@ class SpectacleViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/spectacles/{}/{}".format(self.tirage.id, self.show1.id) + return "/gestion/bda/spectacles/{}/{}".format(self.tirage.id, self.show1.id) class UnpaidViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @@ -259,7 +259,7 @@ class UnpaidViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/spectacles/unpaid/{}".format(self.tirage.id) + return "/gestion/bda/spectacles/unpaid/{}".format(self.tirage.id) class SendRemindersViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @@ -276,7 +276,7 @@ class SendRemindersViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/bda/mails-rappel/{}".format(self.show1.id) + return "/gestion/bda/mails-rappel/{}".format(self.show1.id) def test_post(self): self.require_custommails() @@ -292,7 +292,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): bda_testdata = True def test_api_list(self): - url_list = "/bda/catalogue/list" + url_list = "/gestion/bda/catalogue/list" resp = self.client.get(url_list) self.assertJSONEqual( resp.content.decode("utf-8"), @@ -300,7 +300,7 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): ) def test_api_details(self): - url_details = "/bda/catalogue/details?id={}".format(self.tirage.id) + url_details = "/gestion/bda/catalogue/details?id={}".format(self.tirage.id) resp = self.client.get(url_details) self.assertJSONEqual( resp.content.decode("utf-8"), @@ -311,7 +311,9 @@ class CatalogueViewTestCase(BdATestHelpers, BdAViewTestCaseMixin, TestCase): ) def test_api_descriptions(self): - url_descriptions = "/bda/catalogue/descriptions?id={}".format(self.tirage.id) + url_descriptions = "/gestion/bda/catalogue/descriptions?id={}".format( + self.tirage.id + ) resp = self.client.get(url_descriptions) raw = resp.content.decode("utf-8") try: diff --git a/gestioncof/tests/test_views.py b/gestioncof/tests/test_views.py index 682d85f2..ea51c509 100644 --- a/gestioncof/tests/test_views.py +++ b/gestioncof/tests/test_views.py @@ -26,7 +26,7 @@ User = get_user_model() class RegistrationViewTests(ViewTestCaseMixin, TestCase): url_name = "registration" - url_expected = "/registration/" + url_expected = "/gestion/registration/" http_methods = ["GET", "POST"] @@ -210,16 +210,16 @@ class RegistrationViewTests(ViewTestCaseMixin, TestCase): class RegistrationFormViewTests(ViewTestCaseMixin, TestCase): urls_conf = [ - {"name": "empty-registration", "expected": "/registration/empty"}, + {"name": "empty-registration", "expected": "/gestion/registration/empty"}, { "name": "user-registration", "kwargs": {"username": "user"}, - "expected": "/registration/user/user", + "expected": "/gestion/registration/user/user", }, { "name": "clipper-registration", "kwargs": {"login_clipper": "uid", "fullname": "First Last1 Last2"}, - "expected": "/registration/clipper/uid/First%20Last1%20Last2", + "expected": "/gestion/registration/clipper/uid/First%20Last1%20Last2", }, ] @@ -269,7 +269,7 @@ class RegistrationFormViewTests(ViewTestCaseMixin, TestCase): @override_settings(LDAP_SERVER_URL="ldap_url") class RegistrationAutocompleteViewTests(MockLDAPMixin, ViewTestCaseMixin, TestCase): url_name = "cof.registration.autocomplete" - url_expected = "/registration/autocomplete" + url_expected = "/gestion/registration/autocomplete" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -360,7 +360,7 @@ class RegistrationAutocompleteViewTests(MockLDAPMixin, ViewTestCaseMixin, TestCa class HomeViewTests(ViewTestCaseMixin, TestCase): url_name = "home" - url_expected = "/" + url_expected = "/gestion/" auth_user = "user" auth_forbidden = [None] @@ -372,7 +372,7 @@ class HomeViewTests(ViewTestCaseMixin, TestCase): class ProfileViewTests(ViewTestCaseMixin, TestCase): url_name = "profile" - url_expected = "/profile" + url_expected = "/gestion/profile" http_methods = ["GET", "POST"] @@ -413,7 +413,7 @@ class ProfileViewTests(ViewTestCaseMixin, TestCase): class UtilsViewTests(ViewTestCaseMixin, TestCase): url_name = "utile_cof" - url_expected = "/utile_cof" + url_expected = "/gestion/utile_cof" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -425,7 +425,7 @@ class UtilsViewTests(ViewTestCaseMixin, TestCase): class MailingListDiffCof(ViewTestCaseMixin, TestCase): url_name = "ml_diffcof" - url_expected = "/utile_cof/diff_cof" + url_expected = "/gestion/utile_cof/diff_cof" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -446,7 +446,7 @@ class MailingListDiffCof(ViewTestCaseMixin, TestCase): class ConfigUpdateViewTests(ViewTestCaseMixin, TestCase): url_name = "config.edit" - url_expected = "/config" + url_expected = "/gestion/config" http_methods = ["GET", "POST"] @@ -468,7 +468,7 @@ class ConfigUpdateViewTests(ViewTestCaseMixin, TestCase): class UserAutocompleteViewTests(ViewTestCaseMixin, TestCase): url_name = "cof-user-autocomplete" - url_expected = "/user/autocomplete" + url_expected = "/gestion/user/autocomplete" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -481,7 +481,7 @@ class UserAutocompleteViewTests(ViewTestCaseMixin, TestCase): class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase): url_name = "export.members" - url_expected = "/export/members" + url_expected = "/gestion/export/members" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -521,7 +521,7 @@ class ExportMembersViewTests(CSVResponseMixin, ViewTestCaseMixin, TestCase): class ExportMegaViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): url_name = "export.mega.all" - url_expected = "/export/mega/all" + url_expected = "/gestion/export/mega/all" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -550,7 +550,7 @@ class ExportMegaViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): class ExportMegaOrgasViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): url_name = "export.mega.orgas" - url_expected = "/export/mega/orgas" + url_expected = "/gestion/export/mega/orgas" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -579,7 +579,7 @@ class ExportMegaOrgasViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): class ExportMegaParticipantsViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): url_name = "export.mega.participants" - url_expected = "/export/mega/participants" + url_expected = "/gestion/export/mega/participants" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -596,7 +596,7 @@ class ExportMegaParticipantsViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCa class ExportMegaRemarksViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): url_name = "export.mega.remarks" - url_expected = "/export/mega/avecremarques" + url_expected = "/gestion/export/mega/avecremarques" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -624,7 +624,7 @@ class ExportMegaRemarksViewTests(MegaHelperMixin, ViewTestCaseMixin, TestCase): class ClubListViewTests(ViewTestCaseMixin, TestCase): url_name = "liste-clubs" - url_expected = "/clubs/liste" + url_expected = "/gestion/clubs/liste" auth_user = "member" auth_forbidden = [None, "user"] @@ -671,7 +671,7 @@ class ClubMembersViewTests(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/clubs/membres/{}".format(self.c.name) + return "/gestion/clubs/membres/{}".format(self.c.name) def setUp(self): super().setUp() @@ -712,7 +712,9 @@ class ClubChangeRespoViewTests(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/clubs/change_respo/{}/{}".format(self.c.name, self.users["user"].pk) + return "/gestion/clubs/change_respo/{}/{}".format( + self.c.name, self.users["user"].pk + ) def setUp(self): super().setUp() @@ -734,7 +736,7 @@ class ClubChangeRespoViewTests(ViewTestCaseMixin, TestCase): class CalendarViewTests(ViewTestCaseMixin, TestCase): url_name = "calendar" - url_expected = "/calendar/subscription" + url_expected = "/gestion/calendar/subscription" auth_user = "member" auth_forbidden = [None, "user"] @@ -801,7 +803,7 @@ class CalendarICSViewTests(ICalMixin, ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/calendar/{}/calendar.ics".format(self.token) + return "/gestion/calendar/{}/calendar.ics".format(self.token) def setUp(self): super().setUp() @@ -917,7 +919,7 @@ class EventViewTests(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/event/{}".format(self.e.pk) + return "/gestion/event/{}".format(self.e.pk) def setUp(self): super().setUp() @@ -1002,7 +1004,7 @@ class EventStatusViewTests(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/event/{}/status".format(self.e.pk) + return "/gestion/event/{}/status".format(self.e.pk) def setUp(self): super().setUp() @@ -1068,7 +1070,7 @@ class SurveyViewTests(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/survey/{}".format(self.s.pk) + return "/gestion/survey/{}".format(self.s.pk) def setUp(self): super().setUp() @@ -1168,7 +1170,7 @@ class SurveyStatusViewTests(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/survey/{}/status".format(self.s.pk) + return "/gestion/survey/{}/status".format(self.s.pk) def setUp(self): super().setUp() diff --git a/kfet/auth/tests.py b/kfet/auth/tests.py index 9006612c..6fb1125e 100644 --- a/kfet/auth/tests.py +++ b/kfet/auth/tests.py @@ -168,7 +168,7 @@ class GenericLoginViewTests(TestCase): r = self.client.post(self.url) self.assertRedirects( - r, "/logout?next={}".format(self.url), fetch_redirect_response=False + r, "/gestion/logout?next={}".format(self.url), fetch_redirect_response=False ) def test_notoken_not_team(self): @@ -180,13 +180,13 @@ class GenericLoginViewTests(TestCase): # With GET. r = self.client.get(self.url) self.assertRedirects( - r, "/login?next={}".format(self.url), fetch_redirect_response=False + r, "/gestion/login?next={}".format(self.url), fetch_redirect_response=False ) # Also with POST. r = self.client.post(self.url) self.assertRedirects( - r, "/login?next={}".format(self.url), fetch_redirect_response=False + r, "/gestion/login?next={}".format(self.url), fetch_redirect_response=False ) def _set_signed_cookie(self, client, key, value): diff --git a/kfet/tests/test_statistic.py b/kfet/tests/test_statistic.py index a5e3192c..5b5209cc 100644 --- a/kfet/tests/test_statistic.py +++ b/kfet/tests/test_statistic.py @@ -70,4 +70,4 @@ class TestStats(TestCase): resp = client.get(url) self.assertEqual(200, resp.status_code) resp2 = client2.get(url, follow=True) - self.assertRedirects(resp2, "/") + self.assertRedirects(resp2, "/gestion/") diff --git a/kfet/tests/test_views.py b/kfet/tests/test_views.py index 9a9ad871..e24d52b5 100644 --- a/kfet/tests/test_views.py +++ b/kfet/tests/test_views.py @@ -230,7 +230,9 @@ class AccountReadViewTests(ViewTestCaseMixin, TestCase): if user is None: response = client.get(url) self.assertRedirects( - response, "/login?next={}".format(url), fetch_redirect_response=False + response, + "/gestion/login?next={}".format(url), + fetch_redirect_response=False, ) else: client.login(username=user, password=user) @@ -340,7 +342,9 @@ class AccountUpdateViewTests(ViewTestCaseMixin, TestCase): if user is None: response = meth(url) self.assertRedirects( - response, "/login?next={}".format(url), fetch_redirect_response=False + response, + "/gestion/login?next={}".format(url), + fetch_redirect_response=False, ) else: client.login(username=user, password=user) @@ -620,7 +624,9 @@ class AccountStatOperationListViewTests(ViewTestCaseMixin, TestCase): if user is None: response = client.get(url) self.assertRedirects( - response, "/login?next={}".format(url), fetch_redirect_response=False + response, + "/gestion/login?next={}".format(url), + fetch_redirect_response=False, ) else: client.login(username=user, password=user) @@ -716,7 +722,9 @@ class AccountStatOperationViewTests(ViewTestCaseMixin, TestCase): if user is None: response = client.get(url) self.assertRedirects( - response, "/login?next={}".format(url), fetch_redirect_response=False + response, + "/gestion/login?next={}".format(url), + fetch_redirect_response=False, ) else: client.login(username=user, password=user) @@ -753,7 +761,9 @@ class AccountStatBalanceListViewTests(ViewTestCaseMixin, TestCase): if user is None: response = client.get(url) self.assertRedirects( - response, "/login?next={}".format(url), fetch_redirect_response=False + response, + "/gestion/login?next={}".format(url), + fetch_redirect_response=False, ) else: client.login(username=user, password=user) @@ -817,7 +827,9 @@ class AccountStatBalanceViewTests(ViewTestCaseMixin, TestCase): if user is None: response = client.get(url) self.assertRedirects( - response, "/login?next={}".format(url), fetch_redirect_response=False + response, + "/gestion/login?next={}".format(url), + fetch_redirect_response=False, ) else: client.login(username=user, password=user) diff --git a/kfet/tests/testcases.py b/kfet/tests/testcases.py index 95b48d42..4912023e 100644 --- a/kfet/tests/testcases.py +++ b/kfet/tests/testcases.py @@ -39,7 +39,7 @@ class TestCaseMixin: querystring = QueryDict(mutable=True) querystring["next"] = full_path - login_url = "/login?" + querystring.urlencode(safe="/") + login_url = "/gestion/login?" + querystring.urlencode(safe="/") # We don't focus on what the login view does. # So don't fetch the redirect. diff --git a/petitscours/tests/test_views.py b/petitscours/tests/test_views.py index 3ef68a5a..6cf520a2 100644 --- a/petitscours/tests/test_views.py +++ b/petitscours/tests/test_views.py @@ -19,7 +19,7 @@ User = get_user_model() class PetitCoursDemandeListViewTestCase(ViewTestCaseMixin, TestCase): url_name = "petits-cours-demandes-list" - url_expected = "/petitcours/demandes" + url_expected = "/gestion/petitcours/demandes" auth_user = "staff" auth_forbidden = [None, "user", "member"] @@ -48,7 +48,7 @@ class PetitCoursDemandeDetailListViewTestCase(ViewTestCaseMixin, TestCase): @property def url_expected(self): - return "/petitcours/demandes/{}".format(self.demande.pk) + return "/gestion/petitcours/demandes/{}".format(self.demande.pk) def setUp(self): super().setUp() @@ -61,7 +61,7 @@ class PetitCoursDemandeDetailListViewTestCase(ViewTestCaseMixin, TestCase): class PetitCoursInscriptionViewTestCase(ViewTestCaseMixin, TestCase): url_name = "petits-cours-inscription" - url_expected = "/petitcours/inscription" + url_expected = "/gestion/petitcours/inscription" http_methods = ["GET", "POST"] @@ -176,7 +176,7 @@ class PetitCoursTraitementViewTestCase( @property def url_expected(self): - return "/petitcours/demandes/{}/traitement".format(self.demande.pk) + return "/gestion/petitcours/demandes/{}/traitement".format(self.demande.pk) def setUp(self): super().setUp() @@ -246,7 +246,7 @@ class PetitCoursRetraitementViewTestCase( @property def url_expected(self): - return "/petitcours/demandes/{}/retraitement".format(self.demande.pk) + return "/gestion/petitcours/demandes/{}/retraitement".format(self.demande.pk) def setUp(self): super().setUp() @@ -261,7 +261,7 @@ class PetitCoursRetraitementViewTestCase( class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase): url_name = "petits-cours-demande" - url_expected = "/petitcours/demande" + url_expected = "/gestion/petitcours/demande" http_methods = ["GET", "POST"] @@ -303,7 +303,7 @@ class PetitCoursDemandeViewTestCase(ViewTestCaseMixin, TestCase): class PetitCoursDemandeRawViewTestCase(ViewTestCaseMixin, TestCase): url_name = "petits-cours-demande-raw" - url_expected = "/petitcours/demande-raw" + url_expected = "/gestion/petitcours/demande-raw" http_methods = ["GET", "POST"]