Esempio n. 1
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.userid = None
        self.run = RunMain()

    def test_02(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1507006626132',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secret': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '0b4c502ba647664be04dfedb32ad4f3d',
            'cid': '0'
        }
        res = self.run.run_main(url, 'POST', data)
        #print res
        self.assertEqual(res['errorCode'], 1000, "测试失败")
        print '这是第一个case'

    #@unittest.skip('test_02')
    def test_01(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1507006626132',
            'uid': '5249192',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secret': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '0b4c502ba647664be04dfedb32ad4f3d',
            'cid': '0'
        }
        res = self.run.run_main(url, 'POST', data)
        self.assertEqual(res['errorCode'], 1000, "测试失败")
        print '这是第二个case'
Esempio n. 2
0
 def run_dependent(self,case_id):
     run=RunMain()
     row_num=self.ope_excel.get_row_num(case_id)
     url=self.data.get_url(row_num)
     method=self.data.get_request_method(row_num)
     request_data=self.data.get_data_for_json(row_num)
     headers=self.data.get_headers_for_json(row_num)
     res=run.run_main(url,method,request_data,headers)
     return res
Esempio n. 3
0
    def __init__(self):
        with open("./sheet_id.conf","rb") as f:
            conf_info=eval(f.read())
        sheet_id=conf_info["sheet_id"]

        self.data=Get_data(sheet_id=sheet_id)

        self.run=RunMain()
        self.com_utl=CommonUtil()
        self.send=SendMail()
Esempio n. 4
0
class TestMethod(unittest.TestCase):

    def setUp(self):
        """每次方法,之前执行"""
        self.run = RunMain()

    def tearDown(self):
        """每次方法,之后执行"""
        print('test--->tearDown')

    def test_01(self):
        url = 'http://www.imooc.com/m/web/shizhanapi/loadmorepingjia.html?1'
        data = {'cart': '11'}
        # mock_data = mock.Mock(return_value=data)
        # self.run.rum_main = mock_data
        res = mock_test(self.run.rum_main, data, url, 'GET', data)
        # res = self.run.rum_main(url, 'GET', data)
        print(res)
        self.assertEqual(res['cart'], '11', '测试失败')
        # globals()['userid'] = 10009 全局变量,globals()是一个字典

    def test_02(self):
        # print(globals()['userid'])
        url = 'http://www.imooc.com/m/web/shizhanapi/loadmorepingjia.html?1'
        data = {'cart': '21'}
        res = self.run.rum_main(url, 'GET', data)
        self.assertEqual(res['data']['errorCode'], 1006, '测试失败')
Esempio n. 5
0
class TestMethod(unittest.TestCase):
    # @classmethod
    # def setUpClass(cls):
    #     print("类执行之前的方法")
    # @classmethod
    # def tearDownClass(cls):
    #     print("类执行之后的方法")
    def setUp(self):
        print('test ---> setup')
        self.run = RunMain()

    # # def tearDown(self):
    #     print('test -- > tearDown ')

    def test_01(self):
        print("这是第01个测试方法")
        url = 'https://m.gearbest.com/we/feed/group'
        data = {"group": 100, "page": 1, "pageSize": 10}
        res = self.run.run_main(url, 'POST', data)

        a = 0
        for i in res:
            print(a, res[a])
            a = a + 1

        if res[2] == "SUCCESS":
            print('测试通过')
Esempio n. 6
0
class TestMethod(unittest.TestCase):

    def setUp(self):#,每个case执行之前都要执行setup
        self.run = RunMain()
        #self.user_id = self.test_001()

    def test_001(self):
        url = 'http://127.0.0.1:8000/login/'
        data = {'username':'******',
        'password':'******'}

        #res = self.run.run_main(url,"POST",data)
        #print(res)
        res = mock_test(self.run.run_main,data,'POST',url,data)

        #self.assertEqual(res['user'],'sarah')
        #globals()['userid'] = 10034   #定义全局变量
        #return self.user_id
        print(res)

    @unittest.skip('test_002')    #跳过test_002的方法
    def test_002(self):
        url = 'http://127.0.0.1:8000/login/'
        data = {'username':'******',
        'password':'******'}
        res = self.run.run_main(url,"POST",data)
        print(res)
        print(userid)

    def tearDown(self):
        pass
