Ejemplo n.º 1
0
    def test_guanjia_user_show(self):
        """
        test body
        :return:
        """
        # 给get或者post方法配置Http地址
        self.localConfigHttp = configHttp_new.ConfigHttp(env_old_new='old')
        # 接口地址存储在excel文件里,读取出来
        self.localConfigHttp.set_url(self.service_id)
        # set params
        # self.data['content'] = json.dumps(self.data['content'])
        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
        # AES加密
        params_miwen = encryptLib.zhiyu_des_encode(data)
        # 真正的入参
        params = {
                'client_id': '1fobqa5ofzixluyjlum7icdufabjfo25',
                '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.º 2
0
    def test_rent_decorate_lists(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
        # 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)
Ejemplo n.º 3
0
import unittest
import time
# import method
import graphcode as method
from common import configDB
person = configDB.MyDB()
class TestForgotpwd(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        print("忘记登录密码用例开始执行\n")
        cls.gr = person.get_one("SELECT * FROM user_basic WHERE user_type=1 AND mobile LIKE '1471123%'")
        cls.qy = person.get_one("SELECT * FROM user_basic WHERE user_type=2 AND mobile LIKE '1471123%'")
    def setUp(self):
        print("单条用例执行开始")
    def test01(self):
        '''个人忘记登录密码'''
        user=method.forgotpwd(self.gr['mobile'],'111111','111111')
        self.assertEqual('00000000',user['status'])
    def test02(self):
        '''两次密码不一样'''
        user = method.forgotpwd(self.gr['mobile'], '111111', '123456')
        self.assertEqual('20002018',user['status'],msg="两次密码不一样")
    def test04(self):
        '''图形验证码为空'''
        user = method.forgotpwd(self.gr['mobile'],'111111','111111','000000', 1,'')
        self.assertEqual('20001001',user['status'])
    def test05(self):
        '''图形验证码不对'''
        user = method.forgotpwd(self.gr['mobile'], '111111', '111111', '000000',1,'453465')
        self.assertEqual('20002014',user['status'])
    def test06(self):
Ejemplo n.º 4
0
#coding:gbk
import json
import unittest
import paramunittest
import readConfig as readConfig
from common import Log as Log
from common import common
from common import configHttp as ConfigHttp
from common import configDB as ConfigDB
from decimal import  Decimal
import os

login_xls = common.get_xls("userCase.xlsx", "weidu")
localReadConfig = readConfig.ReadConfig()
configHttp = ConfigHttp.ConfigHttp()
configDB = ConfigDB.MyDB()
info = {}
cookie_v = []
proDir = os.path.split(os.path.realpath(__file__))[0]

@paramunittest.parametrized(*login_xls)
class Login(unittest.TestCase):
    def setParameters(self, case_name, method, token, type, student_name, result, code, msg):
        """
        set params
        :param case_name:
        :param method:
        :param token:
        :param JSESSIONID:
        :param type:
        :param result:
Ejemplo n.º 5
0
import readConfig as readConfig
import unittest
import paramunittest
from common.Log import MyLog
from common import configHttp
from common import common
from common import configDB

localRegisterQuick_xls = common.get_xls("userCase.xlsx", "registerquick")
localReadConfig = readConfig.ReadConfig()
localConfigHttp = configHttp.ConfigHttp()
localConfigDB = configDB.MyDB()


@paramunittest.parametrized(*localRegisterQuick_xls)
class RegisterQuick(unittest.TestCase):
    def setParameters(self, case_name, method, token, email, result, code,
                      msg):
        """
        set parameters
        :param case_name:
        :param method:
        :param token:
        :param email:
        :param result:
        :param code:
        :param msg:
        :return:
        """
        self.case_name = str(case_name)
        self.method = str(method)
Ejemplo n.º 6
0
    def test_lease_community_addonehouse(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;"
        self.building_id = configDB.MyDB().zhiyu_getone(sql)
        data['building_id'] = self.building_id
        sql1 = "SELECT * FROM lp_unit WHERE community_id = '12873' ORDER BY id DESC;"
        self.unit_id = configDB.MyDB().zhiyu_getone(sql1)
        data['unit_id'] = self.unit_id
        sql2 = "SELECT * FROM lp_floor WHERE community_id = '12873' ORDER BY id DESC;"
        self.floor_id = configDB.MyDB().zhiyu_getone(sql2)
        data['floor_id'] = self.floor_id
        self.house_no = '7007'
        data['house_no'] = self.house_no
        # 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.º 7
0
from common import common
import unittest
from common import configDB

local_db = configDB.MyDB()


class TestDB(unittest.TestCase):
    def setUp(self):
        self.select_member = None
        self.select_list = []
        self.cursor = None

    def testDB(self):
        mysql = "SELECT COUNT(activity_type) FROM `rs_member_winner` WHERE email='*****@*****.**'"
        self.select_member = common.get_sql("newsitetest",
                                            "rs_member_wallet_bill",
                                            "select_member")
        self.cursor = local_db.executeSQL(self.select_member, '1933546')
        self.list = local_db.get_all(self.cursor)
        # get result list
        for l in self.list:
            self.select_list.append(l)
            print(l[2])
        print(self.select_list[4][8])

    def tearDown(self):
        # close database
        local_db.closeDB()
Ejemplo n.º 8
0
    def test_guanjia_registerlogin(self):
        """
        test body
        :return:
        """
        # 给get或者post方法配置Http地址
        self.localConfigHttp = configHttp_new.ConfigHttp(env_old_new='v1.5')
        # 接口地址存储在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
        # AES加密
        params_miwen = encryptLib.zhiyu_aes_encode_v1_5(data)
        # 真正的入参
        params = {
            'encrypt': 'APPAES',
            'client_id': '586ee968a305374e6198f6b7c293b07a',
            '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'] and self.info[
                'err_msg'] == 'success':
            token_temp = self.info['data']['access_token']
            # localReadConfig.set_headers('token_temp', token_temp)
            f = open(token_fiel_path, 'w')
            f.write(token_temp)
            print '最新token存储完成...', 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)