Skip to content

Commit

Permalink
Added direct test cases with and w/o flask.Response
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentín Gutiérrez authored and rafaelcaricio committed Feb 3, 2016
1 parent 678fbf7 commit b28cd87
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/fakeapi/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,22 @@ paths:
in: query
required: true

/test-redirect-endpoint:
get:
summary: Tests handlers returning flask.Response objects
operationId: fakeapi.hello.test_redirect_endpoint
responses:
302:
description: 302 Found

/test-redirect-response-endpoint:
get:
summary: Tests handlers returning flask.Response objects
operationId: fakeapi.hello.test_redirect_response_endpoint
responses:
302:
description: 302 Found

definitions:
new_stack:
type: object
Expand Down
10 changes: 10 additions & 0 deletions tests/fakeapi/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from connexion import problem, request
from connexion import NoContent
from flask import redirect


class DummyClass:
Expand Down Expand Up @@ -234,3 +235,12 @@ def test_bool_default_param(thruthiness):

def test_required_param(simple):
return simple


def test_redirect_endpoint():
headers = {'Location': 'http://www.google.com/'}
return '', 302, headers


def test_redirect_response_endpoint():
return redirect('http://www.google.com/')
12 changes: 12 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,15 @@ def test_required_param_miss_config(app):

resp = app_client.get('/v1.0/test-required-param')
assert resp.status_code == 400


def test_redirect_endpoint(app):
app_client = app.app.test_client()
resp = app_client.get('/v1.0/test-redirect-endpoint')
assert resp.status_code == 302


def test_redirect_response_endpoint(app):
app_client = app.app.test_client()
resp = app_client.get('/v1.0/test-redirect-response-endpoint')
assert resp.status_code == 302

0 comments on commit b28cd87

Please sign in to comment.