mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-11 00:21:18 +00:00
support map type response for python client
This commit is contained in:
@@ -88,3 +88,39 @@ class ApiClientTests(unittest.TestCase):
|
||||
content_types = []
|
||||
content_type = self.api_client.select_header_content_type(content_types)
|
||||
self.assertEqual(content_type, 'application/json')
|
||||
|
||||
def test_deserialize_to_dict(self):
|
||||
# dict(str, Pet)
|
||||
json = {
|
||||
'pet': {
|
||||
"id": 0,
|
||||
"category": {
|
||||
"id": 0,
|
||||
"name": "string"
|
||||
},
|
||||
"name": "doggie",
|
||||
"photoUrls": [
|
||||
"string"
|
||||
],
|
||||
"tags": [
|
||||
{
|
||||
"id": 0,
|
||||
"name": "string"
|
||||
}
|
||||
],
|
||||
"status": "available"
|
||||
}
|
||||
}
|
||||
|
||||
data = self.api_client.deserialize(json, 'dict(str, Pet)')
|
||||
self.assertTrue(isinstance(data, dict))
|
||||
self.assertTrue(isinstance(data['pet'], SwaggerPetstore.Pet))
|
||||
|
||||
# dict(str, int)
|
||||
json = {
|
||||
'integer': 1
|
||||
}
|
||||
|
||||
data = self.api_client.deserialize(json, 'dict(str, int)')
|
||||
self.assertTrue(isinstance(data, dict))
|
||||
self.assertTrue(isinstance(data['integer'], int))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
Run the tests.
|
||||
$ pip install nose (optional)
|
||||
$ cd SwaggerPetstore-python
|
||||
$ nosetests -v
|
||||
"""
|
||||
|
||||
import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import SwaggerPetstore
|
||||
from SwaggerPetstore.rest import ApiException
|
||||
|
||||
|
||||
class StoreApiTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.store_api = SwaggerPetstore.StoreApi()
|
||||
|
||||
def tearDown(self):
|
||||
# sleep 1 sec between two every 2 tests
|
||||
time.sleep(1)
|
||||
|
||||
def test_get_inventory(self):
|
||||
data = self.store_api.get_inventory()
|
||||
self.assertIsNotNone(data)
|
||||
self.assertTrue(isinstance(data, dict))
|
||||
self.assertItemsEqual(data.keys(), ['available', 'string', 'sold', 'pending', 'confused', 'active', 'na'])
|
||||
Reference in New Issue
Block a user