Exemplo n.º 1
0
 def test_configure_basic(self):
     user = self.model_dependencies["user"]
     blank_conf = EditRegionConfiguration()
     blank_conf.configure(obj=user)
     self.assertEqual(blank_conf.obj, user)
     self.assertTrue(blank_conf.has_configuration)
     self.assertEqual(blank_conf.config, {})
Exemplo n.º 2
0
 def test_configure_template_discovered(self):
     """
     We can't test for the Template instance directly, as it's no longer
     exposed on the object.
     Given the template `sample_editregion_template.html` has nothing in it,
     the config should become an empty dict.
     """
     user = self.model_dependencies["user"]
     blank_conf = EditRegionConfiguration()
     blank_conf.configure(obj=user)
     self.assertEqual({}, blank_conf.config)
Exemplo n.º 3
0
    def test_configure_template_not_discovered(self):
        user = self.model_dependencies["user"]
        blank_conf = EditRegionConfiguration()

        try:
            admin.site.unregister(User)
        except NotRegistered:
            pass
        admin.site.register(User, TestBadUserAdmin)

        with self.settings(DEBUG=True):
            with self.assertRaises(TemplateDoesNotExist):
                blank_conf.configure(obj=user)

        with self.settings(DEBUG=False):
            blank_conf.configure(obj=user)
            self.assertFalse(blank_conf.has_configuration)