import requests
import unittest
from interface import interface
from ddt import ddt,data
import os
from pprint import pprint
import yaml
from requests.cookies import cookiejar_from_dict
import jsonpath
import json

#获取上级目录路径
path = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
# 拼接需要的目录
path = os.path.join(path,"test_yaml","modify.yaml")

# 打开文件夹 读取数据
file1 = open(path,'r', encoding="utf-8")
file2 = file1.read()
file3 = yaml.load(file2)

# print("所有数据列表陈列：开始")
# pprint(file3)
# print("所有数据列表陈列：结束"+ '\n')
#

@ddt
class Case(unittest.TestCase):
    @data(*file3)
    def test_01_customer_pool(self,contents):
        '线索详情页接口'
        # print("预期响应数据：开始")
        # pprint(contents)
        # print("预期响应数据：结束")
        URL = interface.hera_host+interface.modify
        body = contents.get("request").get("body")
        print(body)
        cookies = interface.hera_cookies
        header = {
            "content-type":"text/html"
        }
        result = requests.post(url=URL, cookies=cookiejar_from_dict(cookies), data=body,verify=False,headers=header)
        print(result)
        res = result.text
        print(res)

