def blackbox_test(self):
        # Should create a new campaign first
        HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN)

        # Combination of three kinds of test cases defined in README
        # Part I: Valid Case
        for a in self.valid_arg["auth_token"]:
            self.arg_pass_in = {}
            self.arg_pass_in_msg = []
            self.arg_pass_in["auth_token"] = a
            self.arg_pass_in_msg.append(self.valid_arg_msg["auth_token"][0])
            for clt in self.valid_arg["client"]:
                self.arg_pass_in["client"] = clt
                self.arg_pass_in_msg.append(self.valid_arg_msg["client"][self.valid_arg["client"].index(clt)])
                for camp in self.valid_arg["campaign_urn"]:
                    self.arg_pass_in["campaign_urn"] = camp
                    self.arg_pass_in_msg.append(
                        self.valid_arg_msg["campaign_urn"][self.valid_arg["campaign_urn"].index(camp)]
                    )
                    for run in self.valid_arg["running_state"]:
                        self.update_arg_pass_in("running_state", run, 0)
                        self.arg_pass_in_msg.append(
                            self.valid_arg_msg["running_state"][self.valid_arg["running_state"].index(run)]
                        )
                        for pri in self.valid_arg["privacy_state"]:
                            self.update_arg_pass_in("privacy_state", pri, 0)
                            self.arg_pass_in_msg.append(
                                self.valid_arg_msg["privacy_state"][self.valid_arg["privacy_state"].index(pri)]
                            )
                            for cls in self.valid_arg["class_urn_list"]:
                                self.update_arg_pass_in("class_urn_list", cls, 0)
                                self.arg_pass_in_msg.append(
                                    self.valid_arg_msg["class_urn_list"][self.valid_arg["class_urn_list"].index(cls)]
                                )
                                for xml in self.valid_arg["xml"]:
                                    self.update_arg_pass_in("xml", xml, 0)
                                    self.arg_pass_in_msg.append(
                                        self.valid_arg_msg["xml"][self.valid_arg["xml"].index(xml)]
                                    )
                                    for des in self.valid_arg["description"]:
                                        self.update_arg_pass_in("description", des, 0)
                                        self.arg_pass_in_msg.append(
                                            self.valid_arg_msg["description"][self.valid_arg["description"].index(des)]
                                        )
                                        for add in self.valid_arg["user_role_list_add"]:
                                            self.update_arg_pass_in("user_role_list_add", add, 0)
                                            self.arg_pass_in_msg.append(
                                                self.valid_arg_msg["user_role_list_add"][
                                                    self.valid_arg["user_role_list_add"].index(add)
                                                ]
                                            )
                                            for remove in self.valid_arg["user_role_list_remove"]:
                                                self.update_arg_pass_in("user_role_list_remove", remove, 0)
                                                self.arg_pass_in_msg.append(
                                                    self.valid_arg_msg["user_role_list_remove"][
                                                        self.valid_arg["user_role_list_remove"].index(remove)
                                                    ]
                                                )
                                                # Determine the expected result
                                                exp_result = self.result_det(self.arg_pass_in_msg)
                                                # Use zip(dict.keys(), dict.values())
                                                # can convert dict into a list of tuples
                                                self.http.set_pass_in_with_file(
                                                    zip(self.arg_pass_in.keys(), self.arg_pass_in.values())
                                                )
                                                # Need to upload a file, set flag to 1
                                                # to change the type of HTTP request
                                                self.http.request(1)
                                                self.total_case = self.total_case + 1
                                                # Print status
                                                print "Processing Case ID {0}.\n{1}% to finish Campaign Update API.".format(
                                                    "CD" + str(self.total_case), self.total_case * 100 / TOTAL_CASE
                                                )
                                                # Check the response
                                                if exp_result == "v":
                                                    if (self.http.http_code != 200) or (
                                                        self.http.cont_dict["result"] != "success"
                                                    ):
                                                        HTTP.write_err_report(
                                                            self.err_report,
                                                            "CD" + str(self.total_case),
                                                            self.arg_pass_in,
                                                            self.http.contents,
                                                            '{"result": "success"}',
                                                        )
                                                        # increment the invalid case id list and unexpected case counter
                                                        self.invalid_case_id_list.append("CD" + str(self.total_case))
                                                        self.unexpect_case = self.unexpect_case + 1
                                                    else:
                                                        HTTP.write_succ_report(
                                                            self.succ_report,
                                                            "CD" + str(self.total_case),
                                                            self.arg_pass_in,
                                                            self.http.contents,
                                                        )
                                                else:
                                                    print >> sys.stderr, "Error: Invalid valid test case"
                                                    sys.exit(1)
                                                # update arg_pass_in and arg_pass_in_msg
                                                self.update_arg_pass_in("user_role_list_remove", remove, 1)
                                                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                                            # update arg_pass_in and arg_pass_in_msg
                                            self.update_arg_pass_in("user_role_list_add", add, 1)
                                            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                                        # update arg_pass_in and arg_pass_in_msg
                                        self.update_arg_pass_in("description", des, 1)
                                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                                    # update arg_pass_in and arg_pass_in_msg
                                    self.update_arg_pass_in("xml", xml, 1)
                                    self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                                # update arg_pass_in and arg_pass_in_msg
                                self.update_arg_pass_in("class_urn_list", cls, 1)
                                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                            # update arg_pass_in and arg_pass_in_msg
                            self.update_arg_pass_in("privacy_state", pri, 1)
                            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                        # update arg_pass_in and arg_pass_in_msg
                        self.update_arg_pass_in("running_state", run, 1)
                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                    # update arg_pass_in and arg_pass_in_msg
                    del self.arg_pass_in["campaign_urn"]
                    self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
                # update arg_pass_in and arg_pass_in_msg
                del self.arg_pass_in["client"]
                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
            # update arg_pass_in and arg_pass_in_msg
            del self.arg_pass_in["auth_token"]
            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)

        ########################################################################
        ########################################################################
        # Part II: Invalid case with one invalid argument
        # Here I reduce the number of test cases by only picking one combination
        # of valid case
        # pick each invalid argument once
        for arg_name in self.para_name_list:
            for arg in self.invalid_arg[arg_name]:
                # first keep all argument valid
                self.form_one_valid_arg()
                self.update_arg_pass_in(arg_name, arg, 0)
                self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name][self.invalid_arg[arg_name].index(arg)])
                # Determine the expected result
                exp_result = self.result_det(self.arg_pass_in_msg)
                # Use zip(dict.keys(), dict.values())
                # can convert dict into a list of tuples
                self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                # Need to upload a file, set flag to 1
                # to change the type of HTTP request
                self.http.request(1)
                self.total_case = self.total_case + 1
                # Print status
                print "Processing Case ID {0}.\n{1}% to finish Campaign Update API.".format(
                    "CD" + str(self.total_case), self.total_case * 100 / TOTAL_CASE
                )
                # check the response
                self.err_response_check(exp_result)

        ########################################################################
        ########################################################################
        # Part III: Invalid case with two invalid arguments
        # Here I reduce the number of test cases by only picking one combination
        # of valid case
        for arg_name1 in self.para_name_list:
            index1 = self.para_name_list.index(arg_name1)
            for arg_name2 in self.para_name_list[index1 + 1 :]:
                # add those two arguments into arg_pass_in dict
                for arg1 in self.invalid_arg[arg_name1]:
                    self.form_one_valid_arg()
                    self.update_arg_pass_in(arg_name1, arg1, 0)
                    self.arg_pass_in_msg.append(
                        self.invalid_arg_msg[arg_name1][self.invalid_arg[arg_name1].index(arg1)]
                    )
                    for arg2 in self.invalid_arg[arg_name2]:
                        self.update_arg_pass_in(arg_name2, arg2, 0)
                        self.arg_pass_in_msg.append(
                            self.invalid_arg_msg[arg_name2][self.invalid_arg[arg_name2].index(arg2)]
                        )
                        # Determine the expected result
                        exp_result = self.result_det(self.arg_pass_in_msg)
                        # Use zip(dict.keys(), dict.values())
                        # can convert dict into a list of tuples
                        self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                        # Need to upload a file, set flag to 1
                        # to change the type of HTTP request
                        self.http.request(1)
                        self.total_case = self.total_case + 1
                        # Print status
                        print "Processing Case ID {0}.\n{1}% to finish Campaign Update API.".format(
                            "CD" + str(self.total_case), self.total_case * 100 / TOTAL_CASE
                        )
                        # check the response
                        self.err_response_check(exp_result)
                        # update arg_pass_in and arg_pass_in_msg
                        self.update_arg_pass_in(arg_name2, arg2, 1)
                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg) - 1)
 def blackbox_test(self):
     # All the combination of test cases
     # Special cases for 'Wrong argument name' and 'Missing Argument'
     # argument: user
     for u in self.arg['user']:
         self.arg_pass_in = {}
         self.arg_pass_in_msg = []
         if u == 'user1':
             self.arg_pass_in['user1'] = gconst.USERNAME
         elif u != gconst.MISS:
             self.arg_pass_in['user'] = u
         # append the corresponding message into the msg list
         self.arg_pass_in_msg.append(self.arg_msg['user'][self.arg['user'].index(u)])
         # argument: password
         for p in self.arg['password']:
             if p == 'password1':
                 self.arg_pass_in['password1'] = gconst.PASSWORD
             elif p != gconst.MISS:
                 self.arg_pass_in['password'] = p
             # append the corresponding message into the msg list
             self.arg_pass_in_msg.append(self.arg_msg['password'][self.arg['password'].index(p)])
             # argument: client
             for c in self.arg['client']:
                 if c == 'client1':
                     self.arg_pass_in['client1'] = 'curl'
                 elif c != gconst.MISS:
                     self.arg_pass_in['client'] = c
                 # append the corresponding message into the msg list
                 self.arg_pass_in_msg.append(self.arg_msg['client'][self.arg['client'].index(c)])
                 # check for the expected
                 exp_result = self.result_det(self.arg_pass_in_msg)
                 # HTTP request part
                 # Increment the total and invalid cases at the same time
                 self.http.set_pass_in(self.arg_pass_in)
                 self.http.request(0)
                 self.total_case = self.total_case + 1
                 # Print status
                 print 'Processing Case ID {0}.\n{1}% to finish auth_token API.'.format('A'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                 if exp_result == 'v':
                     if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                         HTTP.write_err_report(self.err_report,\
                                               'A'+str(self.total_case),\
                                               self.arg_pass_in,\
                                               self.http.contents,\
                                               '{"result": "success", "token":...}')
                         # increment the invalid case id list and unexpected case counter
                         self.invalid_case_id_list.append('A'+str(self.total_case))
                         self.unexpect_case = self.unexpect_case + 1
                     else:
                         HTTP.write_succ_report(self.succ_report,\
                                                'A'+str(self.total_case),\
                                                self.arg_pass_in,\
                                                self.http.contents)
                 elif exp_result == gconst.AUTH_FAIL:
                     if (self.http.http_code != 200) or \
                        (self.http.cont_dict['result'] != 'failure') or \
                        (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
                         HTTP.write_err_report(self.err_report,\
                                               'A'+str(self.total_case),\
                                               self.arg_pass_in,\
                                               self.http.contents,\
                                               gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
                         # increment the invalid case id list and unexpected case counter
                         self.invalid_case_id_list.append('A'+str(self.total_case))
                         self.unexpect_case = self.unexpect_case + 1
                     else:
                         HTTP.write_succ_report(self.succ_report,\
                                                'A'+str(self.total_case),\
                                                self.arg_pass_in,\
                                                self.http.contents)
                 else:
                     print >> sys.stderr, 'Error: expectation error in Auth_token'
                     sys.exit(1)
                 # update arg_pass_in and arg_pass_in_msg
                 if c == 'client1':
                     del self.arg_pass_in['client1']
                 elif c != gconst.MISS:
                     del self.arg_pass_in['client']
                 self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
             # update arg_pass_in and arg_pass_in_msg
             if p == 'password1':
                 del self.arg_pass_in['password1']
             elif p != gconst.MISS:
                 del self.arg_pass_in['password']
             self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
         # update arg_pass_in and arg_pass_in_msg
         if u == 'user1':
             del self.arg_pass_in['user1']
         elif u != gconst.MISS:
             del self.arg_pass_in['user']
         self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
 def blackbox_test(self):
     # Should create a new campaign first
     HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN)
     # Combination of three kinds of test cases defined in README
     # Part I: Valid Case
     for a in self.valid_arg['auth_token']:
         self.arg_pass_in = {}
         self.arg_pass_in_msg = []
         self.arg_pass_in['auth_token'] = a
         self.arg_pass_in_msg.append(self.valid_arg_msg['auth_token'][0])
         for clt in self.valid_arg['client']:
             self.arg_pass_in['client'] = clt
             self.arg_pass_in_msg.append(self.valid_arg_msg['client'][self.valid_arg['client'].index(clt)])
             for camp in self.valid_arg['campaign_urn']:
                 self.arg_pass_in['campaign_urn'] = camp
                 self.arg_pass_in_msg.append(self.valid_arg_msg['campaign_urn'][self.valid_arg['campaign_urn'].index(camp)])
                 # Determine the expected result
                 exp_result = self.result_det(self.arg_pass_in_msg)
                 # HTTP request part
                 # Increment the total and invalid cases at the same time
                 self.http.set_pass_in(self.arg_pass_in)
                 self.http.request(0)
                 self.total_case = self.total_case + 1
                 # Print status
                 print 'Processing Case ID {0}.\n{1}% to finish Campaign Delete API.'.format('CD'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                 # Check the response
                 if exp_result == 'v':
                     if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                         HTTP.write_err_report(self.err_report,\
                                               'CD'+str(self.total_case),\
                                               self.arg_pass_in,\
                                               self.http.contents,\
                                               '{"result": "success"}')
                         # increment the invalid case id list and unexpected case counter
                         self.invalid_case_id_list.append('CD'+str(self.total_case))
                         self.unexpect_case = self.unexpect_case + 1
                     else:
                         HTTP.write_succ_report(self.succ_report,\
                                                'CD'+str(self.total_case),\
                                                self.arg_pass_in,\
                                                self.http.contents)
                         # need to create the campaign with expected deleting
                         result = HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN)
                         if result != 'success':
                             print >> sys.stderr, 'Error: Cannot create a new campaign'
                             sys.exit(1)
                 else:
                     print >> sys.stderr, 'Error: Invalid valid test case'
                     sys.exit(1)
                 # update arg_pass_in and arg_pass_in_msg
                 del self.arg_pass_in['campaign_urn']
                 self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
             # update arg_pass_in and arg_pass_in_msg
             del self.arg_pass_in['client']
             self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)         
         # update arg_pass_in and arg_pass_in_msg
         del self.arg_pass_in['auth_token']
         self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                 
     ########################################################################
     ########################################################################    
     # Part II: Invalid case with one invalid argument
     for para in self.para_name_list:
         index = self.para_name_list.index(para)
         arg = []
         # each turn pick one as invalid argument
         self.para_name_list.remove(para)
         # store the only one invalid argument
         arg.append(para)
         # store all other valid arguments
         for x in range(1,3):
             arg.append(self.para_name_list[x-1])
         # Add first argument
         for a0 in self.invalid_arg[arg[0]]:
             self.arg_pass_in = {}
             self.arg_pass_in_msg = []
             self.update_arg_pass_in(arg[0], a0, 0)
             self.arg_pass_in_msg.append(self.invalid_arg_msg[arg[0]][self.invalid_arg[arg[0]].index(a0)])
             # Add second arguemnt
             for a1 in self.valid_arg[arg[1]]:
                 self.update_arg_pass_in(arg[1], a1, 0)
                 self.arg_pass_in_msg.append(self.valid_arg_msg[arg[1]][self.valid_arg[arg[1]].index(a1)])
                 # Add third arguemnt
                 for a2 in self.valid_arg[arg[2]]:
                     self.update_arg_pass_in(arg[2], a2, 0)
                     self.arg_pass_in_msg.append(self.valid_arg_msg[arg[2]][self.valid_arg[arg[2]].index(a2)])
                     # Determine the expected result
                     exp_result = self.result_det(self.arg_pass_in_msg)
                     # HTTP request part
                     # Increment the total and invalid cases at the same time
                     self.http.set_pass_in(self.arg_pass_in)
                     self.http.request(0)
                     self.total_case = self.total_case + 1
                     # Print status
                     print 'Processing Case ID {0}.\n{1}% to finish Campaign Delete API.'.format('CD'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                     # check the response
                     self.err_response_check(exp_result)
                     # update arg_pass_in and arg_pass_in_msg
                     self.update_arg_pass_in(arg[2], a2, 1)
                     self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                 # update arg_pass_in and arg_pass_in_msg
                 self.update_arg_pass_in(arg[1], a1, 1)
                 self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
             # update arg_pass_in and arg_pass_in_msg
             self.update_arg_pass_in(arg[0], a0, 1)
             self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
         # restore the para_name_list
         self.para_name_list.insert(index, para)
         
     ########################################################################
     ########################################################################    
     # Part III: Invalid case with two invalid arguments
     # Get first invalid argument
     for para1 in self.para_name_list:
         index1 = self.para_name_list.index(para1)
         arg = []
         arg.append(para1)
         # each turn remove one invalid parameter from the para_name_list
         self.para_name_list.remove(para1)
         # Get second invalid argument
         for para2 in self.para_name_list[index1:]:
             index2 = self.para_name_list.index(para2)
             arg = [para1]
             arg.append(para2)
             # each turn remove one invalid parameter from the para_name_list
             self.para_name_list.remove(para2)
             # Store all other valid argument
             arg.append(self.para_name_list[0])
             # Add first argument
             for a0 in self.invalid_arg[arg[0]]:
                 self.arg_pass_in = {}
                 self.arg_pass_in_msg = []
                 self.update_arg_pass_in(arg[0], a0, 0)
                 self.arg_pass_in_msg.append(self.invalid_arg_msg[arg[0]][self.invalid_arg[arg[0]].index(a0)])
                 # Add second arguemnt
                 for a1 in self.invalid_arg[arg[1]]:
                     self.update_arg_pass_in(arg[1], a1, 0)
                     self.arg_pass_in_msg.append(self.invalid_arg_msg[arg[1]][self.invalid_arg[arg[1]].index(a1)])
                     # Add third arguemnt
                     for a2 in self.valid_arg[arg[2]]:
                         self.update_arg_pass_in(arg[2], a2, 0)
                         self.arg_pass_in_msg.append(self.valid_arg_msg[arg[2]][self.valid_arg[arg[2]].index(a2)])
                         # Determine the expected result
                         exp_result = self.result_det(self.arg_pass_in_msg)
                         # HTTP request part
                         # Increment the total and invalid cases at the same time
                         self.http.set_pass_in(self.arg_pass_in)
                         self.http.request(0)
                         self.total_case = self.total_case + 1
                         # Print status
                         print 'Processing Case ID {0}.\n{1}% to finish Campaign Delete API.'.format('CD'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                         # check the response
                         self.err_response_check(exp_result)
                         # update arg_pass_in and arg_pass_in_msg
                         self.update_arg_pass_in(arg[2], a2, 1)
                         self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                     # update arg_pass_in and arg_pass_in_msg
                     self.update_arg_pass_in(arg[1], a1, 1)
                     self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                 # update arg_pass_in and arg_pass_in_msg
                 self.update_arg_pass_in(arg[0], a0, 1)
                 self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
             # restore the para_name_list
             self.para_name_list.insert(index2, para2)
         # restore the para_name_list
         self.para_name_list.insert(index1, para1)  
 def err_response_check(self, exp_result):
     # helper function to check invalid cases response
     if exp_result == gconst.AUTH_FAIL:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.AUTH_FAIL)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.AUTH_FAIL + ": " + gconst.ERROR[gconst.AUTH_FAIL],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.CLT_TOO_LONG:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.CLT_TOO_LONG)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.CLT_TOO_LONG + ": " + gconst.ERROR[gconst.CLT_TOO_LONG],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_RUN_STATE:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_RUN_STATE)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_RUN_STATE + ": " + gconst.ERROR[gconst.INVALID_RUN_STATE],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_PRI_STATE:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_PRI_STATE)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_PRI_STATE + ": " + gconst.ERROR[gconst.INVALID_PRI_STATE],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_CLS_URN:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_CLS_URN)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_CLS_URN + ": " + gconst.ERROR[gconst.INVALID_CLS_URN],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_XML:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_XML)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_XML + ": " + gconst.ERROR[gconst.INVALID_XML],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_ROLE:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_ROLE)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_ROLE + ": " + gconst.ERROR[gconst.INVALID_ROLE],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_USERNAME:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_USERNAME)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_USERNAME + ": " + gconst.ERROR[gconst.INVALID_USERNAME],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.INVALID_CAMP_URN:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.INVALID_CAMP_URN)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.INVALID_CAMP_URN + ": " + gconst.ERROR[gconst.INVALID_CAMP_URN],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     elif exp_result == gconst.CHANGE_CAMP_ID:
         if (
             (self.http.http_code != 200)
             or (self.http.cont_dict["result"] != "failure")
             or (self.http.cont_dict["errors"][0]["code"] != gconst.CHANGE_CAMP_ID)
         ):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 gconst.CHANGE_CAMP_ID + ": " + gconst.ERROR[gconst.CHANGE_CAMP_ID],
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     # this is necessary, since we don't really have an invalid case for "description"
     # TODO: you may delete this condition when "description" has something invalid
     elif exp_result == "v":
         if (self.http.http_code != 200) or (self.http.cont_dict["result"] != "success"):
             HTTP.write_err_report(
                 self.err_report,
                 "CU" + str(self.total_case),
                 self.arg_pass_in,
                 self.http.contents,
                 '{"result": "success"}',
             )
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append("CU" + str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(
                 self.succ_report, "CU" + str(self.total_case), self.arg_pass_in, self.http.contents
             )
     else:
         print >> sys.stderr, "Error: Unexpected invalid test case"
         sys.exit(1)
 def err_response_check(self, exp_result):
     # helper function to check invalid cases response
     if exp_result == gconst.AUTH_FAIL:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
             HTTP.write_err_report(self.err_report,\
                                   'CD'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CD'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' delete campaign, need to create a new campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot create a new campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CD'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.CLT_TOO_LONG:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.CLT_TOO_LONG):
             HTTP.write_err_report(self.err_report,\
                                   'CD'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.CLT_TOO_LONG+': '+gconst.ERROR[gconst.CLT_TOO_LONG])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CD'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' delete campaign, need to create a new campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot create a new campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CD'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_CAMP_URN:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CAMP_URN):
             HTTP.write_err_report(self.err_report,\
                                   'CD'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_CAMP_URN+': '+gconst.ERROR[gconst.INVALID_CAMP_URN])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CD'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' delete campaign, need to create a new campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot create a new campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CD'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     else:
         print >> sys.stderr, 'Error: Unexpected invalid test case'
         sys.exit(1)
 def blackbox_test(self):
     # Make sure no pre-existing campaign with campaign urn:
     # 'urn:campaign:ca:ucla:Mobilize:July:2011:Test'
     HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
     # Complete testing on 241 testing xml
     for x in range(1,242):
         FILE_PATH = XML_PATH + '/xml' + str(x) + '.xml'
         self.arg_pass_in['xml'] = (pycurl.FORM_FILE, FILE_PATH)
         # Use zip(dict.keys(), dict.values())
         # can convert dict into a list of tuples
         self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
         # Need to upload a file, set flag to 1
         # to change the type of HTTP request
         self.http.request(1)
         self.total_case = self.total_case + 1
         # Print status
         print 'Processing Case ID {0}.\n{1}% to finish XML Schema Testing.'.format('XML'+str(self.total_case), self.total_case*100/TOTAL_CASE)
         print self.http.contents
         # check response
         if self.exp_result[x] == 'success':
             if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                 HTTP.write_err_report(self.err_report,\
                                       'XML'+str(self.total_case),\
                                       self.arg_pass_in,\
                                       self.http.contents,\
                                       '{"result": "success"}')
                 # increment the invalid case id list and unexpected case counter
                 self.invalid_case_id_list.append('XML'+str(self.total_case))
                 self.unexpect_case = self.unexpect_case + 1
             else:
                 HTTP.write_succ_report(self.succ_report,\
                                        'XML'+str(self.total_case),\
                                        self.arg_pass_in,\
                                        self.http.contents)
                 # need to delete the campaign after writing the success report
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             # Need to check whether expected string is a substring of result
             print self.http.contents.find(self.exp_result[x])
             if (self.http.http_code != 200) or \
                (self.http.cont_dict['result'] != 'failure') or \
                (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_XML) or \
                (self.http.contents.find(self.exp_result[x]) == -1):
                 HTTP.write_err_report(self.err_report,\
                                       'XML'+str(self.total_case),\
                                       self.arg_pass_in,\
                                       self.http.contents,\
                                       gconst.INVALID_XML+': '+self.exp_result[x])
                 # increment the invalid case id list and unexpected case counter
                 self.invalid_case_id_list.append('XML'+str(self.total_case))
                 self.unexpect_case = self.unexpect_case + 1
                 # Although unexpected success, still need to delete the original campaign
                 if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                     result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                     if result != 'success':
                         print >> sys.stderr, 'Error: Cannot delete existing campaign'
                         sys.exit(1)
             else:
                 HTTP.write_succ_report(self.succ_report,\
                                        'XML'+str(self.total_case),\
                                        self.arg_pass_in,\
                                        self.http.contents)
    def blackbox_test(self):
        # Should delete the old campaign first
        HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)

        # Combination of three kinds of test cases defined in README
        # Special cases for 'Missing Argument' of argument 'description'
        # Part I: Valid Case
        for a in self.valid_arg['auth_token']:
            self.arg_pass_in = {}
            self.arg_pass_in_msg = []
            self.arg_pass_in['auth_token'] = a
            self.arg_pass_in_msg.append(self.valid_arg_msg['auth_token'][0])
            for clt in self.valid_arg['client']:
                self.arg_pass_in['client'] = clt
                self.arg_pass_in_msg.append(self.valid_arg_msg['client'][self.valid_arg['client'].index(clt)])
                for run in self.valid_arg['running_state']:
                    self.arg_pass_in['running_state'] = run
                    self.arg_pass_in_msg.append(self.valid_arg_msg['running_state'][self.valid_arg['running_state'].index(run)])
                    for pri in self.valid_arg['privacy_state']:
                        self.arg_pass_in['privacy_state'] = pri
                        self.arg_pass_in_msg.append(self.valid_arg_msg['privacy_state'][self.valid_arg['privacy_state'].index(pri)])
                        for cls in self.valid_arg['class_urn_list']:
                            self.arg_pass_in['class_urn_list'] = cls
                            self.arg_pass_in_msg.append(self.valid_arg_msg['class_urn_list'][self.valid_arg['class_urn_list'].index(cls)])
                            for xml in self.valid_arg['xml']:
                                self.arg_pass_in['xml'] = xml
                                self.arg_pass_in_msg.append(self.valid_arg_msg['xml'][self.valid_arg['xml'].index(xml)])
                                for des in self.valid_arg['description']:
                                    self.update_arg_pass_in('description', des, 0)
                                    self.arg_pass_in_msg.append(self.valid_arg_msg['description'][self.valid_arg['description'].index(des)])
                                    # Determine the expected result
                                    exp_result = self.result_det(self.arg_pass_in_msg)
                                    # Use zip(dict.keys(), dict.values())
                                    # can convert dict into a list of tuples
                                    self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                                    # Need to upload a file, set flag to 1
                                    # to change the type of HTTP request
                                    self.http.request(1)
                                    self.total_case = self.total_case + 1
                                    # Print status
                                    print 'Processing Case ID {0}.\n{1}% to finish Campaign Create API.'.format('CC'+str(self.total_case), \
                                          self.total_case*100/TOTAL_CASE)
                                    # Check the response
                                    if exp_result == 'v':
                                        if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                                            HTTP.write_err_report(self.err_report,\
                                                                  'CC'+str(self.total_case),\
                                                                  self.arg_pass_in,\
                                                                  self.http.contents,\
                                                                  '{"result": "success"}')
                                            # increment the invalid case id list and unexpected case counter
                                            self.invalid_case_id_list.append('CC'+str(self.total_case))
                                            self.unexpect_case = self.unexpect_case + 1
                                        else:
                                            HTTP.write_succ_report(self.succ_report,\
                                                                   'CC'+str(self.total_case),\
                                                                   self.arg_pass_in,\
                                                                   self.http.contents)
                                            # need to delete the campaign after expected creation
                                            result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                                            if result != 'success':
                                                print >> sys.stderr, 'Error: Cannot delete existing campaign'
                                                sys.exit(1)
                                    else:
                                        print >> sys.stderr, 'Error: Invalid valid test case'
                                        sys.exit(1)
                                    # update arg_pass_in and arg_pass_in_msg
                                    self.update_arg_pass_in('description', des, 1)
                                    self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                                # update arg_pass_in and arg_pass_in_msg
                                del self.arg_pass_in['xml']
                                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                            # update arg_pass_in and arg_pass_in_msg
                            del self.arg_pass_in['class_urn_list']
                            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                        # update arg_pass_in and arg_pass_in_msg
                        del self.arg_pass_in['privacy_state']
                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                    # update arg_pass_in and arg_pass_in_msg
                    del self.arg_pass_in['running_state']
                    self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                # update arg_pass_in and arg_pass_in_msg
                del self.arg_pass_in['client']
                self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)         
            # update arg_pass_in and arg_pass_in_msg
            del self.arg_pass_in['auth_token']
            self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)

        ########################################################################
        ########################################################################    
        # Part II: Invalid case with one invalid argument
        # Here I reduce the number of test cases by only picking one combination
        # of valid case
        # pick each invalid argument once
        for arg_name in self.para_name_list:
            for arg in self.invalid_arg[arg_name]:
                # first keep all argument valid
                self.form_one_valid_arg()
                self.update_arg_pass_in(arg_name, arg, 0)
                self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name][self.invalid_arg[arg_name].index(arg)])
                # Determine the expected result
                exp_result = self.result_det(self.arg_pass_in_msg)
                # Use zip(dict.keys(), dict.values())
                # can convert dict into a list of tuples
                self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                # Need to upload a file, set flag to 1
                # to change the type of HTTP request
                self.http.request(1)
                self.total_case = self.total_case + 1
                # Print status
                print 'Processing Case ID {0}.\n{1}% to finish Campaign Create API.'.format('CC'+str(self.total_case), \
                      self.total_case*100/TOTAL_CASE)
                # check the response
                self.err_response_check(exp_result)
        
        ########################################################################
        ########################################################################    
        # Part III: Invalid case with two invalid arguments
        # Here I reduce the number of test cases by only picking one combination
        # of valid case
        for arg_name1 in self.para_name_list:
            index1 = self.para_name_list.index(arg_name1)
            for arg_name2 in self.para_name_list[index1+1:]:
                # add those two arguments into arg_pass_in dict
                for arg1 in self.invalid_arg[arg_name1]:
                    self.form_one_valid_arg()
                    self.update_arg_pass_in(arg_name1, arg1, 0)
                    self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name1][self.invalid_arg[arg_name1].index(arg1)])
                    for arg2 in self.invalid_arg[arg_name2]:
                        self.update_arg_pass_in(arg_name2, arg2, 0)
                        self.arg_pass_in_msg.append(self.invalid_arg_msg[arg_name2][self.invalid_arg[arg_name2].index(arg2)])
                        # Determine the expected result
                        exp_result = self.result_det(self.arg_pass_in_msg)
                        # Use zip(dict.keys(), dict.values())
                        # can convert dict into a list of tuples
                        self.http.set_pass_in_with_file(zip(self.arg_pass_in.keys(), self.arg_pass_in.values()))
                        # Need to upload a file, set flag to 1
                        # to change the type of HTTP request
                        self.http.request(1)
                        self.total_case = self.total_case + 1
                        # Print status
                        print 'Processing Case ID {0}.\n{1}% to finish Campaign Create API.'.format('CC'+str(self.total_case), \
                              self.total_case*100/TOTAL_CASE)
                        # check the response
                        self.err_response_check(exp_result)
                        # update arg_pass_in and arg_pass_in_msg
                        self.update_arg_pass_in(arg_name2, arg2, 1)
                        self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
 def err_response_check(self, exp_result):
     # helper function to check invalid cases response
     if exp_result == gconst.AUTH_FAIL:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.CLT_TOO_LONG:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.CLT_TOO_LONG):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.CLT_TOO_LONG+': '+gconst.ERROR[gconst.CLT_TOO_LONG])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_RUN_STATE:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_RUN_STATE):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_RUN_STATE+': '+gconst.ERROR[gconst.INVALID_RUN_STATE])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_PRI_STATE:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_PRI_STATE):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_PRI_STATE+': '+gconst.ERROR[gconst.INVALID_PRI_STATE])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_CLS_URN:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CLS_URN):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_CLS_URN+': '+gconst.ERROR[gconst.INVALID_CLS_URN])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     elif exp_result == gconst.INVALID_XML:
         if (self.http.http_code != 200) or \
            (self.http.cont_dict['result'] != 'failure') or \
            (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_XML):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   gconst.INVALID_XML+': '+gconst.ERROR[gconst.INVALID_XML])
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
             # Unexpected 'success' create campaign, need to delete the wrong campaign
             if (self.http.http_code == 200) and (self.http.cont_dict['result'] == 'success'):
                 result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
                 if result != 'success':
                     print >> sys.stderr, 'Error: Cannot delete existing campaign'
                     sys.exit(1)
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
     # this is necessary, since we don't really have an invalid case for "description"
     # TODO: you may delete this condition when "description" has something invalid
     elif exp_result == 'v':
         if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
             HTTP.write_err_report(self.err_report,\
                                   'CC'+str(self.total_case),\
                                   self.arg_pass_in,\
                                   self.http.contents,\
                                   '{"result": "success"}')
             # increment the invalid case id list and unexpected case counter
             self.invalid_case_id_list.append('CC'+str(self.total_case))
             self.unexpect_case = self.unexpect_case + 1
         else:
             HTTP.write_succ_report(self.succ_report,\
                                    'CC'+str(self.total_case),\
                                    self.arg_pass_in,\
                                    self.http.contents)
             # need to delete the campaign after writing the success report
             result = HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
             if result != 'success':
                 print >> sys.stderr, 'Error: Cannot delete existing campaign'
                 sys.exit(1)
     else:
         print >> sys.stderr, 'Error: Unexpected invalid test case'
         sys.exit(1)
   def blackbox_test(self):
       # Should refresh the server campaign with URN gconst.CAMP_URN
       HTTP.delete_camp(self.host, self.TOKEN, gconst.CAMP_URN)
       HTTP.create_camp(self.host, self.TOKEN, gconst.CLS_URN_LIST)
       # Combination of three kinds of test cases defined in README
       # Special cases for 'Wrong argument name' and 'Missing Argument'
       # Part I: Valid Case
       for a in self.valid_arg['auth_token']:
           self.arg_pass_in = {}
           self.arg_pass_in_msg = []
           self.arg_pass_in['auth_token'] = a
           self.arg_pass_in_msg.append(self.valid_arg_msg['auth_token'][0])
           for clt in self.valid_arg['client']:
               self.arg_pass_in['client'] = clt
               self.arg_pass_in_msg.append(self.valid_arg_msg['client'][self.valid_arg['client'].index(clt)])
               for camp in self.valid_arg['campaign_urn_list']:
                   self.update_arg_pass_in('campaign_urn_list', camp, 0)
                   self.arg_pass_in_msg.append(self.valid_arg_msg['campaign_urn_list'][self.valid_arg['campaign_urn_list'].index(camp)])
                   for cls in self.valid_arg['class_urn_list']:
                       self.update_arg_pass_in('class_urn_list', cls, 0)
                       self.arg_pass_in_msg.append(self.valid_arg_msg['class_urn_list'][self.valid_arg['class_urn_list'].index(cls)])
                       # Determine the expected result
                       exp_result = self.result_det(self.arg_pass_in_msg)
                       # HTTP request part
                       # Increment the total and invalid cases at the same time
                       self.http.set_pass_in(self.arg_pass_in)
                       self.http.request(0)
                       self.total_case = self.total_case + 1
                       # Print status
                       print 'Processing Case ID {0}.\n{1}% to finish User Read API.'.format('UR'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                       # Check the response
                       if exp_result == 'v':
                           if (self.http.http_code != 200) or (self.http.cont_dict['result'] != 'success'):
                               HTTP.write_err_report(self.err_report,\
                                                     'UR'+str(self.total_case),\
                                                     self.arg_pass_in,\
                                                     self.http.contents,\
                                                     '{"result": "success", "data":...}')
                               # increment the invalid case id list and unexpected case counter
                               self.invalid_case_id_list.append('UR'+str(self.total_case))
                               self.unexpect_case = self.unexpect_case + 1
                           else:
                               HTTP.write_succ_report(self.succ_report,\
                                                      'UR'+str(self.total_case),\
                                                      self.arg_pass_in,\
                                                      self.http.contents)
                       else:
                           print >> sys.stderr, 'Error: Invalid valid test case'
                           sys.exit(1)
                       # update arg_pass_in and arg_pass_in_msg
                       self.update_arg_pass_in('class_urn_list', cls, 1)
                       self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                   # update arg_pass_in and arg_pass_in_msg
                   self.update_arg_pass_in('campaign_urn_list', camp, 1)
                   self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
               # update arg_pass_in and arg_pass_in_msg
               del self.arg_pass_in['client']
               self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)         
           # update arg_pass_in and arg_pass_in_msg
           del self.arg_pass_in['auth_token']
           self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
 
       ########################################################################
       ########################################################################    
       # Part II: Invalid case with one invalid argument
       for para in self.para_name_list:
           index = self.para_name_list.index(para)
           # each turn pick one as invalid argument
           self.para_name_list.remove(para)
           arg1 = para                         # invalid arg
           arg2 = self.para_name_list[0]       # valid arg   
           arg3 = self.para_name_list[1]       # valid arg
           arg4 = self.para_name_list[2]       # valid arg
           # Add arg 1
           for a1 in self.invalid_arg[arg1]:
               self.arg_pass_in = {}
               self.arg_pass_in_msg = []
               self.update_arg_pass_in(arg1, a1, 0)
               self.arg_pass_in_msg.append(self.invalid_arg_msg[arg1][self.invalid_arg[arg1].index(a1)])
               # Add arg 2
               for a2 in self.valid_arg[arg2]:
                   self.update_arg_pass_in(arg2, a2, 0)
                   self.arg_pass_in_msg.append(self.valid_arg_msg[arg2][self.valid_arg[arg2].index(a2)])
                   # Add arg 3
                   for a3 in self.valid_arg[arg3]:
                       self.update_arg_pass_in(arg3, a3, 0)
                       self.arg_pass_in_msg.append(self.valid_arg_msg[arg3][self.valid_arg[arg3].index(a3)])
                       # Add arg 4
                       for a4 in self.valid_arg[arg4]:
                           self.update_arg_pass_in(arg4, a4, 0)
                           self.arg_pass_in_msg.append(self.valid_arg_msg[arg4][self.valid_arg[arg4].index(a4)])
                           # Result determine
                           exp_result = self.result_det(self.arg_pass_in_msg)
                           # HTTP request
                           # Increment the total and invalid cases at the same time
                           self.http.set_pass_in(self.arg_pass_in)
                           self.http.request(0)
                           self.total_case = self.total_case + 1
                           print 'Processing Case ID {0}.\n{1}% to finish User Read API.'.format('UR'+str(self.total_case), self.total_case*100/TOTAL_CASE)
                           # result check
                           if exp_result == gconst.AUTH_FAIL:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.CLT_TOO_LONG:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.CLT_TOO_LONG):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.CLT_TOO_LONG+': '+gconst.ERROR[gconst.CLT_TOO_LONG])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.NO_PERM_IN_CAMP:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CAMP):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.NO_PERM_IN_CAMP+': '+gconst.ERROR[gconst.NO_PERM_IN_CAMP])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.INVALID_CAMP_URN:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CAMP_URN):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.INVALID_CAMP_URN+': '+gconst.ERROR[gconst.INVALID_CAMP_URN])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.INVALID_CLS_URN:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CLS_URN):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.INVALID_CLS_URN+': '+gconst.ERROR[gconst.INVALID_CLS_URN])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           elif exp_result == gconst.NO_PERM_IN_CLS:
                               if (self.http.http_code != 200) or \
                                  (self.http.cont_dict['result'] != 'failure') or \
                                  (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CLS):
                                   HTTP.write_err_report(self.err_report,\
                                                        'UR'+str(self.total_case),\
                                                        self.arg_pass_in,\
                                                        self.http.contents,\
                                                        gconst.NO_PERM_IN_CLS+': '+gconst.ERROR[gconst.NO_PERM_IN_CLS])
                                   # increment the invalid case id list and unexpected case counter
                                   self.invalid_case_id_list.append('UR'+str(self.total_case))
                                   self.unexpect_case = self.unexpect_case + 1
                               else:
                                   HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                           else:
                               print >> sys.stderr, 'Error: Unexpected single argument invalid test case'
                               sys.exit(1)
                           # update arg_pass_in and arg_pass_in_msg
                           self.update_arg_pass_in(arg4, a4, 1)
                           self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                       # update arg_pass_in and arg_pass_in_msg
                       self.update_arg_pass_in(arg3, a3, 1)
                       self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                   # update arg_pass_in and arg_pass_in_msg
                   self.update_arg_pass_in(arg2, a2, 1)
                   self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
               # update arg_pass_in and arg_pass_in_msg
               self.update_arg_pass_in(arg1, a1, 1)
               self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
           # restore the para_name_list
           self.para_name_list.insert(index, para)
           
       ########################################################################
       ########################################################################    
       # Part III: Invalid case with two invalid arguments
       # Get first invalid arg
       for arg1 in self.para_name_list:
           index1 = self.para_name_list.index(arg1)
           # each turn pick one as invalid argument
           self.para_name_list.remove(arg1)
           # Get second invalid arg
           for arg2 in self.para_name_list[index1:]:          # reduce half of the redundency
               index2 = self.para_name_list.index(arg2)
               self.para_name_list.remove(arg2)
               # Get other two arg
               arg3 = self.para_name_list[0]
               arg4 = self.para_name_list[1]
               # Add arg 1
               for a1 in self.invalid_arg[arg1]:
                   self.arg_pass_in = {}
                   self.arg_pass_in_msg = []
                   self.update_arg_pass_in(arg1, a1, 0)
                   self.arg_pass_in_msg.append(self.invalid_arg_msg[arg1][self.invalid_arg[arg1].index(a1)])
                   # Add arg 2
                   for a2 in self.invalid_arg[arg2]:
                       self.update_arg_pass_in(arg2, a2, 0)
                       self.arg_pass_in_msg.append(self.invalid_arg_msg[arg2][self.invalid_arg[arg2].index(a2)])
                       # Add arg 3
                       for a3 in self.valid_arg[arg3]:
                           self.update_arg_pass_in(arg3, a3, 0)
                           self.arg_pass_in_msg.append(self.valid_arg_msg[arg3][self.valid_arg[arg3].index(a3)])
                           # Add arg 4
                           for a4 in self.valid_arg[arg4]:
                               self.update_arg_pass_in(arg4, a4, 0)
                               self.arg_pass_in_msg.append(self.valid_arg_msg[arg4][self.valid_arg[arg4].index(a4)])
                               # Result determine
                               exp_result = self.result_det(self.arg_pass_in_msg)
                               # HTTP request
                               # Increment the total and invalid cases at the same time
                               self.http.set_pass_in(self.arg_pass_in)
                               self.http.request(0)
                               self.total_case = self.total_case + 1
                               print 'Processing Case ID {0}.\n{1}% to finish User Read API.'.format('UR'+str(self.total_case), \
                                      self.total_case*100/TOTAL_CASE)
                               # Result Check
                               if exp_result == gconst.AUTH_FAIL:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.AUTH_FAIL):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.AUTH_FAIL+': '+gconst.ERROR[gconst.AUTH_FAIL])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.NO_PERM_IN_CAMP:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CAMP):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.NO_PERM_IN_CAMP+': '+gconst.ERROR[gconst.NO_PERM_IN_CAMP])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.INVALID_CAMP_URN:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CAMP_URN):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.INVALID_CAMP_URN+': '+gconst.ERROR[gconst.INVALID_CAMP_URN])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.INVALID_CLS_URN:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.INVALID_CLS_URN):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.INVALID_CLS_URN+': '+gconst.ERROR[gconst.INVALID_CLS_URN])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                              'UR'+str(self.total_case),\
                                                              self.arg_pass_in,\
                                                              self.http.contents)
                               elif exp_result == gconst.NO_PERM_IN_CLS:
                                   if (self.http.http_code != 200) or \
                                      (self.http.cont_dict['result'] != 'failure') or \
                                      (self.http.cont_dict['errors'][0]['code'] != gconst.NO_PERM_IN_CLS):
                                       HTTP.write_err_report(self.err_report,\
                                                             'UR'+str(self.total_case),\
                                                             self.arg_pass_in,\
                                                             self.http.contents,\
                                                             gconst.NO_PERM_IN_CLS+': '+gconst.ERROR[gconst.NO_PERM_IN_CLS])
                                       # increment the invalid case id list and unexpected case counter
                                       self.invalid_case_id_list.append('UR'+str(self.total_case))
                                       self.unexpect_case = self.unexpect_case + 1
                                   else:
                                       HTTP.write_succ_report(self.succ_report,\
                                                          'UR'+str(self.total_case),\
                                                          self.arg_pass_in,\
                                                          self.http.contents)
                               else:
                                   print >> sys.stderr, 'Error: Unexpected single argument invalid test case'
                                   sys.exit(1)
                               # update arg_pass_in and arg_pass_in_msg
                               self.update_arg_pass_in(arg4, a4, 1)
                               self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                           # update arg_pass_in and arg_pass_in_msg
                           self.update_arg_pass_in(arg3, a3, 1)
                           self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                       # update arg_pass_in and arg_pass_in_msg
                       self.update_arg_pass_in(arg2, a2, 1)
                       self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
                   # update arg_pass_in and arg_pass_in_msg
                   self.update_arg_pass_in(arg1, a1, 1)
                   self.arg_pass_in_msg.pop(len(self.arg_pass_in_msg)-1)
               # restore the para_name_list
               self.para_name_list.insert(index2, arg2)
           # restore the para_name_list
           self.para_name_list.insert(index1, arg1)