mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-03-16 22:20:25 +00:00
Clean up chartbeat tests
Must call 'syncdb' inside test_rendering_setup_site because we add 'django.contrib.sites' to INSTALLED_APPS
This commit is contained in:
parent
5bf02a8a07
commit
b712121a22
1 changed files with 9 additions and 8 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue