Ejemplo n.º 1
0
    def test_lease_community_addonefloor(self):
        """
        test body
        :return:
        """
        # 给get或者post方法配置Http地址
        self.localConfigHttp = configHttp_new.ConfigHttp()
        # 接口地址存储在excel文件里,读取出来
        self.localConfigHttp.set_url(self.service_id)
        # set params
        data = json.loads(self.data)
        # 判断是否需要token
        if self.token == 1:
            f = open(token_fiel_path, 'r')
            token_tmp = f.readline()
            data['access_token'] = token_tmp
            print '获取到的最新token:', data['access_token']
        # 判断是否需要获取验证码
        if 'sms_code' in data:
            sql = localReadConfig.get_sql('sql_yzm')
            yzm = configDB.MyDB().zhiyu_yzm(sql)
            data['sms_code'] = yzm
        # 获取house_id,如果excel表格里house_id为空,则取ini文件里的house_id,否则取excel里的house_id
        if 'house_id' in data:
            if data['house_id'] == '':
                house_id = localReadConfig.get_ini('PARAMS', 'house_id')
                data['house_id'] = house_id
        # 获取时间戳
        time_now = common.get_time_now()
        data['timestamp'] = time_now
        # 查找楼栋
        sql = "SELECT * FROM lp_building WHERE community_id = '12873' ORDER BY id DESC;"
        building_id = configDB.MyDB().zhiyu_getone(sql)
        data['building_id'] = building_id
        sql1 = "SELECT * FROM lp_unit WHERE community_id = '12873' ORDER BY id DESC;"
        unit_id = configDB.MyDB().zhiyu_getone(sql1)
        data['unit_id'] = unit_id
        # AES加密
        params_miwen = encryptLib.zhiyu_aes_encode(data)
        # 真正的入参
        params = {'param': params_miwen}

        self.localConfigHttp.set_params(params)
        # 获取响应结果信息
        if self.method.lower() == 'get':
            self.response = self.localConfigHttp.get()
            print 'get'
        elif self.method.lower() == 'post':
            self.response = self.localConfigHttp.post()
            print 'post'
        # 显示响应结果信息
        common.show_return_msg(self.response)
        self.info = self.response.text
        # Json响应信息转成字典格式
        self.info = json.loads(self.info)
        # 断言返回状态码
        self.assertEqual(self.info['err_no'], self.expect_state)
        # 断言返回message
        mes_reponse = self.info['err_msg'].encode('utf-8')
        self.assertEqual(mes_reponse, self.expect_msg)
Ejemplo n.º 2
0
    def test_guanjia_rent_scatsearch(self):
        """
        test body
        :return:
        """
        # 给get或者post方法配置Http地址
        self.localConfigHttp = configHttp_new.ConfigHttp()
        # 接口地址存储在excel文件里,读取出来
        self.localConfigHttp.set_url(self.service_id)
        # set params
        data = json.loads(self.data)
        # 判断是否需要token
        if self.token == 1:
            f = open(token_fiel_path, 'r')
            token_tmp = f.readline()
            data['access_token'] = token_tmp
            print '获取到的最新token:', data['access_token']
        # 判断是否需要获取验证码
        if 'sms_code' in data:
            sql = localReadConfig.get_sql('sql_yzm')
            yzm = configDB.MyDB().zhiyu_yzm(sql)
            data['sms_code'] = yzm
        # 获取house_id,如果excel表格里house_id为空,则取ini文件里的house_id,否则取excel里的house_id
        if 'house_id' in data:
            if data['house_id'] == '':
                house_id = localReadConfig.get_ini('PARAMS', 'house_id')
                data['house_id'] = house_id
        # 获取时间戳为int型
        time_now = common.get_time_now()
        data['timestamp'] = time_now
        # AES加密
        params_miwen = encryptLib.zhiyu_aes_encode(data)
        # 真正的入参
        params = {
                  'param': params_miwen
                  }

        self.localConfigHttp.set_params(params)
        # 获取响应结果信息
        if self.method.lower() == 'get':
            self.response = self.localConfigHttp.get()
            print 'get'
        elif self.method.lower() == 'post':
            self.response = self.localConfigHttp.post()
            print 'post'
        # 显示响应结果信息
        common.show_return_msg(self.response)
        self.info = self.response.text
        # Json响应信息转成字典格式
        self.info = json.loads(self.info)
        # 存储token,只有正确登录的时候才有token
        if 'access_token' in self.info['data']:
            token_temp = self.info['data']['access_token']
            localReadConfig.set_headers('token_temp', token_temp)
        # 断言返回状态码
        self.assertEqual(self.info['err_no'], self.expect_state)
        # 断言返回message
        mes_reponse = self.info['err_msg'].encode('utf-8')
        self.assertEqual(mes_reponse, self.expect_msg)
Ejemplo n.º 3
0
    def test_lease_sign_doedit(self):
        """
        test body
        :return:
        """
        # 给get或者post方法配置Http地址
        self.localConfigHttp = configHttp_new.ConfigHttp()
        # 接口地址存储在excel文件里,读取出来
        self.localConfigHttp.set_url(self.service_id)
        # set params
        data = json.loads(self.data)
        # 判断是否需要token
        if self.token == 1:
            f = open(token_fiel_path, 'r')
            token_tmp = f.readline()
            data['access_token'] = token_tmp
            print '获取到的最新token:', data['access_token']
        # 判断是否需要获取验证码
        if 'sms_code' in data:
            sql = localReadConfig.get_sql('sql_yzm')
            yzm = configDB.MyDB().zhiyu_yzm(sql)
            data['sms_code'] = yzm
        # 获取house_id,如果excel表格里house_id为空,则取ini文件里的house_id,否则取excel里的house_id
        if 'house_id' in data:
            if data['house_id'] == '':
                house_id = localReadConfig.get_ini('PARAMS', 'house_id')
                data['house_id'] = house_id
        # 获取时间戳
        time_now = common.get_time_now()
        data['timestamp'] = time_now
        # 获取最新租约id
        sql = "SELECT id FROM fy_signing WHERE house_id = '1640616' ORDER BY id DESC;"
        zuyue_id = configDB.MyDB().zhiyu_yzm(sql)
        data['signing_id'] = zuyue_id
        print "租约id:", zuyue_id
        # AES加密
        params_miwen = encryptLib.zhiyu_aes_encode(data)
        # 真正的入参
        params = {'param': params_miwen}

        self.localConfigHttp.set_params(params)
        # 获取响应结果信息
        if self.method.lower() == 'get':
            self.response = self.localConfigHttp.get()
            print 'get'
        elif self.method.lower() == 'post':
            self.response = self.localConfigHttp.post()
            print 'post'
        # 显示响应结果信息
        common.show_return_msg(self.response)
        self.info = self.response.text
        # Json响应信息转成字典格式
        self.info = json.loads(self.info)
        # 断言返回状态码
        self.assertEqual(self.info['err_no'], self.expect_state)
        # 断言返回message
        mes_reponse = self.info['err_msg'].encode('utf-8')
        self.assertEqual(mes_reponse, self.expect_msg)
        # 断言返回具体内容
        if self.expect_result != '':
            data_reponse = self.info['data']
            name_reponse = data_reponse[0]['real_name']
            mobile_reponse = data_reponse[0]['mobile']

            self.expect_result = json.loads(self.expect_result)
            name = self.expect_result['real_name']
            mobile = self.expect_result['mobile']
            self.assertEqual(name_reponse, name)
            self.assertEqual(mobile_reponse, mobile)