예제 #1
0
    def test_002(self):
        print(self._storeid, self._JSESSIONID, self._access_token)
        url = 'http://192.168.1.137:8080/sold/app/orders/categorylist'
        data = {
            'storeId':self._storeid
        }
        header = {
            # 'JSESSIONID': str(self._JSESSIONID),
            "Authorization":self._access_token,
            "jsessionid":self._JSESSIONID
            # 'Authorization': str(self._access_token)
        }
        # _respons = GetRessponse(_url,_data,'post').getResponse()
        _respons = RunMethod().run_main('post',url,data,header)

        #
        # respones_data = requests.post(url,data=data,headers=header).json()
        print(json.dumps(_respons, ensure_ascii=False, sort_keys=True, indent=2))


        # _suatuscose = AnalysisResponse(_respons).getstatuscode
        # 验证http状态码200
        # self.assertEqual(200,_suatuscose, '_suatuscose is error')
        # 验证resuit返回状态码200
        self.assertEqual('200',_respons['result']['code'],msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('登录成功!',self._respons['result']['message'],msg="_response['result']['code'] is error")
예제 #2
0
class DependentData:
    def __init__(self, case_id):
        self.opera_excel = OperationExcel()
        self.case_id = case_id
        self.run_method = RunMethod()
        self.data = GetData()

    #通过case_id去获取该case_id的整行数据
    def get_case_line_data(self):
        rows_data = self.opera_excel.get_rows_data(self.case_id)
        return rows_data

    #执行依赖测试,获取结果
    def run_dependent(self):
        row_num = self.opera_excel.get_row_num(self.case_id)
        request_data = self.data.get_data_for_json(row_num)
        header = self.data.is_header(row_num)
        method = self.data.get_request_method(row_num)
        url = self.data.get_request_url(row_num)
        res = self.run_method.run_main(method, url, request_data, header)
        return res

    #根据依赖的key去获取执行一来测试case的相应,然后返回
    def get_data_for_key(self, row):
        depend_data = self.data.get_depend_key(row)
        response_data = self.run_dependent()
        json_exe = parse(depend_data)
        madle = json_exe.find(response_data)
        '''  
        for i in madle:
            print(i.value)
        '''
        # 这是一个for循环,普通for循环的简写
        return [math.value for math in madle][0]
예제 #3
0
    def test_001(self):
        _url = 'http://192.168.1.137:8080/sold/app/login'
        # 请求参数
        _data = {
            'code': '111111',
            'mob': '17800000000',
            'positionX': '116.480153',
            'positionY': '39.997075',
        }

        self._respons = RunMethod().run_main('post', _url, _data)
        # _response = _respons.json()


        # print(json.dumps(_respons,ensure_ascii=False,sort_keys=True,indent=2))

        # _suatuscose = AnalysisResponse(_respons).getstatuscode
        # 验证http状态码200
        # self.assertEqual(200,_suatuscose,'suatuscose is error')
        # 验证resuit返回状态码200
        self.assertEqual(200,self._respons['result']['code'], msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('登录成功!',self._respons['result']['message'], msg="_response['result']['code'] is error")
        # print(res)
        # 设置全局变量,把参数传给下条Case
        globals()['response'] = self._respons
예제 #4
0
파일: client.py 프로젝트: Lsm666777/python
    def test_delete_client003(self):
        # store_id = globals()['key']

        url = 'http://192.168.1.137:8080/sold/app/customer/del'
        data = {
            'storeId': self._storeid,
            'id': array,
        }
        header = {
            "Authorization": self._access_token,
            "jsessionid": self._JSESSIONID
        }
        _respons = RunMethod().run_main('post', url, data, header)
        # 将返回参数转换为json格式

        # 验证http状态码200
        # self.assertEqual(200, AnalysisResponse(_respons).getstatuscode, 'suatuscose is error')
        # 验证result返回状态码200

        self.assertEqual('200',
                         str(_respons['result']['code']),
                         msg="_response['result']['code' is error")
        # 验证result返回信息
        self.assertEqual('获取成功!',
                         str(_respons['result']['message']),
                         msg="_response['result']['message'] is error")
예제 #5
0
파일: client.py 프로젝트: Lsm666777/python
    def test_add_client002(self):
        print(a)

        url = 'http://192.168.1.137:8080/sold/app/customer/add'
        data = {
            'storeId': self._storeid,
            'phone': 13277884565,
            'name': '王12先',
            'address': '北京市朝阳区',
            'ID_number': ''
        }
        header = {
            "Authorization": self._access_token,
            "jsessionid": self._JSESSIONID
        }
        _respons = RunMethod().run_main('post', url, data, header)

        # 验证http状态码200
        # self.assertEqual(200, AnalysisResponse(_respons).getstatuscode, 'suatuscose is error')
        # 验证result返回状态码200

        self.assertEqual('200',
                         str(_respons['result']['code']),
                         msg="_response['result']['code' is error")
        # 验证result返回信息
        self.assertEqual('添加客户成功!',
                         str(_respons['result']['message']),
                         msg="_response['result']['message'] is error")
예제 #6
0
파일: login.py 프로젝트: Lsm666777/python
 def test_get_code003(self):
     url = "http://192.168.1.137:8080/sold/app/getcode"
     data = {'mob': '13212345678'}
     response = RunMethod().run_main('post', url, data)
     self.assertEqual(200,
                      response['result']['code'],
                      msg="response['result']['code'] is error")
     self.assertEqual('获取验证码成功!',
                      response['result']['message'],
                      msg="response['result']['message'] is error")
예제 #7
0
파일: login.py 프로젝트: Lsm666777/python
 def test_store_setting004(self):
     url = "http://192.168.1.137:8080/sold/app/getcode"
     data = {'storeId': '42'}
     header = {
         "Authorization": self._access_token,
         "jsessionid": self._JSESSIONID
     }
     response = RunMethod().run_main('post', url, data, header)
     self.assertEqual(200,
                      response['result']['code'],
                      msg="response['result']['code'] is error")
     self.assertEqual('获取门店详情成功!',
                      response['result']['message'],
                      msg="response['result']['message'] is error")
예제 #8
0
파일: client.py 프로젝트: Lsm666777/python
 def setUp(self):
     url = 'http://192.168.1.137:8080/sold/app/login'
     # 请求参数
     data = {
         'code': '111111',
         'mob': '17800000000',
         'positionX': '116.480153',
         'positionY': '39.997075',
     }
     self._respons = RunMethod().run_main('post', url, data)
     # print(json.dumps(self._respons, ensure_ascii=False, sort_keys=True, indent=2))
     globals()['response'] = self._respons
     self._storeid = globals()['response']["data"]["storeId"]
     self._JSESSIONID = globals()['response']["data"]["jsessionid"]
     self._access_token = globals()['response']["data"]["access_token"]
예제 #9
0
    def test_case01(self):
        url = 'http://192.168.1.137:8080/sold/app/item/addcategory'
        # 请求参数
        data = {'storeId': self._storeid, 'name': '山1'}
        header = {
            "Authorization": self._access_token,
            "jsessionid": self._JSESSIONID
        }
        _respons = RunMethod().run_main('post', url, data, header)

        # 验证resuit返回状态码200
        self.assertEqual('200',
                         _respons['result']['code'],
                         msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('添加分类成功!',
                         _respons['result']['message'],
                         msg="_response['result']['code'] is error")
예제 #10
0
    def test_case004(self):
        url = 'http://192.168.1.137:8080/sold/app/item/variety'
        # 请求参数
        data = {'id': '1', 'pageNo': '1', 'pageSize': '10'}
        header = {
            "Authorization": self._access_token,
            "jsessionid": self._JSESSIONID
        }
        _respons = RunMethod().run_main('post', url, data, header)

        # 验证resuit返回状态码200
        self.assertEqual('200',
                         _respons['result']['code'],
                         msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('获取品种列表成功!',
                         _respons['result']['message'],
                         msg="_response['result']['code'] is error")
예제 #11
0
 def test_case02(self):
     url = 'http://192.168.1.137:8080/sold/app/item/categorylist'
     # 请求参数
     data = {'storeId': self._storeid}
     header = {
         "Authorization": self._access_token,
         "jsessionid": self._JSESSIONID
     }
     _respons = RunMethod().run_main('post', url, data, header)
     print(_respons['data'][0]['id'])
     # print(_respons)
     # 验证resuit返回状态码200
     self.assertEqual('200',
                      _respons['result']['code'],
                      msg="_response['result']['code'] is error")
     # 验证result返回信息
     self.assertEqual('获取商品分类列表成功!',
                      _respons['result']['message'],
                      msg="_response['result']['code'] is error")
예제 #12
0
파일: login.py 프로젝트: Lsm666777/python
    def test_001(self):
        _url = 'http://192.168.1.137:8080/sold/app/store/region'
        # 请求参数
        _data = {'parentId': '110101'}

        self._respons = RunMethod().run_main('post', _url, _data)

        # print(json.dumps(_respons,ensure_ascii=False,sort_keys=True,indent=2))

        # 验证http状态码200
        # self.assertEqual(200,_suatuscose,'suatuscose is error')
        # 验证resuit返回状态码200
        self.assertEqual(200,
                         self._respons['result']['code'],
                         msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('获取区域成功!',
                         self._respons['result']['message'],
                         msg="_response['result']['code'] is error")
예제 #13
0
    def test_003(self):
        url = 'http://192.168.1.137:8080/sold/app/logout'
        data = {
            'storeId':self._storeid
        }
        header = {
            "Authorization":self._access_token,
            "jsessionid":self._JSESSIONID
        }
        _respons = RunMethod().run_main('post', url, data, header)
        #将返回参数转换为json格式

        # 验证http状态码200
        # self.assertEqual(200, AnalysisResponse(_respons).getstatuscode, 'suatuscose is error')
        #验证result返回状态码200

        self.assertEqual('200',str(_respons['result']['code']),msg="_response['result']['code' is error")
        #验证result返回信息
        self.assertEqual('退出登录成功!',str(_respons['result']['message']),msg="_response['result']['message'] is error")
예제 #14
0
파일: login.py 프로젝트: Lsm666777/python
    def test_002(self):

        url = 'http://192.168.1.137:8080/sold/app/orders/categorylist'
        data = {'storeId': self._storeid}
        header = {
            "Authorization": self._access_token,
            "jsessionid": self._JSESSIONID
        }

        _respons = RunMethod().run_main('post', url, data, header)
        print(
            json.dumps(_respons, ensure_ascii=False, sort_keys=True, indent=2))

        # 验证resuit返回状态码200
        self.assertEqual(200,
                         _respons['result']['code'],
                         msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('登录成功!',
                         self._respons['result']['message'],
                         msg="_response['result']['code'] is error")
예제 #15
0
파일: RunTest.py 프로젝트: Lsm666777/python
class RunTest:
    def __init__(self):
        self.run_method = RunMethod()
        self.data = GetData()
        self.com_util = CommonUtil()
        self.depend_data = DependentData()
    #程序执行
    def go_on_run(self):
        res = None
        rows_count = self.data.get_case_lines()
        for i in range(1,rows_count):
            is_run = self.data.get_is_run(i)
            if is_run:
                url = self.data.get_request_url(i)
                method = self.data.get_request_method(i)

                request_data = self.data.get_data_for_json(i)
                expect = self.data.get_expcet_data(i)
                # print('value:'+expect)
                header = self.data.is_header(i)
                depend_case = self.data.is_depend(i)

                # if is_run:
                #     res = self.run_method.run_main(method,url,data,header)
                # return res
                if depend_case != None:
                    #获取以来的响应数据
                    depend_response_data = self.depend_data.get_data_for_key(i)
                    #获取依赖的key
                    depend_key = self.data.get_depend_field(i)
                    request_data[depend_key] = depend_response_data
                res = self.run_method.run_main(method,url,request_data,header)


                if self.com_util.is_contain(expect,res):
                    self.data.write_result(i,'pass')
                    # print("测试通过!")
                else:
                    self.data.write_result(i,'fail')
예제 #16
0
파일: client.py 프로젝트: Lsm666777/python
    def test_get_client001(self):
        url = 'http://192.168.1.137:8080/sold/app/customer/customerlist'
        data = {'storeId': self._storeid}
        header = {
            "Authorization": self._access_token,
            "jsessionid": self._JSESSIONID
        }
        _respons = RunMethod().run_main('post', url, data, header)
        # print(json.dumps(_respons,ensure_ascii=False,sort_keys=True,indent=2))
        # globals()['key'] = _respons #['data'][0]['list'][0]['id']
        array.append(_respons['data'][0]['list'][0]['id'])

        print(array)
        # 验证http状态码200
        # self.assertEqual(200, AnalysisResponse(_respons).getstatuscode, 'suatuscose is error')
        # 验证result返回状态码200

        self.assertEqual('200',
                         str(_respons['result']['code']),
                         msg="_response['result']['code'] is error")
        # 验证result返回信息
        self.assertEqual('获取成功!',
                         str(_respons['result']['message']),
                         msg="_response['result']['message'] is error")
예제 #17
0
파일: RunTest.py 프로젝트: Lsm666777/python
 def __init__(self):
     self.run_method = RunMethod()
     self.data = GetData()
     self.com_util = CommonUtil()
     self.depend_data = DependentData()
예제 #18
0
 def __init__(self, case_id):
     self.opera_excel = OperationExcel()
     self.case_id = case_id
     self.run_method = RunMethod()
     self.data = GetData()