def test_user_multiple_opts(self):
        max_opt = random.randint(5,9)
        
        exp_ids = []
        first_id = Experiment.objects.all()[0].id
        exp_ids.append(first_id)
        
        for index in range(2,max_opt):
        #create a random number of experiments
            exp = Experiment.objects.create(slice_id="slice_id_%d"%index, project_name="project name_%d"%index,
                                      project_desc="project description", slice_name="slice name_%d"%index,
                                      slice_desc="slice description", controller_url="controller url",
                                      owner_email="owner email", owner_password="owner password") 
            expfs = ExperimentFLowSpace.objects.create(exp=exp, dpid="00:00:00:00:00:00:0%d"%index,
                                ip_src_s=random.randint(0,0x80000000) & 0xFFFF0000, 
                                ip_src_e=random.randint(0x80000000,0xFFFFFFFF) & 0xFFFF0000, 
                                 )
            expfs.save() 
            exp_ids.append(exp.id)
        
        # opt into all of them
        count = 0
        for exp in Experiment.objects.all():
            count = count + 1
            response = test_get_and_post_form(
                self.client,
                reverse("opt_in_experiment"),
                {"experiment":exp.id},
            )
            self.assertContains(response, "successfully")
            uopt = UserOpts.objects.filter(user__username__exact="user")
            self.assertEqual(len(uopt),count)
            self.assertEqual(uopt[count-1].experiment.slice_name,exp.slice_name)
            optfs = OptsFlowSpace.objects.filter(opt=uopt[count-1])
            self.assertEqual(len(optfs),1)
            
            
        # change priority
        request_post = {}
        for id in range(1,max_opt):
            request_post["p_%d"%exp_ids[id-1]] = max_opt - id + 1
            
        response = test_get_and_post_form(
            self.client,
            reverse("change_priority"),
            request_post,
        )
        self.assertContains(response, "Successfully")
        for id in range(1,max_opt):
            uopt = UserOpts.objects.filter(user__username__exact="user",\
                                    experiment__slice_name="slice name_%d"%id)
            self.assertEqual(uopt.count(),1,"uopt.count()!=1 for id=%d"%id)
            self.assertEqual(uopt[0].priority,max_opt - id + 1)
            optfs = OptsFlowSpace.objects.filter(opt = uopt[0])
            self.assertEqual(optfs.count(),1)
            mstr = optfs[0].matchstruct_set.all()
            self.assertNotEqual(mstr.count(),0)
            fv_rule = DummyFVRule.objects.filter(match=mstr[0].match,\
                                                 dpid="00:00:00:00:00:00:0%d"%id)
            self.assertEqual(fv_rule.count(),1)
            self.assertEqual(fv_rule[0].priority,mstr[0].priority)
            
            
        #opt out of all of them
        request_post = {}
        for id in range(1,max_opt):
            request_post["%d"%exp_ids[id-1]] = "checked"
            
        response = test_get_and_post_form(
            self.client,
            reverse("opt_out_of_experiment"),
            request_post,
        )
        uopt = UserOpts.objects.filter(user__username__exact="user")
        self.assertEqual(len(uopt),0)
        optfs = OptsFlowSpace.objects.filter(opt__user__username="user")
        self.assertEqual(optfs.count(),0) 
        actual_fv_rules_count = DummyFVRule.objects.all().count()
        self.assertEqual(actual_fv_rules_count,0)
Check that passing wrong values raises an error.
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/opts/tests.py/Tests.test_user_multiple_opts--crossover with--dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/test/test_usage.py/TypedTestCase.test_invalidValues