Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
31z4 committed Sep 29, 2016
1 parent 6abd065 commit 91aeb69
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/api/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,13 @@ def test_bad_operations(bad_operations_app):

resp = app_client.post('/v1.0/welcome')
assert resp.status_code == 501


def test_text_request(simple_app):
app_client = simple_app.app.test_client()

resp = app_client.post('/v1.0/text-request', data='text')
assert resp.status_code == 200
assert resp.content_type == 'text/plain; charset=utf-8'
# validate text content
assert resp.data == 'text'
4 changes: 4 additions & 0 deletions tests/fakeapi/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ def get_data_as_binary():
return get_blob_data(), 200, {'Content-Type': 'application/octet-stream'}


def get_data_as_text(post_param):
return post_param, 200, {'Content-Type': 'text/plain; charset=utf-8'}


def get_invalid_response():
return {"simple": object()}

Expand Down
20 changes: 20 additions & 0 deletions tests/fixtures/simple/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,26 @@ paths:
schema:
type: object

/text-request:
post:
operationId: fakeapi.hello.get_data_as_text
consumes:
- "text/plain"
produces:
- "text/plain"
parameters:
- name: post_param
description: Just a testing parameter.
in: body
required: true
schema:
type: string
responses:
200:
description: Everything is ok
schema:
type: string


definitions:
new_stack:
Expand Down

0 comments on commit 91aeb69

Please sign in to comment.