def testGetConversionData(self):
        days = [datetime.combine(date.today() + timedelta(days=i), time(hour=12))
                for i in range(-7, 0)]
        
        yesterday = date.today() - timedelta(days=1)
        experiment = Experiment(name="experiment1")
        experiment.save()
        experiment.state = Experiment.ENABLED_STATE
        experiment.save()
        experiment.start_date = yesterday
        experiment.save()
        
        goal_types = [GoalType.objects.create(name="%s" % i) for i in range(4)]
        
        report = DailyConversionReport.objects.create(experiment=experiment,
                                             date=yesterday,
                                             overall_test_conversion=17,
                                             overall_control_conversion=12,
                                             test_group_size=139,
                                             control_group_size=142,
                                             confidence=87.3)
        
        DailyConversionReportGoalData.objects.create(report=report,
                                                     goal_type=goal_types[0],
                                                     test_conversion=11,
                                                     control_conversion=0,
                                                     confidence=65.3)
        DailyConversionReportGoalData.objects.create(report=report,
                                                     goal_type=goal_types[1],
                                                     test_conversion=0,
                                                     control_conversion=21,
                                                     confidence=None)
        DailyConversionReportGoalData.objects.create(report=report,
                                                     goal_type=goal_types[2],
                                                     test_conversion=23,
                                                     control_conversion=21,
                                                     confidence=100)
        
        data = get_conversion_data(experiment, yesterday)
        
        self.assertEquals(data['date'], yesterday)
        self.assertTrue("totals" in data)
        self.assertTrue("goal_types" in data)
        self.assertEquals(4, len(data["goal_types"].keys()))
        
        for goal_type in goal_types[0:3]:
            self.assertTrue(goal_type.name in data["goal_types"])
            
            goal_type_data = data["goal_types"][goal_type.name]
            self.assertTrue("test_count" in goal_type_data)
            self.assertTrue("control_count" in goal_type_data)
            self.assertTrue("test_rate" in goal_type_data)
            self.assertTrue("control_rate" in goal_type_data)
            self.assertTrue("improvement" in goal_type_data)
            self.assertTrue("confidence" in goal_type_data)
        
        self.assertEquals(None, data["goal_types"][goal_types[3].name])
        
        self.assertEquals(139, data["test_group_size"])
        self.assertEquals(142, data["control_group_size"])
        
        totals = data["totals"]
        
        expected_test_rate = 17. / 139. * 100.
        expected_control_rate = 12. / 142. * 100.
        expected_improvement = expected_control_rate * 100. / (expected_test_rate - expected_control_rate)
        
        self.assertAlmostEquals(expected_test_rate, totals["test_rate"])
        self.assertAlmostEquals(expected_control_rate, totals["control_rate"])
        self.assertAlmostEquals(expected_improvement, totals["improvement"])
        self.assertAlmostEquals(87.3, totals["confidence"])
        self.assertEquals(17, totals["test_count"])
        self.assertEquals(12, totals["control_count"])
        
        self.assertEquals(0, data["goal_types"][goal_types[0].name]["control_rate"])
        self.assertAlmostEquals(11./139*100., data["goal_types"][goal_types[0].name]["test_rate"])
        self.assertEquals(None, data["goal_types"][goal_types[0].name]["improvement"])
        self.assertAlmostEquals(65.3, data["goal_types"][goal_types[0].name]["confidence"])
        self.assertEquals(11, data["goal_types"][goal_types[0].name]["test_count"])
        self.assertEquals(0, data["goal_types"][goal_types[0].name]["control_count"])
        
        self.assertAlmostEquals(21./142*100., data["goal_types"][goal_types[1].name]["control_rate"])
        self.assertEquals(None, data["goal_types"][goal_types[1].name]["confidence"])
        self.assertEquals(None, data["goal_types"][goal_types[1].name]["improvement"])
        
        self.assertAlmostEquals((23./139-21./142)/(21./142)*100.,
                                data["goal_types"][goal_types[2].name]["improvement"])


#TODO test with zero participants and check rate == None

#TODO sometimes confidence cannot be calculated and must return None. Add a test to verify this.
dataset/ETHPy150Open Miserlou/django-easy-split/easy_split/tests/test_daily_report.py/TestDailyReports.testGetConversionData/swapped operands of `/`