Exemple #1
0
 def test_get_all_analytics_names(self):
     with patch(settings, "LEAN_ANALYTICS", NotImplemented):
         reset_caches()
         self.assertEqual(get_all_analytics_names(), ())
     with patch(settings, "LEAN_ANALYTICS", []):
         reset_caches()
         self.assertEqual(get_all_analytics_names(), [])
     base_name = "%s.%s" % (BaseAnalytics.__module__, BaseAnalytics.__name__)
     with patch(settings, "LEAN_ANALYTICS", [base_name]):
         reset_caches()
         self.assertEqual(get_all_analytics_names(), [base_name])
Exemple #2
0
 def test_get_all_analytics_names(self):
     with patch(settings, 'LEAN_ANALYTICS', NotImplemented):
         reset_caches()
         self.assertEqual(get_all_analytics_names(), ())
     with patch(settings, 'LEAN_ANALYTICS', []):
         reset_caches()
         self.assertEqual(get_all_analytics_names(), [])
     base_name = '%s.%s' % (BaseAnalytics.__module__, BaseAnalytics.__name__)
     with patch(settings, 'LEAN_ANALYTICS', [base_name]):
         reset_caches()
         self.assertEqual(get_all_analytics_names(), [base_name])
Exemple #3
0
            reset_caches()
            self.assertEqual(get_all_analytics(), [])
        base_name = "%s.%s" % (BaseAnalytics.__module__, BaseAnalytics.__name__)
        with patch(settings, "LEAN_ANALYTICS", [base_name]):
            reset_caches()
            self.assertEqual([a.__class__.__name__ for a in get_all_analytics()], [BaseAnalytics.__name__])


#############
# KISSMETRICS
#############

try:
    import django_kissmetrics
except ImportError:
    if "django_lean.lean_analytics.kissmetrics.KissMetrics" in get_all_analytics_names():
        traceback.print_exc()
else:
    from django_lean.lean_analytics.kissmetrics import KissMetrics

    class TestKissMetrics(TestCase):
        def setUp(self):
            self.mox = mox.Mox()
            self.analytics = KissMetrics()

        def test_id_from_user(self):
            user = User.objects.create_user("user", "*****@*****.**", "user")
            self.assertEqual(self.analytics._id_from_user(user), "User %d" % user.pk)
            self.assertRaises(IdentificationError, self.analytics._id_from_user, None)

        def test_id_from_session(self):
Exemple #4
0
        base_name = '%s.%s' % (BaseAnalytics.__module__, BaseAnalytics.__name__)
        with patch(settings, 'LEAN_ANALYTICS', [base_name]):
            reset_caches()
            self.assertEqual([a.__class__.__name__ for a in get_all_analytics()],
                             [BaseAnalytics.__name__])


#############
# KISSMETRICS
#############

try:
    import django_kissmetrics
except ImportError:
    if 'django_lean.lean_analytics.kissmetrics.KissMetrics' in \
       get_all_analytics_names():
        traceback.print_exc()
else:
    from django_lean.lean_analytics.kissmetrics import KissMetrics


    class TestKissMetrics(TestCase):
        def setUp(self):
            self.mox = mox.Mox()
            self.analytics = KissMetrics()

        def test_id_from_user(self):
            user = User.objects.create_user('user', '*****@*****.**', 'user')
            self.assertEqual(self.analytics._id_from_user(user),
                             'User %d' % user.pk)
            self.assertRaises(IdentificationError,