-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Introduced app registration system #6421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4f4139e
7db2fc9
0394871
0ee728e
f79f575
f329f22
b5f1825
5b88aa1
c9f064d
e53eac3
f2299db
2416687
ec35c49
5968fc9
c1b606e
367e49f
31d767d
d908a66
093408c
263c1c5
741a803
bcc02f4
e64a652
6a55666
9f3f6f2
6e683d9
0850fd1
2055642
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,8 +95,22 @@ def get_urls(self, page=None, language=None, **kwargs): | |
return self._urls | ||
|
||
|
||
class CMSAppConfig(): | ||
class CMSAppConfig(object): | ||
"""Base class that all cms app configurations should inherit from""" | ||
|
||
def configure_app(self, app): | ||
""" | ||
Implement this method if the app provides functionality that | ||
other apps can use and configure. | ||
|
||
This method will be run once for every app that defines an | ||
attribute like "<app_label>_enabled" as True on its cms app | ||
config class. | ||
So for example if app A with label "app_a" implements this | ||
method and app B and app C define app_a_enabled = True on their | ||
cms config classes, the method app A has defined will run twice, | ||
once for app B and once for app C. | ||
|
||
:param app: django app that has defined the feature as enabled | ||
""" | ||
raise NotImplementedError() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when not passing arguments, raise |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_using_non_feature.apps.NonFeatureCMSConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_with_bad_cms_file.apps.BadCMSFileConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_with_cms_config.apps.CMSConfigConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_with_cms_feature.apps.CMSFeatureConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_with_two_cms_app_classes.apps.TwoCMSAppClassesConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_without_cms_app_class.apps.WithoutCMSAppClassConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'cms.test_utils.project.app_without_cms_file.apps.WithoutCMSFileConfig' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
class AutodiscoverTestCase(CMSTestCase): | ||
|
||
@override_settings(INSTALLED_APPS=[ | ||
'cms.tests.test_app_registry.app_with_cms_feature', | ||
'cms.tests.test_app_registry.app_without_cms_file' | ||
'cms.test_utils.project.app_with_cms_feature', | ||
'cms.test_utils.project.app_without_cms_file' | ||
]) | ||
def test_adds_cms_app_attribute_to_django_app_config(self): | ||
app_registration.autodiscover_cms_configs() | ||
|
@@ -30,7 +30,7 @@ def test_adds_cms_app_attribute_to_django_app_config(self): | |
self.assertFalse(hasattr(app_list[1], 'cms_app')) | ||
|
||
@override_settings(INSTALLED_APPS=[ | ||
'cms.tests.test_app_registry.app_with_bad_cms_file', | ||
'cms.test_utils.project.app_with_bad_cms_file', | ||
]) | ||
def test_raises_exception_raised_in_cms_file(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename to |
||
# The cms file intentionally raises a KeyError. We need | ||
|
@@ -40,15 +40,15 @@ def test_raises_exception_raised_in_cms_file(self): | |
app_registration.autodiscover_cms_configs() | ||
|
||
@override_settings(INSTALLED_APPS=[ | ||
'cms.tests.test_app_registry.app_without_cms_app_class', | ||
'cms.test_utils.project.app_without_cms_app_class', | ||
]) | ||
def test_raises_exception_when_no_cms_app_class_found_in_cms_file(self): | ||
# No cms config defined in the cms file so raise exception | ||
with self.assertRaises(ImproperlyConfigured): | ||
app_registration.autodiscover_cms_configs() | ||
|
||
@override_settings(INSTALLED_APPS=[ | ||
'cms.tests.test_app_registry.app_with_two_cms_app_classes', | ||
'cms.test_utils.project.app_with_two_cms_app_classes', | ||
]) | ||
def test_raises_exception_when_more_than_one_cms_app_class_found_in_cms_file(self): | ||
# More than one cms config defined so raise exception | ||
|
@@ -226,9 +226,9 @@ def test_setup_cms_apps_function_run_on_startup(self, mocked_setup): | |
mocked_setup.assert_called_once() | ||
|
||
@override_settings(INSTALLED_APPS=[ | ||
'cms.tests.test_app_registry.app_with_cms_feature', | ||
'cms.tests.test_app_registry.app_without_cms_file', | ||
'cms.tests.test_app_registry.app_with_cms_config' | ||
'cms.test_utils.project.app_with_cms_feature', | ||
'cms.test_utils.project.app_without_cms_file', | ||
'cms.test_utils.project.app_with_cms_config' | ||
]) | ||
def test_cms_apps_setup_after_setup_function_run(self): | ||
# This is the function that gets run on startup | ||
|
@@ -253,8 +253,8 @@ def test_cms_apps_setup_after_setup_function_run(self): | |
self.assertTrue(config_app.cms_app.configured) | ||
|
||
@override_settings(INSTALLED_APPS=[ | ||
'cms.tests.test_app_registry.app_with_cms_config', | ||
'cms.tests.test_app_registry.app_using_non_feature' | ||
'cms.test_utils.project.app_with_cms_config', | ||
'cms.test_utils.project.app_using_non_feature' | ||
]) | ||
def test_raises_not_implemented_exception_when_feature_app_doesnt_implement_configure_method(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be shortened to test_raises_not_implemented_exception and the rest explained in comment |
||
with self.assertRaises(NotImplementedError): | ||
|
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
param is now
cms_config