forked from loafle/openapi-generator-original
updated unittests of python client
This commit is contained in:
parent
245ce642ce
commit
8d0efd812c
@ -260,7 +260,10 @@ class ApiClient(object):
|
|||||||
"""
|
"""
|
||||||
if not accepts:
|
if not accepts:
|
||||||
return
|
return
|
||||||
if 'application/json'.lower() in accepts:
|
|
||||||
|
accepts = list(map(lambda x: x.lower(), accepts))
|
||||||
|
|
||||||
|
if 'application/json' in accepts:
|
||||||
return 'application/json'
|
return 'application/json'
|
||||||
else:
|
else:
|
||||||
return ', '.join(accepts)
|
return ', '.join(accepts)
|
||||||
@ -272,9 +275,10 @@ class ApiClient(object):
|
|||||||
"""
|
"""
|
||||||
if not content_types:
|
if not content_types:
|
||||||
return 'application/json'
|
return 'application/json'
|
||||||
if 'application/json'.lower() in content_types:
|
|
||||||
|
content_types = list(map(lambda x: x.lower(), content_types))
|
||||||
|
|
||||||
|
if 'application/json' in content_types:
|
||||||
return 'application/json'
|
return 'application/json'
|
||||||
else:
|
else:
|
||||||
return content_types[0]
|
return content_types[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,7 +260,10 @@ class ApiClient(object):
|
|||||||
"""
|
"""
|
||||||
if not accepts:
|
if not accepts:
|
||||||
return
|
return
|
||||||
if 'application/json'.lower() in accepts:
|
|
||||||
|
accepts = list(map(lambda x: x.lower(), accepts))
|
||||||
|
|
||||||
|
if 'application/json' in accepts:
|
||||||
return 'application/json'
|
return 'application/json'
|
||||||
else:
|
else:
|
||||||
return ', '.join(accepts)
|
return ', '.join(accepts)
|
||||||
@ -272,9 +275,10 @@ class ApiClient(object):
|
|||||||
"""
|
"""
|
||||||
if not content_types:
|
if not content_types:
|
||||||
return 'application/json'
|
return 'application/json'
|
||||||
if 'application/json'.lower() in content_types:
|
|
||||||
|
content_types = list(map(lambda x: x.lower(), content_types))
|
||||||
|
|
||||||
|
if 'application/json' in content_types:
|
||||||
return 'application/json'
|
return 'application/json'
|
||||||
else:
|
else:
|
||||||
return content_types[0]
|
return content_types[0]
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ class ApiClientTests(unittest.TestCase):
|
|||||||
self.api_client = SwaggerPetstore.ApiClient(HOST)
|
self.api_client = SwaggerPetstore.ApiClient(HOST)
|
||||||
|
|
||||||
def test_select_header_accept(self):
|
def test_select_header_accept(self):
|
||||||
|
accepts = ['APPLICATION/JSON', 'APPLICATION/XML']
|
||||||
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
|
self.assertEqual(accept, 'application/json')
|
||||||
|
|
||||||
accepts = ['application/json', 'application/xml']
|
accepts = ['application/json', 'application/xml']
|
||||||
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
accept = SwaggerPetstore.ApiClient.select_header_accept(accepts)
|
||||||
self.assertEqual(accept, 'application/json')
|
self.assertEqual(accept, 'application/json')
|
||||||
@ -39,6 +43,10 @@ class ApiClientTests(unittest.TestCase):
|
|||||||
self.assertEqual(accept, None)
|
self.assertEqual(accept, None)
|
||||||
|
|
||||||
def test_select_header_content_type(self):
|
def test_select_header_content_type(self):
|
||||||
|
content_types = ['APPLICATION/JSON', 'APPLICATION/XML']
|
||||||
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
|
self.assertEqual(content_type, 'application/json')
|
||||||
|
|
||||||
content_types = ['application/json', 'application/xml']
|
content_types = ['application/json', 'application/xml']
|
||||||
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
content_type = SwaggerPetstore.ApiClient.select_header_content_type(content_types)
|
||||||
self.assertEqual(content_type, 'application/json')
|
self.assertEqual(content_type, 'application/json')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user