示例#1
0
 def setUpClass(cls):
     print('{}测试开始执行'.format(cls))
     cls.mysql = ObMysql()  # 创建数据库连接
     pr = PreClass()
     pr.add()  # 借款人加标
     pr.recharge()  # 投资人登录并充值
     cls.mylog.info('-----添加回款计划测试开始执行-----')
 def userRegister(self):
     '''注册方法'''
     self.sendMCode()  # 发送短信验证码
     mysql = ObMysql('user_db')
     url = "http://120.24.235.105:9010/finance-user_info-war-1.0/ws/financeUserInfoFacade.ws?wsdl"
     verify_code = getattr(ConText, 'verify_code')
     user_id = getattr(ConText, 'username')
     pwd = getattr(ConText, 'pwd')
     mobile = getattr(ConText, 'phone')
     ip = getattr(ConText, 'client_ip')
     data = {
         "verify_code": verify_code,
         "user_id": user_id,
         "channel_id": 1,
         "pwd": pwd,
         "mobile": mobile,
         "ip": ip
     }
     client = Client(url=url)  # 建立连接
     client.service.userRegister(data)  # 发送请求
     uid = mysql.select(
         "SELECT Fuid FROM t_user_info WHERE Fuser_id= '{}'".format(
             user_id))[0][0]
     setattr(ConText, 'uid', uid)  # 将uid写进临时变量
     mysql.close()
示例#3
0
 def setUpClass(cls):
     url = ob.getstr('url', 'url') + '/member/login'
     phone = ob.getstr('login', 'phone')
     pwd = ob.getstr('login', 'pwd')
     login_data = {"mobilephone": phone, "pwd": pwd}  # 登录数据
     print('{}测试开始执行'.format(cls))
     cls.login = HttpSession(url=url, data=login_data).httprequest(
         method='post')  # 登录
     cls.ms = ObMysql()  # 创建数据库操作对象,打开数据库
     cls.mylog1.info('-----充值提现模块开始测试-----')
 def sendMCode(self):
     mysql = ObMysql(database="sms_db_45")
     url = "http://120.24.235.105:9010/sms-service-war-1.0/ws/smsFacade.ws?wsdl"
     client = Client(url=url)  # 建立连接
     client_ip = ob.getstr('register', 'client_ip')
     phone = ob.getstr('register', 'phone')
     username = ob.getstr('register', 'username')
     pwd = ob.getstr('register', 'pwd')
     data = {"client_ip": client_ip, "tmpl_id": 1, "mobile": phone}
     client.service.sendMCode(data)  # 请求
     verify_code = mysql.select(
         "SELECT Fverify_code FROM t_mvcode_info_6 WHERE Fmobile_no= '{}'".
         format(phone))[0][0]  # 获取短信验证码
     setattr(ConText, 'client_ip', client_ip)  # 将ip地址添加到临时变量
     setattr(ConText, 'phone', phone)  # 将手机号添加到临时变量
     setattr(ConText, 'username', username)  # 将用户名添加到临时变量
     setattr(ConText, 'pwd', pwd)  # 密码添加到临时变量
     setattr(ConText, 'verify_code', verify_code)  # 将短信验证码添加到临时变量
     mysql.close()
     update_phone()  # 更新配置文件
示例#5
0
    def setUpClass(cls):

        cls.mysql = ObMysql(database='user_db')  # 建立数据库连接对象
        cls.mylog.info('-----注册测试开始执行-----')
        print('{}开始测试'.format(cls))
