def setUp(self):
     r = RandomUtil()
     logging.info('启动脚本文件 :  {} '.format(os.path.basename(__file__)))
     self.account = Config().get_ini_value('Global_ini', 'WebUserName')
     self.password = Config().get_ini_value('Global_ini', 'WebPwd')
     self.amount_pwd = Config().get_ini_value('Global_ini', 'amount_pwd')
     self.new_amount_pwd = r.get_random_info_str(6)
class Api_User_UpdateLoginPwd_01(unittest.TestCase):

    r = RandomUtil()
    # 获取全局运行过滤规则字典
    run_rules_dic = Config().get_run_rules_config()
    run_rules_dic.update({'ScriptName': os.path.basename(__file__)})
    # 获取测试数据
    datas = get_case_from_excel(Config().case_data_file_path, ['User'],
                                run_rules_dic, 'User')

    def setUp(self):
        logging.info('已经启动脚本文件: {}.py'.format(os.path.basename(__file__)))
        self.account = Config().get_ini_value('modify_loginpwd', 'mod_account')
        self.password = Config().get_ini_value('modify_loginpwd', 'mod_pwd')
        print(self.password)
        self.new_password = '******' + self.r.get_random_info_str(6)
        print(self.new_password)

    @data(*datas)
    def test_updateloginpwd_01(self, datas):
        self.TestCaseName = datas['CaseName']
        logging.info('开始执行用例:{}  |  运行case:{}'.format(self.TestCaseName,
                                                      self._testMethodName))
        logging.info(
            '=======================调用【用户登录】接口===================================='
        )
        LoginSessionID = login_api(self.account, self.password)
        if not LoginSessionID:
            logging.error('登录失败,请检查登录接口是否异常!')
        datas['NewVerifParmsData'].update({"OldPwd": self.password})
        datas['NewVerifParmsData'].update({
            "OkPwd": self.new_password,
            "NewPwd": self.new_password
        })
        print(datas)
        logging.info(
            '=======================调用【修改登录密码】接口===================================='
        )
        self.actual_result = http_api_requests(
            '密码相关.修改登录密码',
            Headers={"LoginSessionID": LoginSessionID},
            NewVerifParmsData=datas['NewVerifParmsData'])
        self.expected_result = datas['ExpectResult']
        try:
            check_result(self.expected_result, self.actual_result)
            result = 'pass'
            Config().set_options_value('mod_pwd',
                                       self.new_password,
                                       setions='modify_loginpwd')
        except InterfaceVerifyError:
            result = 'false'
        finally:
            write_result_data_to_excel(Config().case_data_file_path, 'User',
                                       'ID', datas['ID'], result)

    def tearDown(self):
        pass
Exemple #3
0
class Ag_Api_User_AddAccount(unittest.TestCase):
    r = RandomUtil()
    run_rules_dic = Config().get_run_rules_config()
    run_rules_dic.update({'ScriptName': os.path.basename(__file__)})
    datas = get_case_from_excel(Config().case_data_file_path, ['User'],
                                run_rules_dic, 'User')

    def setUp(self) -> None:
        logging.info('启动脚本文件 :  {}'.format(os.path.basename(__file__)))
        self.account = Config().get_ini_value('Global_ini', 'AgUserName')
        self.password = Config().get_ini_value('Global_ini', 'AgPwd')
        self.account_name = 'AGatuotest' + self.r.get_random_info_int(4)

    @data(*datas)
    def test_AG_uesr_login(self, datas):
        self._testMethodDoc = datas['CaseName']
        logging.info('开始执行用例: {} ( {} )'.format(self._testMethodDoc,
                                                self._testMethodName))
        logging.info(
            '=======================调用【后台用户登录】接口===================================='
        )
        LoginSessionID = ag_login_api(self.account, self.password)
        if not LoginSessionID:
            logging.error('后台登录失败,请检查!')
            raise
        logging.info(
            '=======================调用【后台添加账户】接口===================================='
        )
        datas['NewVerifParmsData'].update({"password": self.password})
        datas['NewVerifParmsData'].update({"accountName": self.account_name})
        datas['NewVerifParmsData'].update({
            "jsonlist":
            '[{"Key":"AccountRemark","Title":"用户备注","Value":""}]'
        })
        datas['NewVerifParmsData'].update({
            "UserKickbacks":
            '[{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09},{"FKickback":0.09}]'
        })
        self.actual_result = http_api_requests(
            '后台相关.添加账户',
            Headers={"LoginSessionID": LoginSessionID},
            server_host=Config().ag_host,
            NewVerifParmsData=datas['NewVerifParmsData'])
        self.expected_result = datas['ExpectResult']
        result = None
        try:
            check_result(self.expected_result, self.actual_result)
            result = 'pass'
            logging.info('新增用户({})成功'.format(self.account_name))
        except InterfaceVerifyError:
            result = 'false'
        finally:
            write_result_data_to_excel(Config().case_data_file_path, 'User',
                                       'ID', datas['ID'], result)

    def tearDown(self) -> None:
        pass
