From 0e8b4b244a3516c7a229569f4cd6705aa7ea13f9 Mon Sep 17 00:00:00 2001 From: Joost Cassee Date: Wed, 8 Feb 2012 00:06:04 +0100 Subject: [PATCH] Add tests for anonymous user --- analytical/tests/test_tag_clicky.py | 7 ++++++- analytical/tests/test_tag_gosquared.py | 7 ++++++- analytical/tests/test_tag_kiss_insights.py | 7 ++++++- analytical/tests/test_tag_kiss_metrics.py | 7 ++++++- analytical/tests/test_tag_mixpanel.py | 7 ++++++- analytical/tests/test_tag_olark.py | 7 ++++++- analytical/tests/test_tag_performable.py | 7 ++++++- analytical/tests/test_tag_reinvigorate.py | 8 +++++++- analytical/tests/test_tag_snapengage.py | 7 ++++++- analytical/tests/test_tag_spring_metrics.py | 7 ++++++- analytical/tests/test_tag_woopra.py | 10 +++++----- docs/services/spring_metrics.rst | 22 ++++++++++----------- 12 files changed, 77 insertions(+), 26 deletions(-) diff --git a/analytical/tests/test_tag_clicky.py b/analytical/tests/test_tag_clicky.py index b929405..1755e7e 100644 --- a/analytical/tests/test_tag_clicky.py +++ b/analytical/tests/test_tag_clicky.py @@ -4,7 +4,7 @@ Tests for the Clicky template tags and filters. import re -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context @@ -46,6 +46,11 @@ class ClickyTagTestCase(TagTestCase): 'var clicky_custom = {"session": {"username": "test"}};' in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = ClickyNode().render(Context({'user': AnonymousUser()})) + self.assertFalse('var clicky_custom = {"session": {"username":' in r, r) + def test_custom(self): r = ClickyNode().render(Context({'clicky_var1': 'val1', 'clicky_var2': 'val2'})) diff --git a/analytical/tests/test_tag_gosquared.py b/analytical/tests/test_tag_gosquared.py index 37fe2f8..ff922b9 100644 --- a/analytical/tests/test_tag_gosquared.py +++ b/analytical/tests/test_tag_gosquared.py @@ -2,7 +2,7 @@ Tests for the GoSquared template tags and filters. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context @@ -48,6 +48,11 @@ class GoSquaredTagTestCase(TagTestCase): })) self.assertTrue('GoSquared.UserName = "test_identity";' in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = GoSquaredNode().render(Context({'user': AnonymousUser()})) + self.assertFalse('GoSquared.UserName = ' in r, r) + @override_settings(ANALYTICAL_INTERNAL_IPS=['1.1.1.1']) def test_render_internal_ip(self): req = HttpRequest() diff --git a/analytical/tests/test_tag_kiss_insights.py b/analytical/tests/test_tag_kiss_insights.py index 7d2888d..2626ac7 100644 --- a/analytical/tests/test_tag_kiss_insights.py +++ b/analytical/tests/test_tag_kiss_insights.py @@ -2,7 +2,7 @@ Tests for the KISSinsights template tags and filters. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.template import Context from analytical.templatetags.kiss_insights import KissInsightsNode @@ -46,6 +46,11 @@ class KissInsightsTagTestCase(TagTestCase): r = KissInsightsNode().render(Context({'user': User(username='test')})) self.assertTrue("_kiq.push(['identify', 'test']);" in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = KissInsightsNode().render(Context({'user': AnonymousUser()})) + self.assertFalse("_kiq.push(['identify', " in r, r) + def test_show_survey(self): r = KissInsightsNode().render( Context({'kiss_insights_show_survey': 1234})) diff --git a/analytical/tests/test_tag_kiss_metrics.py b/analytical/tests/test_tag_kiss_metrics.py index 8fc7c59..b92aacc 100644 --- a/analytical/tests/test_tag_kiss_metrics.py +++ b/analytical/tests/test_tag_kiss_metrics.py @@ -2,7 +2,7 @@ Tests for the KISSmetrics tags and filters. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context @@ -47,6 +47,11 @@ class KissMetricsTagTestCase(TagTestCase): r = KissMetricsNode().render(Context({'user': User(username='test')})) self.assertTrue("_kmq.push(['identify', 'test']);" in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = KissMetricsNode().render(Context({'user': AnonymousUser()})) + self.assertFalse("_kmq.push(['identify', " in r, r) + def test_event(self): r = KissMetricsNode().render(Context({'kiss_metrics_event': ('test_event', {'prop1': 'val1', 'prop2': 'val2'})})) diff --git a/analytical/tests/test_tag_mixpanel.py b/analytical/tests/test_tag_mixpanel.py index 2683855..d7132b5 100644 --- a/analytical/tests/test_tag_mixpanel.py +++ b/analytical/tests/test_tag_mixpanel.py @@ -2,7 +2,7 @@ Tests for the Mixpanel tags and filters. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context @@ -46,6 +46,11 @@ class MixpanelTagTestCase(TagTestCase): r = MixpanelNode().render(Context({'user': User(username='test')})) self.assertTrue("mpq.push(['identify', 'test']);" in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = MixpanelNode().render(Context({'user': AnonymousUser()})) + self.assertFalse("mpq.push(['identify', " in r, r) + def test_event(self): r = MixpanelNode().render(Context({'mixpanel_event': ('test_event', {'prop1': 'val1', 'prop2': 'val2'})})) diff --git a/analytical/tests/test_tag_olark.py b/analytical/tests/test_tag_olark.py index 48661e3..bd93458 100644 --- a/analytical/tests/test_tag_olark.py +++ b/analytical/tests/test_tag_olark.py @@ -2,7 +2,7 @@ Tests for the Olark template tags and filters. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.template import Context from analytical.templatetags.olark import OlarkNode @@ -39,6 +39,11 @@ class OlarkTestCase(TagTestCase): self.assertTrue("olark('api.chat.updateVisitorNickname', " "{snippet: 'Test User (test)'});" in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = OlarkNode().render(Context({'user': AnonymousUser()})) + self.assertFalse("olark('api.chat.updateVisitorNickname', " in r, r) + def test_nickname(self): r = OlarkNode().render(Context({'olark_nickname': 'testnick'})) self.assertTrue("olark('api.chat.updateVisitorNickname', " diff --git a/analytical/tests/test_tag_performable.py b/analytical/tests/test_tag_performable.py index 8b1192e..5e5c805 100644 --- a/analytical/tests/test_tag_performable.py +++ b/analytical/tests/test_tag_performable.py @@ -2,13 +2,13 @@ Tests for the Performable template tags and filters. """ +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context from analytical.templatetags.performable import PerformableNode from analytical.tests.utils import TagTestCase, override_settings, SETTING_DELETED from analytical.utils import AnalyticalException -from django.contrib.auth.models import User @override_settings(PERFORMABLE_API_KEY='123ABC') @@ -48,6 +48,11 @@ class PerformableTagTestCase(TagTestCase): r = PerformableNode().render(Context({'user': User(username='test')})) self.assertTrue('_paq.push(["identify", {identity: "test"}]);' in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = PerformableNode().render(Context({'user': AnonymousUser()})) + self.assertFalse('_paq.push(["identify", ' in r, r) + class PerformableEmbedTagTestCase(TagTestCase): """ diff --git a/analytical/tests/test_tag_reinvigorate.py b/analytical/tests/test_tag_reinvigorate.py index bbcc55e..f3c4111 100644 --- a/analytical/tests/test_tag_reinvigorate.py +++ b/analytical/tests/test_tag_reinvigorate.py @@ -4,7 +4,7 @@ Tests for the Reinvigorate template tags and filters. import re -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context @@ -44,6 +44,12 @@ class ReinvigorateTagTestCase(TagTestCase): self.assertTrue('var re_name_tag = "Test User";' in r, r) self.assertTrue('var re_context_tag = "test@example.com";' in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = ReinvigorateNode().render(Context({'user': AnonymousUser()})) + self.assertFalse('var re_name_tag = ' in r, r) + self.assertFalse('var re_context_tag = ' in r, r) + def test_tags(self): r = ReinvigorateNode().render(Context({'reinvigorate_var1': 'val1', 'reinvigorate_var2': 2})) diff --git a/analytical/tests/test_tag_snapengage.py b/analytical/tests/test_tag_snapengage.py index 9822287..931b1fb 100644 --- a/analytical/tests/test_tag_snapengage.py +++ b/analytical/tests/test_tag_snapengage.py @@ -2,7 +2,7 @@ Tests for the SnapEngage template tags and filters. """ -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.template import Context from django.utils import translation @@ -234,6 +234,11 @@ class SnapEngageTestCase(TagTestCase): User(username='test', email='test@example.com')})) self.assertTrue('SnapABug.setUserEmail("test@example.com");' in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = SnapEngageNode().render(Context({'user': AnonymousUser()})) + self.assertFalse('SnapABug.setUserEmail(' in r, r) + def test_language(self): r = SnapEngageNode().render(Context({'snapengage_locale': 'fr'})) self.assertTrue('SnapABug.setLocale("fr");' in r, r) diff --git a/analytical/tests/test_tag_spring_metrics.py b/analytical/tests/test_tag_spring_metrics.py index 2bac026..a69cb5d 100644 --- a/analytical/tests/test_tag_spring_metrics.py +++ b/analytical/tests/test_tag_spring_metrics.py @@ -4,7 +4,7 @@ Tests for the Spring Metrics template tags and filters. import re -from django.contrib.auth.models import User +from django.contrib.auth.models import User, AnonymousUser from django.http import HttpRequest from django.template import Context @@ -43,6 +43,11 @@ class SpringMetricsTagTestCase(TagTestCase): self.assertTrue("_springMetq.push(['setdata', " "{'email': 'test@test.com'}]);" in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = SpringMetricsNode().render(Context({'user': AnonymousUser()})) + self.assertFalse("_springMetq.push(['setdata', {'email':" in r, r) + def test_custom(self): r = SpringMetricsNode().render(Context({'spring_metrics_var1': 'val1', 'spring_metrics_var2': 'val2'})) diff --git a/analytical/tests/test_tag_woopra.py b/analytical/tests/test_tag_woopra.py index a12f5de..6fcf9ca 100644 --- a/analytical/tests/test_tag_woopra.py +++ b/analytical/tests/test_tag_woopra.py @@ -59,11 +59,6 @@ class WoopraTagTestCase(TagTestCase): r = WoopraNode().render(Context({'user': User(username='test')})) self.assertTrue('var woo_visitor = {"name": "test"};' in r, r) - @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) - def test_identify_anonymous_user(self): - r = WoopraNode().render(Context({'user': AnonymousUser()})) - self.assertTrue('var woo_visitor = {};' in r, r) - @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) def test_no_identify_when_explicit_name(self): r = WoopraNode().render(Context({'woopra_name': 'explicit', @@ -76,6 +71,11 @@ class WoopraTagTestCase(TagTestCase): 'user': User(username='implicit')})) self.assertTrue('var woo_visitor = {"email": "explicit"};' in r, r) + @override_settings(ANALYTICAL_AUTO_IDENTIFY=True) + def test_identify_anonymous_user(self): + r = WoopraNode().render(Context({'user': AnonymousUser()})) + self.assertTrue('var woo_visitor = {};' in r, r) + @override_settings(ANALYTICAL_INTERNAL_IPS=['1.1.1.1']) def test_render_internal_ip(self): req = HttpRequest() diff --git a/docs/services/spring_metrics.rst b/docs/services/spring_metrics.rst index d40fcf6..627625e 100644 --- a/docs/services/spring_metrics.rst +++ b/docs/services/spring_metrics.rst @@ -3,8 +3,8 @@ Spring Metrics -- conversion tracking ===================================== `Spring Metrics`_ is a convesions analysis tool. It shows you the top -converting sources, search keywords ande landing pages. The real-time -dashboard shows you how customers interacted with your website and how +converting sources, search keywords and landing pages. The real-time +dashboard shows you how customers interact with your website and how to increase conversion. .. _`Spring Metrics`: http://www.springmetrics.com/ @@ -87,11 +87,11 @@ Alternatively, you can mark conversion pages using the Tracking revenue ---------------- -The most important value tracked by Spring Metrics is that of revenue. -Using the :data:`spring_metrics_revenue` template context variable, you -can let the :ttag:`spring_metrics` tag pass earned revenue to Spring -Metrics. You can set the context variable in your view when you render -a template containing thetracking code:: +Spring Metrics allows you to track the value of conversions. Using the +:data:`spring_metrics_revenue` template context variable, you can let +the :ttag:`spring_metrics` tag pass earned revenue to Spring Metrics. +You can set the context variable in your view when you render a +template containing the tracking code:: context = RequestContext({ 'spring_metrics_convert': 'sale', @@ -106,10 +106,10 @@ if you already tagged the page in Spring Metrics.) Custom data ----------- -Spring Metrics can also track other data. Interesting examples would be -transaction IDs or e-mail addresses from logged in users. By setting -any :data:`spring_metrics_X` template context variable, Spring Metrics -will track a variable named :data:`X`. For example:: +Spring Metrics can also track other data. Interesting examples could be +transaction IDs or the e-mail addresses from logged in users. By +setting any :data:`spring_metrics_X` template context variable, Spring +Metrics will track a variable named :data:`X`. For example:: context = RequestContext({ 'spring_metrics_revenue': '30.53',