Exemplo n.º 1
0
 def setUp(self):
     '''初始化数据'''
     '''获得token和学生编号'''
     self.conf = configFunction.get_conf()
     self.host = self.conf["domain_test"]
     phone = self.conf["phone"]
     psw = self.conf["password_test"]
     resp = login.loginByPassword(phone, psw)
     self.uToken = resp["AppendData"][0]["LoginToken"]
     self.studentCode = resp["AppendData"][0]["Code"]
     '''获得班级编号'''
     file_path = os.path.join(
         os.path.abspath('..').split('src')[0] +
         "/testFile/placeOrder.xlsx")
     workbook = xlrd.open_workbook(file_path)
     table = workbook.sheet_by_index(0)
     rows = table.nrows
     i = 1
     self.classCodes = []
     for i in range(rows):
         self.classCodes.append(table.cell(i, 0).value)
     '''获得高思币和余额'''
     balance_resp = accountBalance.accountBalance(self.uToken,
                                                  self.studentCode)
     self.goldCoin = balance_resp["AppendData"]["GoldCoin"]
     self.balance = balance_resp["AppendData"]["Balance"]
Exemplo n.º 2
0
def getVerificationCode(phone,type):
    '''
    获取验证码
    一分钟内同一手机只能获取一次验证码,连续获取6次验证码后,3小时内不能再次获取,不需要登录
    type:验证码用途,0-登录,1-修改密码,2-绑定手机号
    '''

    '''初始化数据'''
    conf = configFunction.get_conf()
    url = conf["domain_test"] + conf["verification_code"]

    '''传参'''
    p = {"phone": phone, "type": type}
    sign = sign.getSign(params = p)
    h = {"sign": sign, "partner": "10016"}

    '''发送请求'''
    resp = requests.get(url = url, params = p, headers = h)
    r = resp.json()
    code = r["AppendData"]

    '''获取成功返回验证码'''
    try:
        assert r["ResultType"] == 0
    except AssertionError:
        print("获得验证码失败,错误类型:" + str(r["ResultType"]) + ",错误信息:" + r["Message"])
    else:
        print("验证码为:" + code)
        return code
Exemplo n.º 3
0
import json
import requests
from common import getSign, enum
from config import configFunction

conf = configFunction.get_conf()
semester = enum.semester


def calcPrice(host,
              uToken,
              items,
              studentCode,
              goidCoin=None,
              balance=None,
              choosedCoupon=False,
              selectedCouponIds=None):
    '''
    计算报名指定班级的价格和享受的优惠,可以使用优惠劵
    :param uToken:token
    :param items: 班级信息
    :param studentCode: 学生编码
    :param choosedCoupon: 选择优惠券 默认未选择
    :param selectedCouponIds:优惠券编码 选填项
    :return: 响应数据
    '''
    '''初始化数据'''
    url = host + conf["calc_price"]
    '''传参'''
    d = {
        "StudentCode": studentCode,