예제 #1
0
    def validate_form(self, config):
        """
        Validate the form class specified as module path in the *config*
        dictionary. Raises ``ImproperlyConfigured`` if class cannot be loaded.
        """
        from fancypages.compat import import_string
        try:
            form_class = import_string(config.get('form'))
        except ImportError:
            raise ImproperlyConfigured(
                "form '{}' doesn't seem to be a valid class".format(
                    config.get('form')))

        return form_class
예제 #2
0
    def validate_form(self, config):
        """
        Validate the form class specified as module path in the *config*
        dictionary. Raises ``ImproperlyConfigured`` if class cannot be loaded.
        """
        from fancypages.compat import import_string
        try:
            form_class = import_string(config.get('form'))
        except ImportError:
            raise ImproperlyConfigured(
                "form '{}' doesn't seem to be a valid class".format(
                    config.get('form')))

        return form_class
예제 #3
0
def test_form_block_can_submit_form(webtest, form_block_class):
    fancypage = factories.FancyPageFactory()
    form_block = form_block_class.objects.create(
        form_selection='contact-us', container=fancypage.containers.all()[0])

    assert isinstance(form_block.form,
                      import_string('contact_us.forms.ContactUsForm'))

    page = webtest.get(fancypage.get_absolute_url())
    assert form_block.url in page

    page.form['name'] = 'Test User'
    page.form['email'] = '*****@*****.**'
    page.form['message'] = 'Test message'
    page.form['next'] = fancypage.get_absolute_url()
    submit_page = page.form.submit().follow()

    assert submit_page.request.path == fancypage.get_absolute_url()
예제 #4
0
def test_form_block_can_submit_form(webtest, form_block_class):
    fancypage = factories.FancyPageFactory()
    form_block = form_block_class.objects.create(
        form_selection='contact-us', container=fancypage.containers.all()[0])

    assert isinstance(
        form_block.form, import_string('contact_us.forms.ContactUsForm'))

    page = webtest.get(fancypage.get_absolute_url())
    assert form_block.url in page

    page.form['name'] = 'Test User'
    page.form['email'] = '*****@*****.**'
    page.form['message'] = 'Test message'
    page.form['next'] = fancypage.get_absolute_url()
    submit_page = page.form.submit().follow()

    assert submit_page.request.path == fancypage.get_absolute_url()