Skip to content

Commit

Permalink
Added extra test for flask-json-response-type
Browse files Browse the repository at this point in the history
  • Loading branch information
andrecsilva committed Dec 11, 2023
1 parent 00803ff commit 960cca0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/codemods/test_flask_json_response_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,32 @@ def foo(request):
self.run_and_assert(tmpdir, dedent(input_code), dedent(expected))
assert len(self.file_context.codemod_changes) == 1

def test_simple_return_json(self, tmpdir):
input_code = """\
from flask import Flask
import json
app = Flask(__name__)
@app.route("/test")
def foo(request):
json_response = json.dumps({ "user_input": request.GET.get("input") })
return json_response
"""
expected = """\
from flask import Flask
import json
app = Flask(__name__)
@app.route("/test")
def foo(request):
json_response = json.dumps({ "user_input": request.GET.get("input") })
return (json_response, {'Content-Type': 'application/json'})
"""
self.run_and_assert(tmpdir, dedent(input_code), dedent(expected))
assert len(self.file_context.codemod_changes) == 1

def test_alias(self, tmpdir):
input_code = """\
from flask import make_response as response, Flask
Expand Down

0 comments on commit 960cca0

Please sign in to comment.