Exemplo n.º 1
0
    def test_missing_cms_config_url_manager_supported_models_attribute(self):
        """Tests, if the url_manager_supported_models attribute has not been specified,
        an ImproperlyConfigured exception is raised
        """
        from djangocms_url_manager.cms_config import UrlManagerCMSExtension

        extensions = UrlManagerCMSExtension()
        cms_config = Mock(spec=[], djangocms_url_manager_enabled=True)
        with self.assertRaises(ImproperlyConfigured):
            extensions.handle_url_manager_setting(cms_config)
Exemplo n.º 2
0
    def test_url_manager_supported_model(self):
        from djangocms_url_manager.cms_config import UrlManagerCMSExtension

        extensions = UrlManagerCMSExtension()
        cms_config = Mock(
            spec=[],
            djangocms_url_manager_enabled=True,
            url_manager_supported_models=[PollContent],
        )
        extensions.handle_url_manager_setting(cms_config)
        self.assertDictEqual(
            supported_models(), {Page: None, PollContent: get_all_poll_content_objects}
        )
Exemplo n.º 3
0
 def test_emit_warning_when_duplicated_models(self):
     """Tests if Warning is emitted when in cms_config
     url_manager_supported_models are duplicated models
     """
     from djangocms_url_manager.cms_config import UrlManagerCMSExtension
     extensions = UrlManagerCMSExtension()
     cms_config = Mock(
         spec=[],
         djangocms_url_manager_enabled=True,
         url_manager_supported_models=[PollContent, PollContent]
     )
     with self.assertRaises(ImproperlyConfigured):
         extensions.handle_url_manager_setting(cms_config)
Exemplo n.º 4
0
 def test_raises_exception_if_url_manager_supported_models_model_does_not_have_url_method(self):
     """Tests ImproperlyConfigured exception is raised if a
     model does not have get_absolute_url implemented
     """
     from djangocms_url_manager.cms_config import UrlManagerCMSExtension
     extensions = UrlManagerCMSExtension()
     cms_config = Mock(
         spec=[],
         djangocms_url_manager_enabled=True,
         url_manager_supported_models=[Poll]
     )
     with self.assertRaises(ImproperlyConfigured):
         extensions.handle_url_manager_setting(cms_config)
Exemplo n.º 5
0
 def test_raises_exception_if_url_manager_supported_models_item_is_not_model_class(self):
     """Tests ImproperlyConfigured exception is raised if elements
     in the url_manager_supported_models list are not valid django models class.
     """
     from djangocms_url_manager.cms_config import UrlManagerCMSExtension
     extensions = UrlManagerCMSExtension()
     cms_config = Mock(
         spec=[],
         djangocms_url_manager_enabled=True,
         url_manager_supported_models=['aaa', {}]
     )
     with self.assertRaises(ImproperlyConfigured):
         extensions.handle_url_manager_setting(cms_config)
Exemplo n.º 6
0
 def test_raises_exception_if_url_manager_supported_models_is_not_list(self):
     """Tests ImproperlyConfigured exception is raised if
     url_manager_supported_models setting is not a list
     """
     from djangocms_url_manager.cms_config import UrlManagerCMSExtension
     extensions = UrlManagerCMSExtension()
     cms_config = Mock(
         spec=[],
         djangocms_url_manager_enabled=True,
         url_manager_supported_models=PollContent
     )
     with self.assertRaises(ImproperlyConfigured):
         extensions.handle_url_manager_setting(cms_config)
Exemplo n.º 7
0
    def test_url_manager_search_helpers(self):
        from djangocms_url_manager.cms_config import UrlManagerCMSExtension

        extensions = UrlManagerCMSExtension()
        cms_config = Mock(spec=[],
                          djangocms_url_manager_enabled=True,
                          url_manager_supported_models=[PollContent],
                          url_manager_supported_models_search_helpers=[
                              get_poll_search_results
                          ])
        extensions.handle_url_manager_setting(cms_config)

        self.assertDictEqual(supported_models_search_helpers(), {
            Page: get_page_search_results,
            PollContent: get_poll_search_results
        })