Esempio n. 1
0
class TestOrder(TestCase):
    def setUp(self):
        self.r = HttpUtils()

    def tearDown(self):
        result = self.result
        self.r.logJson(jsonStr=result.text)
        assert result.status_code == 200, "请求状态码应为 200"

    def test_list(self):
        """订单列表接口
        """
        company_id = '025c647c-9281-486f-8c72-2bf18a2c1f5d'
        order_no = ''
        effective_time = ''
        failure_time = ''
        start_time = '2019-08-26'
        end_time = '2019-08-28'

        url = Order.LIST + f'?page=1&pageSize=10&companyId={company_id}&orderNo={order_no}' \
            f'&effectiveTime={effective_time}&failureTime={failure_time}&startTime={start_time}&endTime={end_time}'
        self.result = self.r.get(url)

    def test_detail(self):
        """订单详情
        """
        order_id = '097b769d-f22e-4ff7-88e1-32f55d3f643d'
        url = Order.DETAIL + f"{order_id}?page=1&pageSize=10&type=4"
        self.result = self.r.get(url)
Esempio n. 2
0
class TestRichtext(unittest.TestCase):
    """富文本编辑器中文件上传接口测试

    Arguments:
        unittest {[type]} -- [description]
    """
    def setUp(self):
        self.r = HttpUtils()
        self.files = {'file': open(filename, 'rb')}
        self.token = getToken()
        self.contentType = http.text

    def tearDown(self):
        self.r.logJson(jsonStr=self.result.text)

    def test_fastdfs(self):
        self.result = self.r.post(url=richtext.fastdfs, files=self.files)

    def test_oss(self):
        self.result = self.r.post(url=richtext.oss, files=self.files)

    def test_streamFastdfs(self):
        """流式上传
        """
        with open(filename) as file:
            self.result = self.r.post(url=richtext.streamFastdfs, data=file)
Esempio n. 3
0
class TestIndex(unittest.TestCase):
    """indexController中各个方法的测试用例
    """
    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
        }

    def tearDown(self):
        """
        执行结束恢复环境
        """
        pass

    def test_fastdfsTest(self):
        response = self.r.post(index.fastdfsTest, files=self.files)
        assert response.status_code == 200

    def test_ossTest(self):
        response = self.r.post(index.ossTest, files=self.files, data=self.data)
        assert response.status_code == 200, ''

    def test_imageTest(self):
        result = self.r.post(index.image, data=self.data)
        self.r.logJson(jsonObj=result.json())
        assert result.status_code == 200
Esempio n. 4
0
class TestAttachmentInfo(unittest.TestCase):
    def setUp(self):
        self.r = HttpUtils()
        pass

    def tearDown(self):
        pass

    def test_get(self):
        id = '20822da6-2c51-45b7-b88c-1c6c5b3749a2'
        response = self.r.get(info.get + '/' + id)
        self.r.logJson(jsonObj=response.json())

    def addTest(self, suit):
        suit.addTest()
        return suit
Esempio n. 5
0
class TestResourcePark(unittest.TestCase):
    def setUp(self):
        """
        测试用例初始化操作
        """
        self.r = HttpUtils()

    def tearDown(self):
        assert self.result.status_code == 200
        self.r.logJson(jsonStr=self.result.text)

    def test_config_json(self):
        """
        """
        data = {
            'companyId': '61e04cca-9213-451b-94ae-8d4dc2a1a5ea',
            'json': '{"resourceKey":"","resourceSecret":"","resourceEffectiveDuration":"","accountType":"1","userInfoFields":"name,fullName,email,phoneNumber,sex"}'
        }
        self.result = self.r.post(ResourcePark.CONFIG_JSON, data=data)
Esempio n. 6
0
class TestBase64(unittest.TestCase):
    """文件base64编码格式上传测试

    Arguments:
        unittest {[type]} -- [description]
    """
    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()}

    def tearDown(self):
        '用例执行完成的后置操作'
        pass

    def test_fastdfs(self):
        result = self.r.post(base64Upload.fastdfs,
                             data=self.data,
                             headers=self.header)
        self.r.logJson(jsonObj=result.json())
        assert result.status_code == 200

    def test_oss(self):
        result = self.r.post(base64Upload.oss,
                             data=self.data,
                             headers=self.header)
        self.r.logJson(jsonObj=result.json())
        assert result.status_code == 200
Esempio n. 7
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
class TestcompanyConfig(unittest.TestCase):
    def setUp(self):
        """
        测试用例初始化操作
        """
        self.r = HttpUtils()

    def tearDown(self):
        assert self.result.status_code == 200
        self.r.logJson(jsonStr=self.result.text)

    def test_callbackConfig_insert(self):
        """新增企业鉴权接口配置信息
        """
        data = {
            'companyId': '61e04cca-9213-451b-94ae-8d4dc2a1a5ea',
            'callbackUrl': 'https://test9.zhixueyun.com/#/home'
        }
        self.result = self.r.post(CompanyConfig.CALLBACK_CONFIG, data=data)

    def test_callbackConfig_update(self):
        """修改企业鉴权接口配置信息
        """
        data = {
            'companyId':
            '61e04cca-9213-451b-94ae-8d4dc2a1a5ea',
            'callbackUrl':
            'http://confluence.zhixueyun.com/pages/viewpage.action?pageId=14109785'
        }
        self.result = self.r.post(CompanyConfig.CALLBACK_CONFIG, data=data)

    def test_callbackConfig_get(self):
        """查询企业鉴权接口配置信息
        """
        company_id = '61e04cca-9213-451b-94ae-8d4dc2a1a5ea'
        url = CompanyConfig.CALLBACK_CONFIG + f'?companyId={company_id}'
        self.result = self.r.get(url)
Esempio n. 9
0
def repaire(url):
    r = HttpUtils()
    result = r.get(url=url)
    r.logJson(jsonStr=result.text)