1
我無法使用燒瓶服務創建後調用。這裏是我的代碼:無法與Pytest,Jenkins和Flask進行POST調用
def test_post_create_file(client):
fileContent = {'filename': 'TestName', 'content': 'TestContent'}
client.post('/v1.0/files', data = json.dumps(fileContent))
POST功能:
@app.route('/v1.0/files',methods=['POST'])
def read_create_file():
cont = request.get_json(silent=True)
file = cont['filename']
content = cont['content']
if not file or not content:
return "empty file or content", 404
if create_file(file, content):
return "CREATED", 200
例外:
Error Message
TypeError: 'NoneType' object is unsubscriptable
Trace
client = <FlaskClient <Flask 'e'>>
def test_post_create_file(client):
fileContent = {'filename': 'ArchivoPrueba', 'content': 'ContenidoPrueba'}
> client.post('/v1.0/files', data = json.dumps(fileContent))
test_e.py:24:
我相信這是與試圖訪問JSON對象的數組,但我不確定。