From 0b838ac5de257aa7715237f4e604435e284aad91 Mon Sep 17 00:00:00 2001 From: Halit Celik Date: Mon, 4 Nov 2024 10:24:26 +0100 Subject: [PATCH] Adds a check for CMSApps without name and test --- cms/tests/test_check.py | 11 +++++++++++ cms/utils/check.py | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/cms/tests/test_check.py b/cms/tests/test_check.py index cd906819bb5..543b6626ef2 100644 --- a/cms/tests/test_check.py +++ b/cms/tests/test_check.py @@ -135,6 +135,17 @@ def test_non_numeric_site_id(self): with self.settings(SITE_ID='broken'): self.assertCheck(False, warnings=0, errors=1) + def test_cmsapps_check(self): + from cms.app_base import CMSApp + from cms.apphook_pool import apphook_pool + class AppWithoutName(CMSApp): + def get_urls(self, page=None, language=None, **kwargs): + return ["sampleapp.urls"] + + app = apphook_pool.register(AppWithoutName) + + self.assertCheck(True, warnings=1, errors=0) + apphook_pool.apps.pop(app.__name__) class CheckWithDatabaseTests(CheckAssertMixin, TestCase): diff --git a/cms/utils/check.py b/cms/utils/check.py index e46557f84c3..9de52e417e3 100644 --- a/cms/utils/check.py +++ b/cms/utils/check.py @@ -371,6 +371,18 @@ def check_template_conf(output): "Will run in headless mode with one placeholder called \"content\"") +@define_check +def check_cmsapps_names(output): + from cms.apphook_pool import apphook_pool + with output.section("Apphooks") as section: + for hook, name in apphook_pool.get_apphooks(): + if apphook_pool.get_apphook(hook).name is None: + section.warn("CMSApps should define a name. %s doesn't have a name" % name) + if section.successful: + section.finish_success("CMSApps configuration is okay") + + + def check(output): """ Checks the configuration/environment of this django CMS installation.