Exemple #4
0
class Api_User_AddAccount_Case_01(unittest.TestCase):
    r = RandomUtil()
    # 获取全局运行过滤规则字典
    run_rules_dic = Config().get_run_rules_config()
    run_rules_dic.update({"ScriptName": os.path.basename(__file__)})
    # 获取case数据
    datas = get_case_from_excel(Config().case_data_file_path, ['User'],
                                run_rules_dic, 'User')

    def setUp(self):
        logging.info('已经启动脚本文件: {}.py'.format(self.__module__))
        self.account = Config().get_ini_value('Global_ini', 'WebUserName')
        self.password = Config().get_ini_value('Global_ini', 'WebPwd')

    @data(*datas)
    def test_addaccount(self, datas):
        self.TestCaseName = datas['CaseName']
        logging.info('开始执行用例:{}  |  运行case:{}'.format(self.TestCaseName,
                                                      self._testMethodName))
        account_name = 'atuotest' + self.r.get_random_info_int(4)
        if '成功' in self.TestCaseName:
            datas['NewVerifParmsData'].update({'AccountName': account_name})
        logging.info(
            '=======================调用【用户登录】接口===================================='
        )
        LoginSessionID = login_api(self.account, self.password)
        if not LoginSessionID:
            logging.error('登录失败,请检查接口是否异常!')
        logging.info(
            '=======================调用【添加账户】接口===================================='
        )
        self.actual_result = http_api_requests(
            '用户相关.添加账户',
            Headers={"LoginSessionID": LoginSessionID},
            NewVerifParmsData=datas['NewVerifParmsData'])
        self.expected_result = datas['ExpectResult']
        try:
            check_result(self.expected_result, self.actual_result)
            result = 'pass'
            logging.info('新增用户({})成功'.format(account_name))
        except InterfaceVerifyError:
            result = 'false'
        finally:
            write_result_data_to_excel(Config().case_data_file_path, 'User',
                                       'ID', datas['ID'], result)

    def tearDown(self):
        pass