Esempio n. 7
0
    def test_02(self):
        url = "http://t.10jqka.com.cn/manage0033t/group/addGroup/"

        data = {
            "name":globals()["errorMsg"] ,
            "ownerid": "359414791",
            "desc": "359414791",
            "numRes": "1000",
            "userRes": "2",
            "img": "http://u.thsi.cn/fileupload/data/Blog/2018/e43e707a38086e5f0925d26e5c33355e.jpg",
            "userResFile": "",

        }
        cookies = {

            "PHPSESSID": "khqqlip68b770d0ef53jnv6no4",
            "Hm_lvt_78c58f01938e4d85eaf619eae71b4ed1": "1530598132",
            "Hm_lpvt_da7579fd91e2c6fa5aeb9d1620a9b333": "1530613727",
            "Hm_lvt_da7579fd91e2c6fa5aeb9d1620a9b333": "1530598132, 1530613727",
            "Hm_lpvt_78c58f01938e4d85eaf619eae71b4ed1": "1530613727",
            "v": "ArzNJ89Ey3OPOP8vW3IONGiSjVFttWDf4ll0o5Y9yKeKYVJHvsUwbzJpRDHl"
        }

        run = RunMain(url, method="post", data=data, cookies=cookies).res
        self.assertEqual(run["errorMsg"], '创建成功', "创建失败")
Esempio n. 8
0
    def test_02(self):
        url = "https://fanyi.baidu.com/v2transapi"
        data = {
            'from': 'en',
            'to': 'zh',
            'query': 'study',
            'transtype': 'translang',
            'simple_means_flag': '3',
            'sign': '704127.941390',
            'token': '97bfaa70c157bf1166391185ee7a29ec'
        }

        headers =  {
            "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36",
            "Cookie":"BIDUPSID=ABF6830AB773673A244EF20622AF5FE4; PSTM=1531370396; BAIDUID=0E8BBB9E5383F7BCBC5FF7C7F9D8B8A5:FG=1; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; BDUSS=RRWUxDOWxlN2txcEJZZENBNjJtWlVrT210TTBPd0VJZmFxVUZtNktnNXdnLWRiQVFBQUFBJCQAAAAAAAAAAAEAAAAHEheR1dTmw9y9AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHD2v1tw9r9bdG; H_PS_PSSID=1444_21110_26350_27509; MCITY=-%3A; delPer=0; PSINO=5; BDRCVFR[feWj1Vr5u3D]=I67x6TjHwwYf0; BDORZ=B490B5EBF6F3CD402E515D22BCDA1598; ZD_ENTRY=baidu; locale=zh; to_lang_often=%5B%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%2C%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%5D; from_lang_often=%5B%7B%22value%22%3A%22zh%22%2C%22text%22%3A%22%u4E2D%u6587%22%7D%2C%7B%22value%22%3A%22en%22%2C%22text%22%3A%22%u82F1%u8BED%22%7D%5D; Hm_lvt_64ecd82404c51e03dc91cb9e8c025574=1542096145,1542096802; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1542096802",
            "X-Requested-With":"XMLHttpRequest",
            "Content - Type":"application/x-www-form-urlencoded;charset =UTF-8"
        }

        # print(type(data))
        # print(type(headers))
        response =RunMain().method_main(url,'POST',data,headers=headers)
        # print(response)
        res=json.loads(response)
        self.assertEqual(res['liju_result']['tag'],['学习', '研究', '课题', '书房', '结论', '考虑', '沉思', '努力', '想出'], '测试失败')

        print(json.dumps(res, indent=2, sort_keys=True))
Esempio n. 9
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.run = RunMain()

    def test_01(self):
        header = {
            'Content-Type':
            'application/json',
            'User-Agent':
            'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1',
            'Authorization':
            'access_key=&^Rwqq%QSSx!HTnFm9XB@pFzL&8im$;app_id=2LaqRXRQvNrVN0Nl'
        }

        url = 'http://172.16.101.35:16000/user'
        data = {
            "id_card_name": "张全-",
            "id_card_image1":
            "https://images.coralglobal.cn/20171009/3628696048878239322.JPG",
            "id_card_image2":
            "https://images.coralglobal.cn/auth_images/20190410/3628705426294555.JPG",
            "merchant": "哇",
            "mobile": "16188880002",
            "bank_account": "612888528144912",
            "id_card_no": "622222194021144911",
            "email": "*****@*****.**",
            "bank_branch": "中国银行杭州分行",
            "company_en_name": "coralglobal",
            "id_card_image3":
            "https://images.coralglobal.cn/auth_images/20190410/3628705426294555.JPG",
            "type": "1"
        }

        res1 = self.run.run_main(url, "POST", json.dumps(data), header)
        self.assertEqual(eval(res1["code"]), 1105, "测试成功")
        print(res1.json())

    def test_02(self):
        url = 'http://api.ishugui.com/asg/portal/call/265.do'
        data = {}
        res2 = self.run.run_main(url, 'POST', data)
        print("test02")
        print(res2)

    def test_03(self):
        print("我是第三个案例")
