Пример #1
0
    def testStatistics(self):
        """
        Tests a simple experiment with one and two variations
        """
        experiment = Experiment(name="Statistics1", short_name="stats")
        experiment.save()

        testOption1 = Test(experiment=experiment, name="Foo", content="foo")
        testOption1.save()

        testOption2 = Test(experiment=experiment, name="Bar", content="bar")
        testOption2.save()

        clients = []
        n = 255
        # Create 255 clients and connect to the test page, our public
        # really likes content containing bar and is immediately
        # interested in signing up in this scenario.
        for i in xrange(1, n + 1):
            client = Client(REMOTE_ADDR="127.0.1." + str(i))
            clients.append(client)

            response = self.client.get('/landing/')
            if "bar" in response.content:
                response = self.client.get('/signup/')

        count_hits = Hit.objects.count()
        self.assertTrue(n <= count_hits and count_hits <= n * 2)
Пример #2
0
    def testExperiments(self):
        """
        Tests a simple experiment with one and two variations
        """
        experiment = Experiment(name="Foo", short_name="foo")
        experiment.save()

        testOption1 = Test(experiment=experiment, name="Foo", content="foo")
        testOption1.save()

        response = self.client1.get('/test/')
        self.assertTrue("foo" in response.content)

        testOption2 = Test(experiment=experiment, name="Bar", content="bar")
        testOption2.save()

        i = 0
        found_bar = False
        while (not found_bar and i < 255):
            i += 1
            client = Client(REMOTE_ADDR="128.0.0." + str(i))
            response = client.get('/test/')
            if "bar" in response.content:
                found_bar = True  # Drinks for everyone!
        # This tests passes with p = 1 - (0.5^255)
        self.assertTrue(found_bar)
Пример #3
0
    def testPersistence(self):
        """
        Tests the persistence of the displayed variations
        """
        url = '/persistence/'

        experiment = Experiment(name="Persistence", short_name="persistence")
        experiment.save()

        testOption1 = Test(experiment=experiment, name="Foo", content="foo")
        testOption1.save()

        testOption2 = Test(experiment=experiment, name="Foo", content="bar")
        testOption2.save()


        content = self.client1.get(url).content

        found_deviation = False
        i = 0
        while (not found_deviation and i < 1000):
            i += 1
            response = self.client1.get(url)
            if content not in response.content:
                found_deviation = True
        # This tests passes with p = 1 - (0.5^1000)
        self.assertTrue(not found_deviation)