def testMissingGoalType(self):
        anonymous_visitor = AnonymousVisitor()
        anonymous_visitor.save()

        goal_type = GoalType(name="existing-goal")
        goal_type.save()
        
        nb_types = GoalType.objects.all().count()
        nb_records = GoalRecord.objects.all().count()

        GoalRecord.record('existing-goal', TestUser(anonymous_visitor=anonymous_visitor))
        self.assertEquals(nb_records + 1, GoalRecord.objects.all().count())
        self.assertEqual(nb_types, GoalType.objects.all().count())

        with patch(settings, 'LEAN_AUTOCREATE_GOAL_TYPES', False):
            GoalRecord.record('inexistant-goal', TestUser(anonymous_visitor=anonymous_visitor))
            self.assertEquals(nb_records + 1, GoalRecord.objects.all().count())
            self.assertEqual(nb_types, GoalType.objects.all().count())

        with patch(settings, 'LEAN_AUTOCREATE_GOAL_TYPES', NotImplemented):
            GoalRecord.record('inexistant-goal', TestUser(anonymous_visitor=anonymous_visitor))
            self.assertEquals(nb_records + 1, GoalRecord.objects.all().count())
            self.assertEqual(nb_types, GoalType.objects.all().count())
            
        with patch(settings, 'LEAN_AUTOCREATE_GOAL_TYPES', True):
            GoalRecord.record('inexistant-goal',
                              TestUser(anonymous_visitor=anonymous_visitor))
            self.assertEquals(nb_records + 2, GoalRecord.objects.all().count())
            self.assertEqual(nb_types + 1, GoalType.objects.all().count())
Exemple #2
0
    def testMissingGoalType(self):
        anonymous_visitor = AnonymousVisitor()
        anonymous_visitor.save()

        goal_type = GoalType(name="existing-goal")
        goal_type.save()

        nb_types = GoalType.objects.all().count()
        nb_records = GoalRecord.objects.all().count()

        GoalRecord.record('existing-goal',
                          TestUser(anonymous_visitor=anonymous_visitor))
        self.assertEquals(nb_records + 1, GoalRecord.objects.all().count())
        self.assertEqual(nb_types, GoalType.objects.all().count())

        with patch(settings, 'LEAN_AUTOCREATE_GOAL_TYPES', False):
            GoalRecord.record('inexistant-goal',
                              TestUser(anonymous_visitor=anonymous_visitor))
            self.assertEquals(nb_records + 1, GoalRecord.objects.all().count())
            self.assertEqual(nb_types, GoalType.objects.all().count())

        with patch(settings, 'LEAN_AUTOCREATE_GOAL_TYPES', NotImplemented):
            GoalRecord.record('inexistant-goal',
                              TestUser(anonymous_visitor=anonymous_visitor))
            self.assertEquals(nb_records + 1, GoalRecord.objects.all().count())
            self.assertEqual(nb_types, GoalType.objects.all().count())

        with patch(settings, 'LEAN_AUTOCREATE_GOAL_TYPES', True):
            GoalRecord.record('inexistant-goal',
                              TestUser(anonymous_visitor=anonymous_visitor))
            self.assertEquals(nb_records + 2, GoalRecord.objects.all().count())
            self.assertEqual(nb_types + 1, GoalType.objects.all().count())
Exemple #3
0
 def test_get_all_analytics(self):
     with patch(settings, "LEAN_ANALYTICS", NotImplemented):
         reset_caches()
         self.assertEqual(get_all_analytics(), [])
     with patch(settings, "LEAN_ANALYTICS", []):
         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__])
Exemple #4
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])
    def testManageCommand(self):
        with patch(
                settings, 'LEAN_ENGAGEMENT_CALCULATOR',
                'django_lean.experiments.testsettings.SimpleEngagementCalculator'
        ):
            #make sure the manage.py command that generates daily stats work

            #Running with arguments should raise Exception
            self.assertRaises(CommandError,
                              update_experiment_reports.Command().handle,
                              "some", "args")

            #This is what manage.py will call
            self.runner = update_experiment_reports.Command().run_from_argv
            #Run the reports
            self.runner(['manage.py', 'update_experiment_reports'])

            #Make sure they were generated
            self.assertEquals(
                5,
                DailyEngagementReport.objects.filter(
                    experiment=self.experiment).count())
            self.assertEquals(
                5,
                DailyConversionReport.objects.filter(
                    experiment=self.experiment).count())
 def testManageCommand(self):        
     with patch(settings, 'LEAN_ENGAGEMENT_CALCULATOR',
                'django_lean.experiments.testsettings.SimpleEngagementCalculator'): 
         #make sure the manage.py command that generates daily stats work
         
         #Running with arguments should raise Exception
         self.assertRaises(CommandError,
             update_experiment_reports.Command().handle,
             "some", "args")
         
         #This is what manage.py will call
         self.runner = update_experiment_reports.Command().run_from_argv
         #Run the reports
         self.runner(['manage.py', 'update_experiment_reports'])
         
         #Make sure they were generated
         self.assertEquals(5, DailyEngagementReport.objects.filter(
                 experiment=self.experiment).count())
         self.assertEquals(5, DailyConversionReport.objects.filter(
                 experiment=self.experiment).count())