0

I'm learning testing with pytest and I'm working on a flask application where I'd like to integrate what I'm learning into. How would you test for a success response and maybe also that the data it returns is what is expected?

# sample Flask app - main.py

from flask import Flask
from flask import escape
import json

app = Flask(__name__)

app.route("/")
def some_route():

    return {"success": True}, 200, {"Content-Type: application/json"}

Test file

from unittest.mock import Mock
import json
import main

def test_some_route():
    assert "success" in main.some_route()[0]
Ari
  • 5,301
  • 8
  • 46
  • 120
  • 1
    Does this answer your question? [How can I unit test this Flask app?](https://stackoverflow.com/questions/13959209/how-can-i-unit-test-this-flask-app), also [How to apply integration tests (rather than unit tests) to a Flask RESTful API](https://stackoverflow.com/questions/41718376/how-to-apply-integration-tests-rather-than-unit-tests-to-a-flask-restful-api) – metatoaster Nov 12 '19 at 06:45
  • cheers, second one seems to be the one – Ari Nov 12 '19 at 10:06

0 Answers0