Exemple #5
0
class Api_Finance_GoPay(unittest.TestCase):
    r = RandomUtil()
    run_rules_dic = Config().get_run_rules_config()
    run_rules_dic.update({'ScriptName': os.path.basename(__file__)})
    datas = get_case_from_excel(Config().case_data_file_path, ['Finance'],
                                run_rules_dic, 'Finance')

    def setUp(self) -> None:
        logging.info('启动脚本文件 :  {}'.format(os.path.basename(__file__)))
        self.account = Config().get_ini_value('Global_ini', 'WebUserName')
        self.password = Config().get_ini_value('Global_ini', 'WebPwd')

    @data(*datas)
    def test_Finance_GoPay(self, datas):
        self._testMethodDoc = datas['CaseName']
        logging.info('开始执行用例: {} ( {} )'.format(self._testMethodDoc,
                                                self._testMethodName))
        logging.info(
            '=======================调用【用户登录】接口===================================='
        )
        self.LoginSessionID = login_api(self.account, self.password)
        if not self.LoginSessionID:
            logging.error('登录失败,请检查登录接口是否异常!')
        # 获取导航通道-线上
        payment_info = get_finance_paymentindex(
            LoginSessionID=self.LoginSessionID, paytype=1)
        logging.info('获取通道ID:{},获取通道名称:{}'.format(payment_info['ID'],
                                                  payment_info['PayType']))
        # 获取导航通道下可用商户字典信息
        payment_data = payment_PreferenceNewConfig(
            LoginSessionID=self.LoginSessionID,
            id=payment_info['ID'],
            isonline=payment_info['Type'],
            return_data=True)
        print('获取商户字典信息' + '\n', json.dumps(payment_data, indent=4))
        # 获取通道优惠设置
        preferenceNewConfig = get_payment_PreferenceNewConfig(
            LoginSessionID=self.LoginSessionID,
            Type=2,
            CashConfigId=payment_data['ID'])
        print('获取商户优惠配置信息' + '\n', json.dumps(preferenceNewConfig, indent=4))
        # 线上充值
        # 金额判断
        Amount = self.r.get_random_int(
            payment_data['MinAmount'], payment_data['MaxAmount']
        ) if not payment_data['FIsShowShortcut'] else int(
            random.choice(payment_data['FShortcutSet'].split(',')))
        logging.info(
            '=======================调用【线上充值】接口===================================='
        )
        datas['NewVerifParmsData'].update({
            "LoginSessionID": self.LoginSessionID,
            "paymentId": payment_data['ID'],
            "amount": Amount,
            "wayType": payment_data['WayType']
        })
        self.actual_result = http_api_requests(
            '充值提现.线上充值',
            Headers={"LoginSessionID": self.LoginSessionID},
            NewVerifParmsData=datas['NewVerifParmsData'])
        # 手续费判断
        IsCharge = payment_data['IsCharge']
        if IsCharge:
            Charge = Amount * payment_data['Charge']
        else:
            Charge = 0
        # 优惠判断
        preference_amount = 0
        if preferenceNewConfig['RechargePrivilege'] == 1:
            if preferenceNewConfig['IsFirst']:
                if Amount < preferenceNewConfig['PreferenceLine']:
                    preference_amount = 0
                else:
                    preference_amount = Amount * preferenceNewConfig[
                        'PreferencePercent'] / 100
                    if preference_amount >= preferenceNewConfig[
                            'PreferenceMax'] and preferenceNewConfig[
                                'PreferenceMax'] != 0.0:
                        preference_amount = preferenceNewConfig[
                            'PreferenceMax']
            else:
                preference_amount = 0
        elif preferenceNewConfig['RechargePrivilege'] == 2:
            if Amount >= preferenceNewConfig['PreferenceLine']:
                preference_amount = Amount * preferenceNewConfig[
                    'PreferencePercent'] / 100
                if preference_amount >= preferenceNewConfig[
                        'PreferenceMax'] and preferenceNewConfig[
                            'PreferenceMax'] != 0.0:
                    preference_amount = preferenceNewConfig['PreferenceMax']
        elif preferenceNewConfig['RechargePrivilege'] == 3:
            if preferenceNewConfig['IsFirst']:
                if Amount >= preferenceNewConfig['PreferenceLine']:
                    preference_amount = Amount * preferenceNewConfig[
                        'PreferencePercent'] / 100
                    if preference_amount >= preferenceNewConfig[
                            'PreferenceMax'] and preferenceNewConfig[
                                'PreferenceMax'] != 0.0:
                        preference_amount = preferenceNewConfig[
                            'PreferenceMax']
        elif preferenceNewConfig['RechargePrivilege'] == 4:
            if Amount >= preferenceNewConfig['PreferenceLine']:
                preference_amount = Amount * preferenceNewConfig[
                    'PreferencePercent'] / 100
                if preference_amount >= preferenceNewConfig[
                        'PreferenceMax'] and preferenceNewConfig[
                            'PreferenceMax'] != 0.0:
                    preference_amount = preferenceNewConfig['PreferenceMax']
        else:
            raise ('优惠数据返回有误,请检查接口数据')

        # 充值记录检查
        end_time, start_time = get_nowday_and_yestday()
        self.actual_result = http_api_requests(
            '充值提现.充值记录',
            Headers={"LoginSessionID": self.LoginSessionID},
            NewVerifParmsData={
                "EndTime": end_time,
                "StartTime": start_time,
                "OrderNum": payment_data['OrderNumber']
            })
        self.actual_result = get_json_value(self.actual_result,
                                            '/Data/ChargeRecordList')
        datas['ExpectResult'].update({
            "SerialNumber":
            str(payment_data['OrderNumber']),
            "ActualAmount":
            float(Amount + preference_amount - Charge)
        })
        self.expected_result = datas['ExpectResult']
        logging.error(
            '充值成功:充值原始金额:{},存款优惠:{},入款手续费:{},实际充值金额:{},充值订单号:{}'.format(
                Amount, preference_amount, Charge,
                Amount + preference_amount - Charge,
                payment_data['OrderNumber']))

        # 写入结果
        result = None
        try:
            check_result(self.expected_result, self.actual_result[0])
            result = 'pass'
        except InterfaceVerifyError:
            result = 'false'
        finally:
            write_result_data_to_excel(Config().case_data_file_path, 'Finance',
                                       'ID', datas['ID'], result)

    def tearDown(self) -> None:
        pass
Exemple #6
0
from Libs.http_requests import *
from Config.Config import *
import logging
from Libs.Db_Sql_Util import *
import random
from Libs.Time_Util import *
import yaml
import os
from Libs.common import *
from Verify.User.UserVerify import login_api
from Libs.Random_util import RandomUtil
from Libs.log_util import set_log
'''
游戏模块通用方法
'''
r = RandomUtil()


def get_official_game_id(retrun_all_id=False):
    '''
   调用获取首页游戏分类接口获取游戏ID
   获取官方游戏ID
   :param retrun_all_id: 返回数据(retrun_all_id为false时返回一个ID,当为trun时,返回所有ID)
   :return:
   '''
    logging.info(
        '=======================调用【获取首页游戏列表接口】接口===================================='
    )
    actual_result = http_api_requests('游戏相关.获取首页游戏列表', NewVerifParmsData={})
    data = get_json_value(actual_result, '/Data/GameData')
    game_id_list = []