def test_user_optin(self):
        '''
        Test if a single opt-in is happening correctly
        '''
        all_exps = Experiment.objects.all()
        self.assertEqual(all_exps.count(),1)
        
        response = test_get_and_post_form(
            self.client,
            reverse("opt_in_experiment"),
            {"experiment":all_exps[0].id},
        )
        self.assertContains(response, "successfully")
        uopt = UserOpts.objects.filter(user__username__exact="user")
        self.assertEqual(len(uopt),1)
        self.assertEqual(uopt[0].experiment.slice_name,"slice name_1")
        optfs = OptsFlowSpace.objects.filter(opt=uopt[0])
        self.assertEqual(len(optfs),1)
        self.num_fv_rules = MatchStruct.objects.filter(optfs=optfs[0]).count()
        actual_fv_rules_count = DummyFVRule.objects.all().count()
        self.assertEqual(actual_fv_rules_count,self.num_fv_rules)
        self.assertEqual(optfs[0].ip_src_s,max(self.user_ip_src_s,self.exp_ip_src_s))
        self.assertEqual(optfs[0].ip_src_e,min(self.user_ip_src_e,self.exp_ip_src_e))
        self.assertEqual(getattr(optfs[0],"%s_s"%self.user_field_name), self.user_field_s)
        self.assertEqual(getattr(optfs[0],"%s_e"%self.user_field_name), self.user_field_e)
        self.assertEqual(getattr(optfs[0],"%s_s"%self.exp_field_name), self.exp_field_s)
        self.assertEqual(getattr(optfs[0],"%s_e"%self.exp_field_name), self.exp_field_e)
dataset/ETHPy150Open fp7-ofelia/ocf/optin_manager/src/python/openflow/optin_manager/opts/tests.py/Tests.test_user_optin/original