forked from loafle/openapi-generator-original
Enables test_inline_composition (#12240)
This commit is contained in:
parent
c456de40c0
commit
5de527e784
@ -596,96 +596,93 @@ class TestFakeApi(unittest.TestCase):
|
|||||||
|
|
||||||
return m
|
return m
|
||||||
|
|
||||||
# comment out below for the time being after adding better inline model support
|
@patch.object(RESTClientObject, 'request')
|
||||||
# ref: https://github.com/OpenAPITools/openapi-generator/pull/12104
|
def test_inline_composition(self, mock_request):
|
||||||
#
|
"""Test case for inline_composition
|
||||||
#@patch.object(RESTClientObject, 'request')
|
|
||||||
#def test_inline_composition(self, mock_request):
|
|
||||||
# """Test case for inline_composition
|
|
||||||
|
|
||||||
# testing composed schemas at inline locations # noqa: E501
|
testing composed schemas at inline locations # noqa: E501
|
||||||
# """
|
"""
|
||||||
# single_char_str = 'a'
|
single_char_str = 'a'
|
||||||
# json_bytes = self.__json_bytes(single_char_str)
|
json_bytes = self.__json_bytes(single_char_str)
|
||||||
|
|
||||||
# # tx and rx json with composition at root level of schema for request + response body
|
# tx and rx json with composition at root level of schema for request + response body
|
||||||
# content_type = 'application/json'
|
content_type = 'application/json'
|
||||||
# mock_request.return_value = self.__response(
|
mock_request.return_value = self.__response(
|
||||||
# json_bytes
|
json_bytes
|
||||||
# )
|
)
|
||||||
# api_response = self.api.inline_composition(
|
api_response = self.api.inline_composition(
|
||||||
# body=single_char_str,
|
body=single_char_str,
|
||||||
# query_params={
|
query_params={
|
||||||
# 'compositionAtRoot': single_char_str,
|
'compositionAtRoot': single_char_str,
|
||||||
# 'compositionInProperty': {'someProp': single_char_str}
|
'compositionInProperty': {'someProp': single_char_str}
|
||||||
# },
|
},
|
||||||
# accept_content_types=(content_type,)
|
accept_content_types=(content_type,)
|
||||||
# )
|
)
|
||||||
# self.__assert_request_called_with(
|
self.__assert_request_called_with(
|
||||||
# mock_request,
|
mock_request,
|
||||||
# 'http://petstore.swagger.io:80/v2/fake/inlineComposition/',
|
'http://petstore.swagger.io:80/v2/fake/inlineComposition/',
|
||||||
# accept_content_type=content_type,
|
accept_content_type=content_type,
|
||||||
# content_type=content_type,
|
content_type=content_type,
|
||||||
# query_params=(('compositionAtRoot', 'a'), ('someProp', 'a')),
|
query_params=(('compositionAtRoot', 'a'), ('someProp', 'a')),
|
||||||
# body=json_bytes
|
body=json_bytes
|
||||||
# )
|
)
|
||||||
# self.assertEqual(api_response.body, single_char_str)
|
self.assertEqual(api_response.body, single_char_str)
|
||||||
# self.assertTrue(isinstance(api_response.body, schemas.StrSchema))
|
self.assertTrue(isinstance(api_response.body, schemas.StrSchema))
|
||||||
|
|
||||||
# # tx and rx json with composition at property level of schema for request + response body
|
# tx and rx json with composition at property level of schema for request + response body
|
||||||
# content_type = 'multipart/form-data'
|
content_type = 'multipart/form-data'
|
||||||
# multipart_response = self.__encode_multipart_formdata(fields={'someProp': single_char_str})
|
multipart_response = self.__encode_multipart_formdata(fields={'someProp': single_char_str})
|
||||||
# mock_request.return_value = self.__response(
|
mock_request.return_value = self.__response(
|
||||||
# bytes(multipart_response),
|
bytes(multipart_response),
|
||||||
# content_type=multipart_response.get_content_type()
|
content_type=multipart_response.get_content_type()
|
||||||
# )
|
)
|
||||||
# api_response = self.api.inline_composition(
|
api_response = self.api.inline_composition(
|
||||||
# body={'someProp': single_char_str},
|
body={'someProp': single_char_str},
|
||||||
# query_params={
|
query_params={
|
||||||
# 'compositionAtRoot': single_char_str,
|
'compositionAtRoot': single_char_str,
|
||||||
# 'compositionInProperty': {'someProp': single_char_str}
|
'compositionInProperty': {'someProp': single_char_str}
|
||||||
# },
|
},
|
||||||
# content_type=content_type,
|
content_type=content_type,
|
||||||
# accept_content_types=(content_type,)
|
accept_content_types=(content_type,)
|
||||||
# )
|
)
|
||||||
# self.__assert_request_called_with(
|
self.__assert_request_called_with(
|
||||||
# mock_request,
|
mock_request,
|
||||||
# 'http://petstore.swagger.io:80/v2/fake/inlineComposition/',
|
'http://petstore.swagger.io:80/v2/fake/inlineComposition/',
|
||||||
# accept_content_type=content_type,
|
accept_content_type=content_type,
|
||||||
# content_type=content_type,
|
content_type=content_type,
|
||||||
# query_params=(('compositionAtRoot', 'a'), ('someProp', 'a')),
|
query_params=(('compositionAtRoot', 'a'), ('someProp', 'a')),
|
||||||
# fields=(
|
fields=(
|
||||||
# api_client.RequestField(
|
api_client.RequestField(
|
||||||
# name='someProp',
|
name='someProp',
|
||||||
# data=single_char_str,
|
data=single_char_str,
|
||||||
# headers={'Content-Type': 'text/plain'}
|
headers={'Content-Type': 'text/plain'}
|
||||||
# ),
|
),
|
||||||
# ),
|
),
|
||||||
# )
|
)
|
||||||
# self.assertEqual(api_response.body, {'someProp': single_char_str})
|
self.assertEqual(api_response.body, {'someProp': single_char_str})
|
||||||
# self.assertTrue(isinstance(api_response.body.someProp, schemas.StrSchema))
|
self.assertTrue(isinstance(api_response.body.someProp, schemas.StrSchema))
|
||||||
|
|
||||||
# # error thrown when a str is input which doesn't meet the composed schema length constraint
|
# error thrown when a str is input which doesn't meet the composed schema length constraint
|
||||||
# invalid_value = ''
|
invalid_value = ''
|
||||||
# variable_locations = 4
|
variable_locations = 4
|
||||||
# for invalid_index in range(variable_locations):
|
for invalid_index in range(variable_locations):
|
||||||
# values = [single_char_str]*variable_locations
|
values = [single_char_str]*variable_locations
|
||||||
# values[invalid_index] = invalid_value
|
values[invalid_index] = invalid_value
|
||||||
# with self.assertRaises(exceptions.ApiValueError):
|
with self.assertRaises(exceptions.ApiValueError):
|
||||||
# multipart_response = self.__encode_multipart_formdata(fields={'someProp': values[0]})
|
multipart_response = self.__encode_multipart_formdata(fields={'someProp': values[0]})
|
||||||
# mock_request.return_value = self.__response(
|
mock_request.return_value = self.__response(
|
||||||
# bytes(multipart_response),
|
bytes(multipart_response),
|
||||||
# content_type=multipart_response.get_content_type()
|
content_type=multipart_response.get_content_type()
|
||||||
# )
|
)
|
||||||
# self.api.inline_composition(
|
self.api.inline_composition(
|
||||||
# body={'someProp': values[1]},
|
body={'someProp': values[1]},
|
||||||
# query_params={
|
query_params={
|
||||||
# 'compositionAtRoot': values[2],
|
'compositionAtRoot': values[2],
|
||||||
# 'compositionInProperty': {'someProp': values[3]}
|
'compositionInProperty': {'someProp': values[3]}
|
||||||
# },
|
},
|
||||||
# content_type=content_type,
|
content_type=content_type,
|
||||||
# accept_content_types=(content_type,)
|
accept_content_types=(content_type,)
|
||||||
# )
|
)
|
||||||
|
|
||||||
def test_json_with_charset(self):
|
def test_json_with_charset(self):
|
||||||
# serialization + deserialization of json with charset works
|
# serialization + deserialization of json with charset works
|
||||||
|
Loading…
x
Reference in New Issue
Block a user