class PreClass(object):
    '''前置条件类'''
    mysql = ObMysql()

    def register(self):
        '''注册'''
        url = "http://test.lemonban.com/futureloan/mvc/api/member/register"
        phone = ob.getstr('register', 'phone')
        pwd = ob.getstr('register', 'pwd')
        data = {"mobilephone": phone, "pwd": pwd, "regname": "zhaojian"}
        HttpSession(url=url, data=data).httprequest(method='post')  # 发送请求

        setattr(ConText, "phone", phone)  # 将注册之后的手机号码临时变量当中
        setattr(ConText, "pwd", pwd)  # 将注册之后的密码临时变量当中
        memerid = self.mysql.select(
            'SELECT id FROM member WHERE MobilePhone="{}"'.format(phone))[0][0]
        setattr(ConText, "memberId", memerid)  # 将注册之后的用户id写到临时变量当中
        update_phone()  # 更新配置文件的手机号码

    def login(self):
        '''登录'''
        self.register()  # 注册
        url = "http://test.lemonban.com/futureloan/mvc/api/member/login"
        phone = getattr(ConText, "phone")
        pwd = getattr(ConText, "pwd")
        data = {"mobilephone": phone, "pwd": pwd}
        HttpSession(url=url, data=data).httprequest(method='post')  # 发送请求

    def recharge(self, amount=20000):
        '''
        充值
        :param amount: 充值金额
        :return:
        '''
        self.login()  # 登录
        url = "http://test.lemonban.com/futureloan/mvc/api/member/recharge"
        phone = getattr(ConText, "phone")
        data = {"mobilephone": phone, "amount": amount}
        HttpSession(url=url, data=data).httprequest(method='post')  # 发送请求

    def withdraw(self, r_amount=10000, w_amount=5000):
        '''
        取现
        :param r_amount: 充值金额
        :param w_amount: 取现金额
        :return:
        '''
        self.recharge(r_amount)  # 先充值
        url = "http://test.lemonban.com/futureloan/mvc/api/member/withdraw"
        phone = getattr(ConText, "phone")
        data = {"mobilephone": phone, "amount": w_amount}
        HttpSession(url=url, data=data).httprequest(method='post')  # 发送请求

    def add(self,
            title='世界那么大,只想宅在家',
            amount=10000,
            loanrate=18.0,
            loanterm=6,
            loandatetype=0,
            repaymemtway=4,
            biddingdays=5):
        '''
        加标
        :param title:标题
        :param amount:借款金额
        :param loanrate:年利率
        :param loanterm:借款期限
        :param loandatetype:借款期限类型
        :param repaymemtway:还款方式
        :param biddingdays:竞标天数
        :return:
        '''
        self.recharge()
        url = "http://test.lemonban.com/futureloan/mvc/api/loan/add"
        memerid = getattr(ConText, "memberId")
        data = {
            "memberId": memerid,
            "title": title,
            "amount": amount,
            "loanRate": loanrate,
            "loanTerm": loanterm,
            "loanDateType": loandatetype,
            "repaymemtWay": repaymemtway,
            "biddingDays": biddingdays
        }
        HttpSession(url=url, data=data).httprequest(method='post')  # 发送请求
        loanid = self.mysql.select(
            'SELECT id FROM loan WHERE MemberId = "{}"'.format(memerid))[0][0]
        setattr(ConText, "loanId", loanid)  # 将标id写进临时变量当中
示例#7
0
Author:赵健
Date:2019-09-05
Time:22:49
E-mail:[email protected]
File:random_mobile.py
============================

"""

import random
import string
import re
from common.ob_mysql import ObMysql  # 导入操作数据库模块
from common.ob_config import ob  # 导入操作配置文件对象

mysql = ObMysql()


def random_phone():
    '''随机生成11位手机号码'''
    while True:
        phone = '13'  # 定义手机号码开头
        for i in range(9):  # 随机生成9个数字
            c = random.randint(0, 9)
            phone += str(c)
        if not mysql.find_result('SELECT * FROM member WHERE MobilePhone = {}'.
                                 format(phone)):  # 如果数据库没有该手机号
            return phone  # 返回手机号码


def random_pwd():
 def setUpClass(cls):
     print('{}测试开始执行'.format(cls))
     cls.ms = ObMysql()  # 创建数据库操作对象,打开数据库
     cls.mylog.info('-----注册登录模块开始测试-----')
    def setUpClass(cls):

        cls.mysql = ObMysql(database='sms_db_45')  # 建立数据库连接对象
        cls.mylog.info('-----短信验证码测试开始执行-----')
        print('{}开始测试'.format(cls))
Date:2019-09-05
Time:22:49
E-mail:[email protected]
File:random_mobile.py
============================

"""

import random
import string
import re

from common.ob_config import ob  # 导入操作配置文件对象
from common.ob_mysql import ObMysql

mysql = ObMysql(database='sms_db_45')


def random_phone():
    '''随机生成11位手机号码'''
    while True:
        phone_13 = '13'  # 定义手机号码开头
        phone_645 = '645'
        for i in range(6):  # 随机生成9个数字
            c = random.randint(0, 9)
            phone_13 += str(c)
        phone = phone_13 + phone_645
        if not mysql.find_result(
                "SELECT Fverify_code FROM t_mvcode_info_6 WHERE Fmobile_no= '{}'"
                .format(phone)):
            return phone  # 返回手机号码