Esempio n. 10
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.run = RunMain()

    def test_01(self):
        url = 'http://op.juhe.cn/shanghai/police?key=eec88d051b6fcf5c5373f870a7b21ab9'
        data = {'key': 'ec88d051b6fcf5c5373f870a7b21ab9'}
        res = self.run.run_main(url, 'GET', data)
        self.assertEqual(res['error_code'], 10001, "测试失败")
        print("这是第一个测试")

    def test_02(self):

        url = 'http://op.juhe.cn/shanghai/police?key=eec88d051b6fcf5c5373f870a7b21ab9'
        data = {'key': 'ec88d051b6fcf5c5373f870a7b21ab9'}
        res = self.run.run_main(url, 'POST', data)
        self.assertEqual(res['error_code'], 10001, "测试失败")
        print('这是第二个测试方法')
Esempio n. 11
0
class TestMethod(unittest.TestCase):

    # 定义基本属性,使每个方法都可以调用token
    temp_token = GetToken().get_token()

    def setUp(self):
        self.run = RunMain()

    # 工厂结果列表查询
    def test_01(self):
        url = 'http://10.188.2.98:8188/ewap-auth/base/plant/querylistByPage'
        data = {
            "plantNo": "",
            "nameCn": "",
            "pageSize": "10",
            "pageIndex": 1
        }

        header = {
            "Authorization": self.temp_token,
            "Content-Type": "application/json",
        }
        res = self.run.run_main(url, 'POST', data, header)
        self.assertEqual(res['code'], '10000', "测试不通过")
        # print(res)
        # print("这是第一个case")

    def test_02(self):
        url = 'http:/ewap-auth/base/plant/querylistByPage'
        data = {
            "plantNo": "",
            "nameCn": "",
            "pageSize": "10",
            "pageIndex": 1
        }

        header = {
            "Authorization": self.temp_token,
            "Content-Type": "application/json",
        }
        res = self.run.run_main(url, 'POST', data, header)
        self.assertEqual(res['code'], '10000', "测试不通过")
Esempio n. 12
0
class GetToken:

    run = RunMain()

    # 获取token
    def get_token(self):
        url = 'http://10.188.2.98:8188/ewap-auth/system/user/login'
        data = {"no": "CXD001", "password": "******", "hostType": "WEB"}
        res = self.run.run_main(url, 'POST', data)
        token = res['results']['token']
        return token
Esempio n. 13
0
    def test_01(self):

        url = 'http://openapi.ele.me/v2/restaurants'
        data = {"consumer_key":"7284397484","sig":"e76dfee7276f0c7a382b4f0dbdad802a95c642aa","timestamp":"1374908054"}
        # print(type(data))
        respose =RunMain().method_main(url, 'GET',data)
        print(type(respose))
        res=json.loads(respose)
        # print (json.loads(respose))
      
        self.assertEqual(res["code"], 1003,'测试失败')
Esempio n. 14
0
class TestMethod(unittest.TestCase):
    """测试"""

    def setUp(self):
        self.run = RunMain()

    def tearDown(self):
        print('test--->>>tearDown')

    def test_01(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1507034803124',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0',
            'errorCode': 1001
        }
        res = self.run.run_method(url, "POST", data)
        res = json.loads(res)
        print(res)
        print("第一个case")
        self.assertEqual(res['errorCode'], 1007, '测试失败')

    def test_02(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1507034803124',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0'
        }

        res = json.loads(self.run.run_method(url, 'POST', data))
        self.assertEqual(res['errorCode'], 1007, "测试失败")
        print(res)
        print("第二个case")
