def testClientSideExperimentTag(self):
        for i in range(100):
            user = User(username="user%s" % i, email="user%s@example.com" % i)
            user.save()
            
            # create a context for a single "request"
            c = Context({"user": user})
            
            self.doRenderClientSideExperiment(c, "user%i" % i,
                                              self.experiment.name)
            self.assertTrue("client_side_experiments" in c)
            self.doRenderClientSideExperiment(c, "user%i" % i,
                                              self.experiment.name)
            self.doRenderClientSideExperiment(c, "user%i" % i,
                                              self.other_experiment.name)
            self.doRenderClientSideExperiment(c, "user%i" % i,
                                              self.other_experiment.name)
            
            # determine what group the user was assigned to in each experiment
            experiment_partcipant = Participant.objects.get(
                                        user=user,
                                        experiment=self.experiment)
            other_experiment_partcipant = Participant.objects.get(
                                            user=user,
                                            experiment=self.other_experiment)
            
            # assert that exactly two entries were populated in the
            # 'client_side_experiments' dict in the context and that they are
            # equal to the names of our two experiments
            self.assertEquals(2, len(c['client_side_experiments'].keys()))
            self.assertTrue(self.experiment.name in
                               c['client_side_experiments'])
            self.assertTrue(self.other_experiment.name in
                               c['client_side_experiments'])
            
            # get the values that were put in the client_side_experiments dict
            group_name = c['client_side_experiments'][self.experiment.name]
            other_group_name = \
                c['client_side_experiments'][self.other_experiment.name]
            
            # make sure that the values correctly represent the user's
            # enrollments
            group_id = experiment_partcipant.group
            other_group_id = other_experiment_partcipant.group
            self.assertEqual(group_id == Participant.TEST_GROUP,
                             group_name == "test")
            
            self.assertEqual(group_id == Participant.CONTROL_GROUP,
                             group_name == "control")
            
            self.assertEqual(
                        other_group_id == Participant.TEST_GROUP,
                        other_group_name == "test")
            
            self.assertEqual(
                        other_group_id == Participant.CONTROL_GROUP,
                        other_group_name == "control")
dataset/ETHPy150Open Miserlou/django-easy-split/easy_split/tests/test_tags.py/ExperimentTagsTest.testClientSideExperimentTag/original