forked from loafle/openapi-generator-original
Fix issue in python client.
If upload only file it will not send file content.
This commit is contained in:
parent
5e805c2be6
commit
9b148be57e
@ -126,7 +126,7 @@ class ApiClient(object):
|
|||||||
for k, v in iteritems(query_params)}
|
for k, v in iteritems(query_params)}
|
||||||
|
|
||||||
# post parameters
|
# post parameters
|
||||||
if post_params:
|
if post_params or files:
|
||||||
post_params = self.prepare_post_parameters(post_params, files)
|
post_params = self.prepare_post_parameters(post_params, files)
|
||||||
post_params = self.sanitize_for_serialization(post_params)
|
post_params = self.sanitize_for_serialization(post_params)
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class ApiClient(object):
|
|||||||
for k, v in iteritems(query_params)}
|
for k, v in iteritems(query_params)}
|
||||||
|
|
||||||
# post parameters
|
# post parameters
|
||||||
if post_params:
|
if post_params or files:
|
||||||
post_params = self.prepare_post_parameters(post_params, files)
|
post_params = self.prepare_post_parameters(post_params, files)
|
||||||
post_params = self.sanitize_for_serialization(post_params)
|
post_params = self.sanitize_for_serialization(post_params)
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class PetApiTests(unittest.TestCase):
|
|||||||
self.assertNotEqual(pet_api3.api_client, swagger_client.configuration.api_client)
|
self.assertNotEqual(pet_api3.api_client, swagger_client.configuration.api_client)
|
||||||
# customized pet api not using the old pet api's api client
|
# customized pet api not using the old pet api's api client
|
||||||
self.assertNotEqual(pet_api3.api_client, pet_api2.api_client)
|
self.assertNotEqual(pet_api3.api_client, pet_api2.api_client)
|
||||||
|
|
||||||
def test_async_request(self):
|
def test_async_request(self):
|
||||||
self.pet_api.add_pet(body=self.pet)
|
self.pet_api.add_pet(body=self.pet)
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ class PetApiTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_find_pets_by_status(self):
|
def test_find_pets_by_status(self):
|
||||||
self.pet_api.add_pet(body=self.pet)
|
self.pet_api.add_pet(body=self.pet)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
self.pet.id,
|
self.pet.id,
|
||||||
list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_status(status=[self.pet.status])))
|
list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_status(status=[self.pet.status])))
|
||||||
@ -118,7 +118,7 @@ class PetApiTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_find_pets_by_tags(self):
|
def test_find_pets_by_tags(self):
|
||||||
self.pet_api.add_pet(body=self.pet)
|
self.pet_api.add_pet(body=self.pet)
|
||||||
|
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
self.pet.id,
|
self.pet.id,
|
||||||
list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_tags(tags=[self.tag.name])))
|
list(map(lambda x: getattr(x, 'id'), self.pet_api.find_pets_by_tags(tags=[self.tag.name])))
|
||||||
@ -126,7 +126,7 @@ class PetApiTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_update_pet_with_form(self):
|
def test_update_pet_with_form(self):
|
||||||
self.pet_api.add_pet(body=self.pet)
|
self.pet_api.add_pet(body=self.pet)
|
||||||
|
|
||||||
name = "hello kity with form updated"
|
name = "hello kity with form updated"
|
||||||
status = "pending"
|
status = "pending"
|
||||||
self.pet_api.update_pet_with_form(pet_id=self.pet.id, name=name, status=status)
|
self.pet_api.update_pet_with_form(pet_id=self.pet.id, name=name, status=status)
|
||||||
@ -137,6 +137,7 @@ class PetApiTests(unittest.TestCase):
|
|||||||
self.assertEqual(status, fetched.status)
|
self.assertEqual(status, fetched.status)
|
||||||
|
|
||||||
def test_upload_file(self):
|
def test_upload_file(self):
|
||||||
|
# upload file with form parameter
|
||||||
try:
|
try:
|
||||||
additional_metadata = "special"
|
additional_metadata = "special"
|
||||||
self.pet_api.upload_file(
|
self.pet_api.upload_file(
|
||||||
@ -147,10 +148,16 @@ class PetApiTests(unittest.TestCase):
|
|||||||
except ApiException as e:
|
except ApiException as e:
|
||||||
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
|
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
|
||||||
|
|
||||||
|
# upload only file
|
||||||
|
try:
|
||||||
|
self.pet_api.upload_file(pet_id=self.pet.id, file=self.foo)
|
||||||
|
except ApiException as e:
|
||||||
|
self.fail("upload_file() raised {0} unexpectedly".format(type(e)))
|
||||||
|
|
||||||
def test_delete_pet(self):
|
def test_delete_pet(self):
|
||||||
self.pet_api.add_pet(body=self.pet)
|
self.pet_api.add_pet(body=self.pet)
|
||||||
self.pet_api.delete_pet(pet_id=self.pet.id, api_key="special-key")
|
self.pet_api.delete_pet(pet_id=self.pet.id, api_key="special-key")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.pet_api.get_pet_by_id(pet_id=self.pet.id)
|
self.pet_api.get_pet_by_id(pet_id=self.pet.id)
|
||||||
raise "expected an error"
|
raise "expected an error"
|
||||||
@ -159,8 +166,3 @@ class PetApiTests(unittest.TestCase):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user