Esempio n. 15
0
class RunTest(object):
    def __init__(self):
        self.runmain = RunMain()
        self.data = getData()
        self.com_util = CommonUtil()

    def run(self):
        res = None
        row_counts = self.data.get_case_lines()  # 获取excel表格行数
        # print(row_counts) 5
        print(row_counts)
        for row_count in range(1, row_counts):
            print(
                "=============================================================================="
            )
            print(row_count)
            url = self.data.get_request_url(row_count)  # y行不变遍历获取x列的请求地址
            method = self.data.get_request_method(row_count)  # y行不变遍历获取x列的请求方式
            is_run = self.data.get_is_run(row_count)  # y行不变遍历获取x列的是否运行
            data = self.data.get_request_data(
                row_count
            )  # y行不变遍历获取x列的请求数据,这里面时三次调用,依次分别是get_data_for_json丶get_key_words丶get_request_data
            # header = self.data.get_is_header
            print(eval(data))
            data = json.dumps(eval(data))
            header = {
                'Content-Type':
                'application/json',
                'User-Agent':
                'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1',
                'Authorization':
                'access_key=&^Rwqq%QSSx!HTnFm9XB@pFzL&8im$;app_id=2LaqRXRQvNrVN0Nl'
            }
            expect = int(self.data.get_expect_data(row_count))
            print('url:', url)
            print('method:', method)
            print('is_run:', is_run)
            print('data:', data)
            print("expect", expect)
            print(type(data))
            # print('header:', header)

            if is_run:
                res = self.runmain.run_main(url, method, data, header)
                if self.com_util.is_contains(expect, res):
                    print("测试通过")
                    self.data.write_reality_data(row_count, "pass")
                else:
                    print("测试失败")
                    self.data.write_reality_data(row_count, "fail")
                print("*" * 60 + "分割线" + "*" * 60)
        return res
Esempio n. 16
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.run = RunMain()

    def test_01(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1507034803124',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0',
            'errorCode': 1001
        }
        self.run.run_main = mock.Mock(return_value=data)
        res = mock_test(self.run.run_main, data, url, "POST", data)
        res = self.run.run_main(url, 'POST', data)

        print(res)
        self.assertEqual(res['errorCode'], 1001, '测试失败')
        print('test_01')

    def test_02(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1507034803124',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0'
        }
        res = self.run.run_main(url, 'POST', data)

        print(res)
        self.assertEqual(res['errorCode'], 1001, '测试失败')
        print('test_02')
Esempio n. 17
0
    def test_03(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1530065252258',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0'

        }
        response=RunMain().method_main(url,'POST',data)
        res = json.loads(response)
        self.assertEqual(res["errorCode"], 1007, '测试失败')
Esempio n. 18
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.run = RunMain()
        self.a = query()
        self.name = self.a[0]
        self.pwd = self.a[1]

    def test_01(self):
        url = 'https://class-rd.youke100.com/class_in/admin/user/login?account={n}&password={m}&isVaildCode=false'
        url = url.format(n=self.name, m=self.pwd)
        data = {}
        res1 = self.run.run_main(url, "POST", json.dumps(data))
        print(res1)
        print(type(res1))
        print(res1['statusCode'])
        self.assertEqual(res1['statusCode'], 0, "测试失败")
Esempio n. 19
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.run = RunMain()

    def test_01(self):
        url = 'http://127.0.0.1:8000/login/'
        data = {'username': '******', 'password': '******'}
        #self.run.run_main = mock.Mock(return_value=data)
        res = mock_test(self.run.run_main, data, url, 'POST', data)
        #res = self.run.run_main(url,'POST',data)
        print(res)
        self.assertEqual(res['password'], '5621232', '测试通过')

    def test_02(self):
        url = 'http://127.0.0.1:8000/login2/?username=lirundong&password=123123&token=DSADSA1111'
        res = self.run.run_main(url, 'GET')
        re = json.loads(res)
        self.assertEqual(re['user'], 'lirun2dong', '测试失败')
        print(re)
