]> git.parisson.com Git - django-google-tools.git/commitdiff
Added data fixtures and some site tests.
authorJ. Cliff Dyer <jcd@webb.(none)>
Thu, 3 Dec 2009 18:10:34 +0000 (13:10 -0500)
committerJ. Cliff Dyer <jcd@webb.(none)>
Thu, 3 Dec 2009 18:10:34 +0000 (13:10 -0500)
google_analytics/fixtures/test.json [new file with mode: 0644]
google_analytics/tests/test_templatetags.py

diff --git a/google_analytics/fixtures/test.json b/google_analytics/fixtures/test.json
new file mode 100644 (file)
index 0000000..6697392
--- /dev/null
@@ -0,0 +1,18 @@
+[
+  {
+    "pk": 1, 
+    "model": "sites.site", 
+    "fields": {
+      "domain": "example.com", 
+      "name": "example.com"
+    }
+  }, 
+  {
+    "pk": 1, 
+    "model": "google_analytics.analytics", 
+    "fields": {
+      "analytics_code": "UA-777777-3", 
+      "site": 1
+    }
+  }
+]
index 7b205e8807938223368bddd318d3fdaf2c5f1714..6dc850d3b512be5b9a3b5df521dd9906c6d2c173 100644 (file)
@@ -1,9 +1,12 @@
 from django.test import TestCase
 from django import template
 
+from django.contrib.sites.models import Site
+
 from google_analytics.templatetags import analytics 
 
 class ParserTest(TestCase):
+
     def setUp(self):
         self.parser = "unused"
         #################################
@@ -14,6 +17,7 @@ class ParserTest(TestCase):
         self.token_noarg = template.Token(template.TOKEN_BLOCK, "test")
         self.token_onearg = template.Token(template.TOKEN_BLOCK, "test 'UA-888888-1'")
         self.token_twoarg = template.Token(template.TOKEN_BLOCK, "test 'UA-888888-1' 'UA-999999-2'")
+        self.site = Site.objects.get_current()
 
     def test_setup(self):
         self.assert_(True)
@@ -37,6 +41,16 @@ class ParserTest(TestCase):
     def test_twoarg_node_exception(self):
         self.assertRaises(template.TemplateSyntaxError, analytics.do_get_analytics, self.parser, self.token_twoarg)
 
+    def test_noarg_site(self):
+        """If no access code is provided, the site will be set to the currently active site"""
+        node = analytics.do_get_analytics(self.parser, self.token_noarg)
+        self.assertEqual(node.site, self.site)
+
+    def test_onearg_site(self):
+        """If an access code is provided, the site will not be set"""
+        node = analytics.do_get_analytics(self.parser, self.token_onearg)
+        self.assertEqual(node.site, None)
+
 class NodeTest(TestCase):
     def setUp(self):
         self.node_noarg = analytics.AnalyticsNode()