Merge pull request #1295 from geekerzp/python_upload_file

[Python] Fix issue in python client
This commit is contained in:
wing328 2015-09-27 21:48:29 +08:00
commit e301020acc
3 changed files with 14 additions and 12 deletions

View File

@ -126,7 +126,7 @@ class ApiClient(object):
for k, v in iteritems(query_params)}
# post parameters
if post_params:
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params)

View File

@ -126,7 +126,7 @@ class ApiClient(object):
for k, v in iteritems(query_params)}
# post parameters
if post_params:
if post_params or files:
post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params)

View File

@ -137,6 +137,7 @@ class PetApiTests(unittest.TestCase):
self.assertEqual(status, fetched.status)
def test_upload_file(self):
# upload file with form parameter
try:
additional_metadata = "special"
self.pet_api.upload_file(
@ -147,6 +148,12 @@ class PetApiTests(unittest.TestCase):
except ApiException as 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):
self.pet_api.add_pet(body=self.pet)
self.pet_api.delete_pet(pet_id=self.pet.id, api_key="special-key")
@ -159,8 +166,3 @@ class PetApiTests(unittest.TestCase):
if __name__ == '__main__':
unittest.main()