From f33afff50522260e1afea5270b6f6724f11ad893 Mon Sep 17 00:00:00 2001 From: Alvaro Mariano Date: Thu, 6 Jul 2023 20:54:22 +0000 Subject: [PATCH] Fix tests --- notifications/manage.py | 10 ++++++++++ notifications/tests/settings_for_tests.py | 2 +- notifications/tests/tests.py | 4 ++-- notifications/tests/urls_for_tests.py | 9 +++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 notifications/manage.py create mode 100644 notifications/tests/urls_for_tests.py diff --git a/notifications/manage.py b/notifications/manage.py new file mode 100644 index 0000000..1b2eeda --- /dev/null +++ b/notifications/manage.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python +""" Django notification manage file """ +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "notification.tests.settings_for_tests") + from django.core.management import execute_from_command_line + + execute_from_command_line(sys.argv) diff --git a/notifications/tests/settings_for_tests.py b/notifications/tests/settings_for_tests.py index e7418d4..5555433 100644 --- a/notifications/tests/settings_for_tests.py +++ b/notifications/tests/settings_for_tests.py @@ -30,7 +30,7 @@ INSTALLED_APPS = [ "notifications", ] -ROOT_URLCONF = "notifications.urls" +ROOT_URLCONF = "notifications.tests.urls_for_tests" STATIC_URL = "/static/" STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static"), diff --git a/notifications/tests/tests.py b/notifications/tests/tests.py index 25ed566..0353ad0 100644 --- a/notifications/tests/tests.py +++ b/notifications/tests/tests.py @@ -201,7 +201,7 @@ class NotificationTestPages(TestCase): def login(self, username, password): self.logout() - response = self.client.post(reverse("login"), {"username": username, "password": password}) + response = self.client.post(reverse("admin:login"), {"username": username, "password": password}) self.assertEqual(response.status_code, 302) return response @@ -504,7 +504,7 @@ class NotificationTestExtraData(TestCase): def login(self, username, password): self.logout() - response = self.client.post(reverse("login"), {"username": username, "password": password}) + response = self.client.post(reverse("admin:login"), {"username": username, "password": password}) self.assertEqual(response.status_code, 302) return response diff --git a/notifications/tests/urls_for_tests.py b/notifications/tests/urls_for_tests.py new file mode 100644 index 0000000..3969f87 --- /dev/null +++ b/notifications/tests/urls_for_tests.py @@ -0,0 +1,9 @@ +""" Django notification urls for tests """ +# -*- coding: utf-8 -*- +from django.contrib import admin +from django.urls import include, path + +urlpatterns = [ + path("admin/", admin.site.urls), + path("", include("notifications.urls", namespace="notifications")), +]