예제 #1
0
def send_request(api_name, method_type, url, headers, cookies, request):
    configHttp = ConfigHttp.ConfigHttp()
    # configHttp.logger.info("api_name:" + api_name)
    # 设置请求url/headers/request data
    # configHttp.logger.info("send_url:" + url)
    # print("send_type:", method_type)
    # print("send_url:", url)
    # configHttp.logger.info("headers:" + headers)
    # print("headers:", headers)
    # configHttp.logger.info("cookies:" + cookies)
    # print("cookies:", cookies)
    # configHttp.logger.info("request data:" + request)
    # print("request data:", request)

    configHttp.set_url(url)
    configHttp.set_headers(eval(headers))
    configHttp.set_cookies(eval(cookies))
    if method_type == "POST":
        configHttp.set_data(eval(request))
        try:
            return_json = configHttp.postWithJson()
        except Exception as err:
            print("Time out")
            return None

    elif method_type == "GET":
        configHttp.set_params(eval(request))
        try:
            return_json = configHttp.get()
        except Exception as err:
            print("Time out")
            return None
    else:
        return None
    return return_json
예제 #2
0
from utils import commons
from utils import configHttp
import readConfig as readConfig

localReadConfig = readConfig.ReadConfig()
localConfigHttp = configHttp.ConfigHttp()
localLogin_xls = commons.get_xls("userCase.xlsx", "login")
localAddAddress_xls = commons.get_xls("userCase.xlsx", "addAddress")


# login
def login():
    """
    login
    :return: token
    """
    # set url
    url = commons.get_url_from_xml('login')
    localConfigHttp.set_url(url)

    # set header
    token = localReadConfig.get_headers("token_v")
    header = {"token": token}
    localConfigHttp.set_headers(header)

    # set param
    data = {"email": localLogin_xls[0][3],
            "password": localLogin_xls[0][4]}
    localConfigHttp.set_data(data)

    # login
예제 #3
0
import sys
import time

BASE_DIR = os.path.dirname(
    os.path.dirname(os.path.dirname(os.path.abspath(__file__))))  # __file__获取执行文件相对路径,整行为取上一级的上一级目录
sys.path.append(BASE_DIR)  # 添加路径
import unittest
import readConfig as readConfig
from utils.Log import MyLog
from utils import common
from utils import configHttp
from utils.encryptUtils import encryptJAVA
from utils.encryptUtils import md5

localReadConfig = readConfig.ReadConfig()
configHttp = configHttp.ConfigHttp()
info = {}


class LoginRegister(unittest.TestCase):

    def description(self):
        """
        test report description
        :return:
        """
        self.case_name

    def setUp(self):
        """