- 首页 > it技术 > >
requests_toolbelt|requests_toolbelt 提交 multipart/form-data
def test_update_plugin(self):
response = requests.delete(plugin_api)
assert 200 == response.status_coderesponse = requests.get(plugin_list)
assert 200 == response.status_code
logger.debug(response.content)
assert plugin_name not in response.contentm = MultipartEncoder(fields={
'files': ('analysis-pinyin-7.2.1.zip', open('analysis-pinyin-7.2.1.zip', 'rb'), 'application/zip')}
)
response = requests.post(post_api, data=https://www.it610.com/article/m, headers={'Content-Type': m.content_type})
assert 200 == response.status_coderesponse = requests.get(plugin_list)
assert 200 == response.status_code
logger.debug(response.content)
assert plugin_name in response.contentm = MultipartEncoder(fields={
'files': ('analysis-pinyin-wrong.zip', open('analysis-pinyin-wrong.zip', 'rb'), 'application/zip')}
)
response = requests.post(post_api, data=https://www.it610.com/article/m, headers={'Content-Type': m.content_type})
logger.debug(response.headers)
assert 422 == response.status_code
assert 'plugin-descriptor.properties should be located in zip / or zip elasticsearch/ directory' in \
response.headers['X-Error-Message']m = MultipartEncoder(fields={
'files': ('analysis-pinyin-7.2.2.zip', open('analysis-pinyin-7.2.2.zip', 'rb'), 'application/zip')}
)
response = requests.post(update_api, data=https://www.it610.com/article/m, headers={'Content-Type': m.content_type})
logger.debug(response.headers)
assert 200 == response.status_codem = MultipartEncoder(fields={
'files': ('analysis-pinyin-7.2.2.zip', open('analysis-pinyin-7.2.2.zip', 'rb'), 'application/zip')}
)
response = requests.post(post_api, data=https://www.it610.com/article/m, headers={'Content-Type': m.content_type})
logger.debug(response.headers)
assert 422 == response.status_code
assert 'Plugin Already Exists' in response.headers['X-Error-Message']
推荐阅读