From b712121a22c13cfff73cfb01a1a2b853bbd9c067 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Wed, 29 Jun 2011 10:49:37 -0700 Subject: [PATCH] Clean up chartbeat tests Must call 'syncdb' inside test_rendering_setup_site because we add 'django.contrib.sites' to INSTALLED_APPS --- analytical/tests/test_tag_chartbeat.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/analytical/tests/test_tag_chartbeat.py b/analytical/tests/test_tag_chartbeat.py index 337ca3f..1cd7344 100644 --- a/analytical/tests/test_tag_chartbeat.py +++ b/analytical/tests/test_tag_chartbeat.py @@ -14,15 +14,22 @@ from analytical.templatetags.chartbeat import ChartbeatTopNode, \ from analytical.tests.utils import TagTestCase, override_settings from analytical.utils import AnalyticalException -@override_settings(INSTALLED_APPS=[ - a for a in settings.INSTALLED_APPS if a != 'django.contrib.sites']) +@override_settings(INSTALLED_APPS=[a for a in settings.INSTALLED_APPS if a != 'django.contrib.sites'], + CHARTBEAT_USER_ID="12345") class ChartbeatTagTestCaseNoSites(TagTestCase): def test_rendering_setup_no_site(self): r = ChartbeatBottomNode().render(Context()) self.assertTrue('var _sf_async_config={"uid": "12345"};' in r, r) +@override_settings(INSTALLED_APPS=settings.INSTALLED_APPS + ["django.contrib.sites"], + CHARTBEAT_USER_ID="12345") class ChartbeatTagTestCaseWithSites(TagTestCase): def test_rendering_setup_site(self): + from django.core.management import call_command + from django.db.models import loading + loading.cache.loaded = False + call_command("syncdb", verbosity=0) + site = Site.objects.create(domain="test.com", name="test") with override_settings(SITE_ID=site.id, CHARTBEAT_USER_ID="12345"): r = ChartbeatBottomNode().render(Context()) @@ -31,12 +38,6 @@ class ChartbeatTagTestCaseWithSites(TagTestCase): self.assertTrue(re.search( 'var _sf_async_config={.*"domain": "test.com".*};', r), r) -# Ensure django.contrib.sites is in INSTALLED_APPS -if "django.contrib.sites" not in settings.INSTALLED_APPS: - installed_apps = list(settings.INSTALLED_APPS) - installed_apps.append("django.contrib.sites") - ChartbeatTagTestCaseWithSites = override_settings(INSTALLED_APPS=installed_apps)(ChartbeatTagTestCaseWithSites) - class ChartbeatTagTestCase(TagTestCase): """ Tests for the ``chartbeat`` template tag.