Skip to content

Commit

Permalink
Adds a check for CMSApps without name and test
Browse files Browse the repository at this point in the history
  • Loading branch information
halitcelik committed Nov 4, 2024
1 parent 2152f52 commit 0b838ac
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cms/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
12 changes: 12 additions & 0 deletions cms/utils/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0b838ac

Please sign in to comment.