def test_empty_headers(op): response_spec = { 'description': 'I have headers, but it is empty', 'headers': {}, } response = Mock(spec=OutgoingResponse) # no exception raised == success validate_response_headers(op, response_spec, response)
def test_valid_headers(op): response_spec = { 'description': 'I have one header', 'headers': { 'X-Foo': { 'type': 'string' } }, } response = Mock(spec=OutgoingResponse, headers={'X-Foo': 'bar'}) # no exception raised == success validate_response_headers(op, response_spec, response)
def test_invalid_headers(op): response_spec = { 'description': 'I have one header', 'headers': { 'X-Foo': { 'type': 'integer' } }, } response = Mock(spec=OutgoingResponse, headers={'X-Foo': 'bar'}) with pytest.raises(ValidationError) as excinfo: validate_response_headers(op, response_spec, response) assert "is not of type 'integer'" in str(excinfo.value)
def test_no_headers(op): response_spec = {'description': 'I have no headers'} response = Mock(spec=OutgoingResponse) # no exception raised == success validate_response_headers(op, response_spec, response)