Skip to content

Commit

Permalink
Add tests for anonymous user
Browse files Browse the repository at this point in the history
  • Loading branch information
jcassee committed Feb 7, 2012
1 parent 3503561 commit 0e8b4b2
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 26 deletions.
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_clicky.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down Expand Up @@ -46,6 +46,11 @@ def test_identify(self):
'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'}))
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_gosquared.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -48,6 +48,11 @@ def test_manual_identify(self):
}))
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()
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_kiss_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,6 +46,11 @@ def test_identify(self):
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}))
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_kiss_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -47,6 +47,11 @@ def test_identify(self):
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'})}))
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_mixpanel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -46,6 +46,11 @@ def test_identify(self):
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'})}))
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_olark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,6 +39,11 @@ def test_identify(self):
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', "
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_performable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -48,6 +48,11 @@ def test_identify(self):
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):
"""
Expand Down
8 changes: 7 additions & 1 deletion analytical/tests/test_tag_reinvigorate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down Expand Up @@ -44,6 +44,12 @@ def test_identify(self):
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}))
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_snapengage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -234,6 +234,11 @@ def test_identify(self):
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)
Expand Down
7 changes: 6 additions & 1 deletion analytical/tests/test_tag_spring_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

Expand Down Expand Up @@ -43,6 +43,11 @@ def test_identify(self):
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'}))
Expand Down
10 changes: 5 additions & 5 deletions analytical/tests/test_tag_woopra.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ def test_identify_username_no_email(self):
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',
Expand All @@ -76,6 +71,11 @@ def test_no_identify_when_explicit_email(self):
'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()
Expand Down
22 changes: 11 additions & 11 deletions docs/services/spring_metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down

0 comments on commit 0e8b4b2

Please sign in to comment.