title: Flask: testing with unittest - how to get .post json from response
body: <p>I am doing unit testing in flask with python3.
  I have method that returns json:</p>
  
  <pre><code>@app.route('/doctor/book_appointment', methods=['POST'])
  def some_method():
    resp = {
            "status": "",
            "message": ""
          }
    return jsonify(resp)
  </code></pre>
  
  <p>So inside my unittest I try this:</p>
  
  <pre><code>headers = {
          'ContentType': 'application/json',
          'dataType': 'json'
  }
  data = {
      'key1': 'val1',
      'key2': 'val2'
  }
  response = self.test_app.post('/doctor/book_appointment',
                                        data=json.dumps(data),
                                        content_type='application/json',
                                        follow_redirects=True)
          self.assertEqual(response.status_code, 200)
  # hot to get json from response here
  # I tried this, but doesnt work
  json_response = json.loads(resp.data)
  </code></pre>
  
  <p>My response object is of Response streamed type. How do I get json from it. Since some_method returns jsonified data. BTW it works when some javascript framework consumes my api, i.e I could get json from response. But now I need to test code in python here.</p>