title: How to send post data to flask using pytest-flask
body: <h1>Project setting</h1>
  
  <ul>
  <li>Python 3.5.3</li>
  <li>flask 0.12.2</li>
  </ul>
  
  <h1>Directory</h1>
  
  <pre><code>.
  ├── Core
  │   ├── BackgroundProcessManager.py
  │   ├── FirebaseDatabaseManager.py
  │   ├── LearningManager.py
  │   ├── __init__.py
  │  
  ├── FrontEnd
  │   ├── HomePage.py
  │   ├── __init__.py
  │  
  ├── LICENSE
  ├── README.md
  ├── Route
  │   ├── RouteManager.py
  │   ├── __init__.py
  │  
  ├── Settings
  │   ├── DefineManager.py
  │   ├── __init__.py
  │   
  ├── Utils
  │   ├── LoggingManager.py
  │   ├── __init__.py
  │   
  ├── index.py
  └── runner.sh
  </code></pre>
  
  <h1>Expected behavior</h1>
  
  <ul>
  <li><p>All the route link is in <code>Route/RouteManager.py</code></p></li>
  <li><p>Flask main source is in <code>index.py</code></p></li>
  <li><p>I want send fake request and test response using <code>pytest-flask</code>.</p></li>
  </ul>
  
  <h1>Actual behavior</h1>
  
  <ul>
  <li>I don't know how to send fake post data and testing.</li>
  </ul>
  
  <h1>Source</h1>
  
  <h2>index.py</h2>
  
  <pre><code>from flask import Flask
  from Settings import DefineManager
  from Route import *
  import imp
  import sys
  
  imp.reload(sys)
  
  app = Flask(__name__)
  app.register_blueprint(routes)
  
  if __name__ == '__main__':
      app.debug = True
      app.run(host=DefineManager.SERVER_USING_HOST, port=DefineManager.SERVER_USING_PORT)
  </code></pre>
  
  <h2>Route/RouteManager.py</h2>
  
  <pre><code>@routes.route("/")
  def IndexPage():
      LoggingManager.PrintLogMessage("RouteManager", "IndexPage", "web page connection!", DefineManager.LOG_LEVEL_INFO)
      return HomePage.RenderIndexPage()
  
  @routes.route("/upload/", methods=['POST'])
  def UploadRawDatas():
      content = request.get_json(silent=True)
      LoggingManager.PrintLogMessage("RouteManager", "UploadRawDatas", "json data: " + str(content), DefineManager.LOG_LEVEL_INFO)
      return BackgroundProcessManager.UploadRawDatas(content['Data'], content['Date'], content['Day'])
  
  @routes.route("/forecast/", methods=['POST'])
  def ForecastDatas():
      content = request.get_json(silent=True)
      LoggingManager.PrintLogMessage("RouteManager", "ForecastDatas", "json data: " + str(content), DefineManager.LOG_LEVEL_INFO)
      return BackgroundProcessManager.ForecastDatas(content['ProcessId'])
  </code></pre>
  
  <h1>Test case</h1>
  
  <h2>/upload/</h2>
  
  <h3>Request data</h3>
  
  <ul>
  <li>header</li>
  </ul>
  
  <p><code>Content-Type application/json</code></p>
  
  <ul>
  <li>body</li>
  </ul>
  
  <p><code>{
          "Data": [20.0, 30.0, 401.0, 50.0],
          "Date": ["2017-08-11", "2017-08-12", "2017-08-13", "2017-08-14"],
          "Day": 4
  }</code></p>
  
  <h3>Response data</h3>
  
  <ul>
  <li>header</li>
  </ul>
  
  <p><code>Content-Type application/json</code></p>
  
  <ul>
  <li><p>body</p>
  
  <p>{"Result": 39}</p></li>
  </ul>
  
  <h2>Expect test process</h2>
  
  <ul>
  <li>Send fake post data.</li>
  <li>Receive response data.</li>
  <li>Assert check <code>Result</code> is not equal <code>-1</code></li>
  </ul>