Exemplo n.º 1
0
 def setUp(self):
     """
     测试用例初始化操作
     """
     self.r = HttpUtils()
     self.files = {'file': open(BASE_DIR + '/resources/test.md', 'rb')}
     self.data = {
         'id': '61e04cca-9213-451b-94ae-8d4dc2a1a5ea',
         'height': 300,
         'width': 300
     }
Exemplo n.º 2
0
 def setUp(self):
     """测试用例初始化操作
     """
     self.r = HttpUtils()
     file = open(BASE_DIR + '/resources/plant.jpg', 'rb')
     filename = file.name
     suffix = os.path.splitext(filename)[1]
     contentType = mime[suffix]
     base64_str = base64.b64encode(file.read())
     self.data = {
         'trackerServerKey': 'default',
         'contentType': contentType,
         'fileName': filename,
         'body': base64_str,
         'cutSize': '300,300'
     }
     file.close()
     self.header = {'Authorization': getToken()}
Exemplo n.º 3
0
def login(url=URL_AUTH, data=None):
    if data is None:
        return None

    r = HttpUtils()
    result = r.post(url, data=data)
    if result.status_code != 200:
        print('获取token失败')
        os._exit(0)
    token_file = open(token_json_path, 'w')
    jsonObj = json.loads(result.text)
    expires_in = jsonObj['expires_in']
    # 过期时间
    out_of_time = currentTimeMillis() + expires_in
    jsonObj['out_of_time'] = out_of_time
    jsonObj['expires_time'] = DateTime(out_of_time)
    jsonObj['create_time'] = DateTime()
    jsonStr = json.dumps(jsonObj)
    token_file.write(jsonStr)
    token_file.close()
    r.logJson(jsonStr)
    return jsonStr
Exemplo n.º 4
0
 def setUp(self):
     self.r = HttpUtils()
     self.files = {'file': open(filename, 'rb')}
     self.token = getToken()
     self.contentType = http.text
Exemplo n.º 5
0
def test():
    r = HttpUtils()
    result = r.get(URL_API)
    print(result.text)
Exemplo n.º 6
0
def repaire(url):
    r = HttpUtils()
    result = r.get(url=url)
    r.logJson(jsonStr=result.text)
Exemplo n.º 7
0
 def setUp(self):
     self.r = HttpUtils()
     pass
Exemplo n.º 8
0
# -*- coding:utf-8 -*-
import init_env

from urls import Registered, APIKEY, SECRET
from unittest import TestCase
from common.HttpUtils import HttpUtils
from common.DateUtils import currentTimeMillis
from common.md5Utils import md5_sign
from common.base_test import run_tests


r = HttpUtils()


class RegisteredTest(TestCase):
    def setUp(self) -> None:
        pass

    def tearDown(self) -> None:
        result = self.result
        print("\n接口响应:")
        r.logJson(jsonStr=result.text)
        assert result.status_code == 200, "请求状态码应为 200"

    def test_auth_register(self):
        """
        自动注册
        """
        # mock 参数
        data = {
            'token': 'd9888b78d199fb4c9e9b38d2b0c192d7',
Exemplo n.º 9
0
 def setUp(self):
     """
     测试用例初始化操作
     """
     self.r = HttpUtils()
Exemplo n.º 10
0
 def __init__(self):
     self.httpUtils = HttpUtils()