From b3f1a7110b4de91d8581fa60a2894b5b2aa50c11 Mon Sep 17 00:00:00 2001 From: "Miguel G. Flores" Date: Fri, 11 Sep 2020 23:17:51 +0200 Subject: [PATCH] Add failing test for optional header --- tests/api/test_headers.py | 7 +++++++ tests/fakeapi/hello/__init__.py | 4 ++++ tests/fixtures/simple/openapi.yaml | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/tests/api/test_headers.py b/tests/api/test_headers.py index 0b6c88c75..25ad0c7b5 100644 --- a/tests/api/test_headers.py +++ b/tests/api/test_headers.py @@ -42,3 +42,10 @@ def test_no_content_object_and_have_headers(simple_app): resp = app_client.get('/v1.0/test-204-with-headers-nocontent-obj') assert resp.status_code == 204 assert 'X-Something' in resp.headers + + +def test_optional_header(simple_openapi_app): + app_client = simple_openapi_app.app.test_client() + resp = app_client.get('/v1.0/test-optional-headers') + assert resp.status_code == 200 + assert 'X-Optional-Header' not in resp.headers diff --git a/tests/fakeapi/hello/__init__.py b/tests/fakeapi/hello/__init__.py index 1abc0860f..d1aeff818 100644 --- a/tests/fakeapi/hello/__init__.py +++ b/tests/fakeapi/hello/__init__.py @@ -602,3 +602,7 @@ def get_date(): def get_uuid(): return {'value': uuid.UUID(hex='e7ff66d0-3ec2-4c4e-bed0-6e4723c24c51')} + + +def test_optional_headers(): + return {}, 200 diff --git a/tests/fixtures/simple/openapi.yaml b/tests/fixtures/simple/openapi.yaml index 80a3bf4fc..466795e6e 100644 --- a/tests/fixtures/simple/openapi.yaml +++ b/tests/fixtures/simple/openapi.yaml @@ -1140,6 +1140,24 @@ paths: application/json: schema: type: object + /test-optional-headers: + get: + operationId: fakeapi.hello.test_optional_headers + responses: + '200': + description: Some object response + content: + application/json: + schema: + type: object + headers: + X-Optional-Header: + description: Optional header + schema: + type: string + required: False + + servers: - url: http://localhost:{port}/{basePath}