def test_version_admin_registered(self): """Integration test that for each content model there's a version proxy registered with the admin subclassing VersionAdmin """ setup_cms_apps() version_proxies = [ model for model in admin.site._registry if issubclass(model, Version) ] source_models_in_proxies = [ model._source_model for model in version_proxies ] source_model_to_proxy = dict( zip(source_models_in_proxies, version_proxies)) self.assertIn(PollContent, source_models_in_proxies) self.assertIn( VersionAdmin, admin.site._registry[ source_model_to_proxy[PollContent]].__class__.mro()) self.assertIn(BlogContent, source_models_in_proxies) self.assertIn( VersionAdmin, admin.site._registry[ source_model_to_proxy[BlogContent]].__class__.mro()) self.assertNotIn(Comment, source_models_in_proxies)
def test_config_with_two_apps(self): setup_cms_apps() moderation_config = apps.get_app_config("djangocms_moderation") registered_model = moderation_config.cms_extension.moderated_models for model in self.moderated_models: self.assertIn(model, registered_model) self.assertEqual(len(registered_model), 7)
def test_search_config_with_expected_attributes(self): setup_cms_apps() internalsearch_config = apps.get_app_config('djangocms_internalsearch') registered_configs = internalsearch_config.cms_extension.internalsearch_apps_config expected_attributes = ['model', 'list_display'] with self.assertNotRaises(NotImplementedError): for config in registered_configs: for attr in expected_attributes: self.assertTrue(hasattr(config, attr))
def test_search_config_with_expected_method(self): setup_cms_apps() internalsearch_config = apps.get_app_config('djangocms_internalsearch') registered_configs = internalsearch_config.cms_extension.internalsearch_apps_config expected_method = ['prepare_text', ] with self.assertNotRaises(NotImplementedError): for config in registered_configs: for attr in expected_method: self.assertTrue(hasattr(config, attr))
def test_all_versionables_collected(self): """Check that all version models defined in cms_config.py are collected into a list """ setup_cms_apps() # discover and run all cms_config.py files app = apps.get_app_config('djangocms_versioning') poll_versionable = PollsCMSConfig.versioning[0] blog_versionable = BlogpostCMSConfig.versioning[0] comment_versionable = BlogpostCMSConfig.versioning[1] self.assertListEqual( app.cms_extension.versionables, [poll_versionable, blog_versionable, comment_versionable])
def test_config_with_two_apps(self): setup_cms_apps() internalsearch_config = apps.get_app_config("djangocms_internalsearch") registered_models = [ config.model for config in internalsearch_config.cms_extension.internalsearch_apps_config ] expected_models = [ config.model for config in inheritors(BaseSearchConfig) if isinstance(config.model, ModelBase) ] self.assertCountEqual(registered_models, expected_models)
def test_config_with_two_apps(self): setup_cms_apps() contentexpiry_config = apps.get_app_config('djangocms_contentexpiry') registered_models = contentexpiry_config.cms_extension.contentexpiry_apps_models expected_models = [ TestModel1, TestModel2, TestModel3, TestModel4, ] self.assertCountEqual(registered_models, expected_models)
def test_admin_classes_reregistered(self): """Integration test that all content models that are registered with the admin have their admin class overridden with a subclass of VersioningAdminMixin """ setup_cms_apps() # discover and run all cms_config.py files # Check PollContent has had its admin class modified self.assertIn(PollContent, admin.site._registry) self.assertIn(VersioningAdminMixin, admin.site._registry[PollContent].__class__.mro()) # Check BlogContent has had its admin class modified self.assertIn(BlogContent, admin.site._registry) self.assertIn(VersioningAdminMixin, admin.site._registry[BlogContent].__class__.mro()) # Check that Comments were not registered to the admin # (they are defined in cms_config.py but are not registered # to the admin) self.assertNotIn(Comment, admin.site._registry)