def send_xml(self, path): start = datetime.datetime.now() url = "http://10.1.1.71:9999/auditcenter/api/v1/auditcenter" headers = {"Content-Type": "text/plain"} files = os.listdir(path) n = 0 for file in files: with open(os.path.join(path, file), mode='r', encoding='utf-8', buffering=True) as f: file_content = f.read() res = requests.post(url, data=file_content.encode("utf-8"), headers=headers) log.info("执行结果:{}".format(res.json())) n += 1 if n % 100 == 0: time.sleep(10) end = datetime.datetime.now() print(end - start)
def __init__(self): path = os.path.dirname(os.path.abspath(__file__)) configfile = os.path.join(path, 'config.ini') self.conf = ConfigParser() log.info('开始解析配置文件...') self.conf.read(configfile, encoding='utf8')
def req(self, content): headers = {"Content-Type": "text/plain"} res = self.client.post("/api/v1/auditcenter", data=content.encode("utf-8"), headers=headers) log.info("执行结果:{}".format(res.json()))
def get(self,field,key): data = self.conf.get(field,key) if data.isdigit(): data = int(data) log.info("读取配置文件{}-{}的值为{}".format(field,key,data)) return data
def tearDownClass(cls): log.info('------{}测试用例执行结束------'.format(cls.__doc__))
def setUpClass(cls): log.info('------开始执行{}测试用例------'.format(cls.__doc__))
def req(self, content): url = "http://10.1.1.71:9999/auditcenter/api/v1/auditcenter" headers = {"Content-Type": "text/plain"} res = requests.post(url, data=content.encode("utf-8"), headers=headers) log.info("执行结果:{}".format(res.json()))
def setUpClass(cls): log.info('------开始执行{}测试用例------'.format(cls.__doc__)) cls.g = globals() cls.base_url = config.get('auditcenter', 'url') + '/api/v1/auditPlan' cls.plan_list = config.get('auditcenter', 'url') + '/api/v1/auditPlanList' cls.plan_name = "测试审方方案"