Esempio n. 1
0
    def test_list_reference_fields_cms_config_parameter(self):
        """CMS config with list of ints as reference_fields as it expects
        a list of tuples with two elements"""
        extensions = cms_config.ReferencesCMSExtension()
        mocked_cms_config = Mock(
            spec=[],
            djangocms_references_enabled=True,
            reference_fields=[1, 2],
            app_config=Mock(label="blah_cms_config"),
        )

        with self.assertRaises(ImproperlyConfigured):
            extensions.configure_app(mocked_cms_config)
Esempio n. 2
0
    def test_list_with_tuples_with_incorrect_number_of_elements_reference_fields_cms_config_parameter(
            self):
        """CMS config with list of tuples with three elements as it expects
        a list of tuples with two elements"""
        extensions = cms_config.ReferencesCMSExtension()
        mocked_cms_config = Mock(
            spec=[],
            djangocms_references_enabled=True,
            reference_fields=[(Child, "a field", "too many")],
            app_config=Mock(label="blah_cms_config"),
        )

        with self.assertRaises(ImproperlyConfigured):
            extensions.configure_app(mocked_cms_config)
Esempio n. 3
0
    def test_valid_cms_config_parameter(self):
        """CMS config with valid configuration"""
        extensions = cms_config.ReferencesCMSExtension()
        mocked_cms_config = Mock(
            spec=[],
            djangocms_references_enabled=True,
            reference_fields=[(Child, "parent")],
            app_config=Mock(label="blah_cms_config"),
        )

        extensions.configure_app(mocked_cms_config)
        reference_models = apps.get_app_config(
            "djangocms_references").cms_extension.reference_models

        self.assertTrue(Child not in reference_models.keys())
        self.assertTrue(Parent in reference_models.keys())
        self.assertTrue(Child in reference_models[Parent])
        self.assertTrue("parent" in reference_models[Parent][Child])