Esempio n. 20
0
class TestMethod(unittest.TestCase):
    #创建测试类的时候要继承unittest类
    def setUp(self):
        self.run = RunMain()

    def test_01(self):
        #所有的case要以test开头
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '1111111111',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0'
        }

        #self.run.run_main= mock.Mock(return_value=data)
        res = mock_test(self.run.run_main, data, url, "POST", data)

        # res =self.run.run_main(url,'POST',data)
        print(res)

        #若01的某个值在后面的case要被用到,可以声明为全局变量 globals(),见5-4 6分钟
        #testcase的执行顺序是按照字母的(非上下顺序),有依赖时注意(尽量别依赖)

    #跳过case执行,@unittest.skip('test_02')
    def test_02(self):
        url = 'http://coding.imooc.com/api/cate'
        data = {
            'timestamp': '2222222',
            'uid': '5249192',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0'
        }
        res = self.run.run_main(url, 'POST', data)
        print(res)
        print('直接返回的res类型:', type(res))
        res = json.loads(res)  #loads反序列化,把json字符串变为字典
        print('处理后的的res类型:', type(res))
        self.assertEqual(res['errorCode'], 1007, "msg ceode err")
Esempio n. 21
0
class TestMethod(unittest.TestCase):
    def setUp(self):
        self.run = RunMain()

    def test_03(self):
        url = 'http://coding.ctoedu.com/api/cate'
        data = {
            'timestamp': '1507034803124',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0',
            'errorCode': 1001
        }
        # self.run.run_main = mock.Mock(return_value=data)
        res = mock_test(self.run.run_main, data, url, "POST", data)
        # res = self.run.run_main(url,'POST',data)

        print
        res
        self.assertEqual(res['errorCode'], 1001, "测试失败")
        print
        "这是第一个case"

    # @unittest.skip('test_02')
    def test_02(self):
        url = 'http://coding.ctoedu.com/api/cate'
        data = {
            'timestamp': '1507034803124',
            'uid': '5249191',
            'uuid': '5ae7d1a22c82fb89c78f603420870ad7',
            'secrect': '078474b41dd37ddd5efeb04aa591ec12',
            'token': '7d6f14f21ec96d755de41e6c076758dd',
            'cid': '0'
        }

        res = self.run.run_main(url, 'POST', data)
        self.assertEqual(res['errorCode'], 1001, "测试失败")
        print("这是第二个case")
Esempio n. 22
0
 def setUp(self):
     self.run = RunMain()
Esempio n. 23
0
 def setUp(self):      #实例化方法
     RunMain()    # 类的实例化 后面用例不用一一执行了
     print('test-setup')
Esempio n. 24
0
	def setUp(self):
		self.run=RunMain()
