Skip to content

Commit

Permalink
Load site within tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenmcd committed Feb 28, 2012
1 parent 69555d3 commit ab2aace
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions forms_builder/forms/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
from forms_builder.forms.signals import form_invalid, form_valid


current_site = None
if USE_SITES:
current_site = Site.objects.get_current()


class Tests(TestCase):

def setUp(self):
self._site = Site.objects.get_current()

def test_form_fields(self):
"""
Simple 200 status check against rendering and posting to forms with
Expand All @@ -28,7 +26,7 @@ def test_form_fields(self):
for required in (True, False):
form = Form.objects.create(title="Test", status=STATUS_PUBLISHED)
if USE_SITES:
form.sites.add(current_site)
form.sites.add(self._site)
form.save()
for (field, _) in NAMES:
form.fields.create(label=field, field_type=field,
Expand All @@ -51,7 +49,7 @@ def test_draft_form(self):
self.client.logout()
draft = Form.objects.create(title="Draft", status=STATUS_DRAFT)
if USE_SITES:
draft.sites.add(current_site)
draft.sites.add(self._site)
draft.save()
response = self.client.get(draft.get_absolute_url())
self.assertEqual(response.status_code, 404)
Expand All @@ -70,7 +68,7 @@ def test_form_signals(self):
form_valid.connect(valid)
form = Form.objects.create(title="Signals", status=STATUS_PUBLISHED)
if USE_SITES:
form.sites.add(current_site)
form.sites.add(self._site)
form.save()
form.fields.create(label="field", field_type=NAMES[0][0],
required=True, visible=True)
Expand Down

0 comments on commit ab2aace

Please sign in to comment.