Skip to content

Commit

Permalink
Added tests for the render_built_form template tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcd committed Feb 26, 2012
1 parent ee2709f commit 50e12d4
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion forms_builder/forms/tests.py
@@ -1,7 +1,10 @@

from collections import namedtuple

from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.auth.models import User, AnonymousUser
from django.contrib.sites.models import Site
from django.template import Context, Template
from django.test import TestCase

from forms_builder.forms.models import Form, STATUS_DRAFT, STATUS_PUBLISHED
Expand Down Expand Up @@ -75,3 +78,19 @@ def test_form_signals(self):
data = {"field_%s" % form.fields.visible()[0].id: "test"}
self.client.post(form.get_absolute_url(), data=data)
self.assertEqual(len(events), 0)

def test_tag(self):
"""
Test that the different formats for the ``render_built_form``
tag all work.
"""
form = Form.objects.create(title="Tags", status=STATUS_PUBLISHED)
request = namedtuple("Request", ("user",))(user=AnonymousUser())
context = {"form": form, "request": request}
template = "{%% load forms_builder_tags %%}{%% render_built_form %s %%}"
formats = ("form", "form=form", "id=form.id", "slug=form.slug")
for format in formats:
t = Template(template % format).render(Context(context))
self.assertTrue(form.get_absolute_url(), t)


0 comments on commit 50e12d4

Please sign in to comment.