コード例 #1
0
class FormPluginTests(TestCase):
    def setUp(self):
        # create a placeholder
        self.placeholder = Placeholder(slot=u"some_slot")

        # create a fake context and request
        request = HttpRequest()
        self.context = {"request": request}

        # create a form
        self.form = FormDefinition(name="testform")
        self.form.save()

        # add the plugin
        self.plugin = add_plugin(self.placeholder,
                                 u"FormDesignerPlugin",
                                 u"en",
                                 form_definition=self.form)
        self.plugin.save()

    def test_default_plugin_template(self):
        instance = self.plugin.get_plugin_instance()[1]
        self.assertEquals(
            instance.render(self.context, self.plugin,
                            self.placeholder)["form_template_name"],
            settings.DEFAULT_FORM_TEMPLATE)

    def test_custom_plugin_template(self):
        self.form.form_template_name = "html/formdefinition/forms/custom.html"
        instance = self.plugin.get_plugin_instance()[1]
        self.assertEquals(
            instance.render(self.context, self.plugin,
                            self.placeholder)["form_template_name"],
            "html/formdefinition/forms/custom.html")
コード例 #2
0
class FormViewTests(TestCase):
    def setUp(self):
        # create a form
        self.form = FormDefinition(name="testform")
        self.form.save()

    def test_default_form_template(self):
        response = self.client.get("/forms/testform/")
        self.assertEquals(response.context["form_template_name"],
                          settings.DEFAULT_FORM_TEMPLATE)

    def test_custom_form_template(self):
        self.form.form_template_name = "html/formdefinition/forms/custom.html"
        self.form.save()
        response = self.client.get("/forms/testform/")
        self.assertEquals(response.context["form_template_name"],
                          "html/formdefinition/forms/custom.html")
コード例 #3
0
    def setUp(self):
        # create a placeholder
        self.placeholder = Placeholder(slot=u"some_slot")

        # create a fake context and request
        request = HttpRequest()
        self.context = {"request": request}

        # create a form
        self.form = FormDefinition(name="testform")
        self.form.save()

        # add the plugin
        self.plugin = add_plugin(self.placeholder,
                                 u"FormDesignerPlugin",
                                 u"en",
                                 form_definition=self.form)
        self.plugin.save()
コード例 #4
0
class FormViewTests(TestCase):
    def setUp(self):
        # create a form
        self.form = FormDefinition(name = "testform")
        self.form.save()

    def test_default_form_template(self):
        response = self.client.get("/forms/testform/")   
        self.assertEquals(
            response.context["form_template_name"], 
            settings.DEFAULT_FORM_TEMPLATE
            ) 

    def test_custom_form_template(self):
        self.form.form_template_name = "html/formdefinition/forms/custom.html"
        self.form.save()
        response = self.client.get("/forms/testform/")   
        self.assertEquals(
            response.context["form_template_name"], 
            "html/formdefinition/forms/custom.html"
            ) 
コード例 #5
0
class FormPluginTests(TestCase):
    def setUp(self):
        # create a placeholder
        self.placeholder = Placeholder(slot=u"some_slot")

        # create a fake context and request
        request = HttpRequest()
        self.context = {"request": request}

        # create a form
        self.form = FormDefinition(name = "testform")
        self.form.save()

        # add the plugin
        self.plugin = add_plugin(
            self.placeholder, 
            u"FormDesignerPlugin", 
            u"en",
            form_definition=self.form
            )
        self.plugin.save()

    def test_default_plugin_template(self):
        instance = self.plugin.get_plugin_instance()[1] 
        self.assertEquals(
            instance.render(self.context, self.plugin, self.placeholder)["form_template_name"], 
            settings.DEFAULT_FORM_TEMPLATE
            ) 
        
    def test_custom_plugin_template(self):
        self.form.form_template_name = "html/formdefinition/forms/custom.html"
        instance = self.plugin.get_plugin_instance()[1] 
        self.assertEquals(
            instance.render(self.context, self.plugin, self.placeholder)["form_template_name"], 
            "html/formdefinition/forms/custom.html"
            ) 
        
コード例 #6
0
    def setUp(self):
        # create a placeholder
        self.placeholder = Placeholder(slot=u"some_slot")

        # create a fake context and request
        request = HttpRequest()
        self.context = {"request": request}

        # create a form
        self.form = FormDefinition(name = "testform")
        self.form.save()

        # add the plugin
        self.plugin = add_plugin(
            self.placeholder, 
            u"FormDesignerPlugin", 
            u"en",
            form_definition=self.form
            )
        self.plugin.save()
コード例 #7
0
 def setUp(self):
     # create a form
     self.form = FormDefinition(name = "testform")
     self.form.save()
コード例 #8
0
 def setUp(self):
     # create a form
     self.form = FormDefinition(name="testform")
     self.form.save()