Esempio n. 25
0
class Run_Test():
    def __init__(self):
        with open("./sheet_id.conf","rb") as f:
            conf_info=eval(f.read())
        sheet_id=conf_info["sheet_id"]

        self.data=Get_data(sheet_id=sheet_id)

        self.run=RunMain()
        self.com_utl=CommonUtil()
        self.send=SendMail()




    def go_on_run(self):
        pass_count=[]
        fail_count=[]
        cow_count=self.data.get_base_lines()
        for i in range(1,cow_count):
            case=self.data.get_caseid(i)
            # print("case是%s"%case)
            url=self.data.get_url(i)
            # print("url是%s" % url)
            method=self.data.get_request_method(i)
            # print("method是%s" % method)
            data=self.data.get_data_for_json(i)
            # print("data是%s" % data)
            headers = self.data.get_headers_for_json(i)
            # print("headers是%s" % headers)
            expect=self.data.get_expect_data(i)
            # print("except是%s" % expect)
            is_run=self.data.get_is_run(i)
            dep_case=self.data.is_depend(i)
            dep_two=self.data.is_dependTwo(i)
            data_fmdat=self.data.get_dat_formata(i)
            dep_cookie=self.data.is_dependCook(i)
            mysql_expect=self.data.except_mysql(i)


            if is_run=="yes":
                if dep_case != None:
                    if method == "post":
                    # 自己根据redis解决依赖
                        self.depend_data = Deppenddent_data()
                        self.depend_data.redis_isIn(dep_case)
                        dep_value=self.depend_data.get_data_key(i)
                        # print(" dep_values是%s" %dep_value)
                        dep_key=self.data.get_depent_files(i)
                        # print(" dep_key是%s" % dep_key)
                        dp_case= dep_key.split(":")[0]
                        if dp_case=="data":
                            data[dep_key.split(":")[1]]=dep_value
                        else:
                            headers["Authorization"]="Bearer "+str(dep_value)
                        if dep_two!=None:
                            self.depend_data = Deppenddent_data()
                            self.depend_data.redis_isIn(dep_two)
                            dep_value = self.depend_data.get_data_twokey(i)
                            dep_key = self.data.get_Twodepent_files(i)
                            dep_len=len(dep_key.split(":"))
                            header_ordata = dep_key.split(":")[0]
                            #以下是为了解决a接中返回的值在b接口中是一一对应但不是这个值本身 比如false  在b接口中对应的是1 这样的关系
                            if header_ordata == "data":
                                if dep_len==2:
                                    data[dep_key.split(":")[1]] = dep_value
                                else:
                                    if  dep_value==False:
                                        dep_value = 1
                                    else:
                                        dep_value = 2
                                    data[dep_key.split(":")[1]] = dep_value
                            else:
                                headers["Authorization"] = "Bearer " + dep_value
                        if  dep_cookie!=None:
                            self.depend_data = Deppenddent_data()
                            self.depend_data.redis_isIn(dep_cookie)
                             # 获取所依赖的a接口headers中的value
                            dep_value = self.depend_data.get_data_keyCookie(i)
                            # 获取b接口中的key
                            dep_key = self.data.get_CookDepent_files(i)
                            # 将接口b headers中的dep_key=dep_value
                            headers[dep_key] = dep_value
                    #老师的方法解决依赖
                    # self.depend_data = Deppenddent_data(depent_case)
                    # depend_response_data = self.depend_data.get_data_for_key(i)
                    else:
                        self.depend_data = Deppenddent_data()
                        self.depend_data.redis_isIn( dep_case)
                        dep_value = self.depend_data.get_data_key(i)
                        url=url.format(dep_value)
                elif dep_cookie!=None:
                    self.depend_data = Deppenddent_data()
                    self.depend_data.redis_isIn(dep_cookie)
                    #获取所依赖的a接口headers中的value
                    dep_value = self.depend_data.get_data_keyCookie(i)
                    #获取b接口中的key
                    dep_key = self.data.get_CookDepent_files(i)
                    #将接口b headers中的dep_key=dep_value
                    headers[dep_key]=dep_value
                    # print("headers是%s" %headers)

                res=self.run.run_main(url,method,data_fmdat,data,headers)
                res_content=res[0]
                res_headers=res[1]
                res_content=json.dumps(res_content)
                src = StrictRedis()
                src.set(case,res_content)
                case_headers=case+":headers"
                src.set(case_headers,str(res_headers))
                res_content=json.loads(res_content)
                print(res_content)

                if self.com_utl.is_contain(expect,res_content):
                    #判断是否需要进行数据库中验证

                    mysql_curso = self.data.rdom(i)
                    # print("mysql_curso 是%s" %mysql_curso)
                    if mysql_curso==None:
                        self.data.write_value(i,"pass")
                        pass_count.append(i)
                    else:

                        conn = connect(host="47.98.179.27", port=3306, user="******", password="******",
                                       database="shouji")
                        cs1 = conn.cursor()
                        count = cs1.execute(mysql_curso)

                        if count==int(mysql_expect):
                            self.data.write_value(i, "pass")
                            pass_count.append(i)
                        else:
                            self.data.write_value(i, count)
                            fail_count.append(i)

                else:
                    scend_except=self.data.get_sce_excepet(i)
                    if scend_except==None:
                        res_content=str(res_content)
                        self.data.write_value(i, res_content)
                        fail_count.append(i)
                    else:
                        if self.com_utl.is_contain(scend_except, res_content):
                            self.data.write_value(i, "pass")
                            pass_count.append(i)
                        else:
                            self.data.write_value(i, res_content)
                            fail_count.append(i)
Esempio n. 26
0
 def setUp(self):#,每个case执行之前都要执行setup
     self.run = RunMain()
Esempio n. 27
0
 def setUp(self):
     """每次方法,之前执行"""
     self.run = RunMain()
Esempio n. 28
0
 def setUp(self):
     print('test ---> setup')
     self.run = RunMain()
Esempio n. 29
0
 def setUp(self):
     self.run = RunMain()
     self.a = query()
     self.name = self.a[0]
     self.pwd = self.a[1]
Esempio n. 30
0
 def __init__(self):
     self.runmain = RunMain()
     self.data = getData()
     self.com_util = CommonUtil()
Esempio n. 31
0
 def setUp(self):
     self.userid = None
     self.run = RunMain()