mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 08:46:55 +00:00
Add tests for python client with disallowAdditionalPropertiesIfNotPresent set to true (#16690)
* add tests for python client with different option * update samples * update tests
This commit is contained in:
@@ -145,6 +145,40 @@ class TestManual(unittest.TestCase):
|
||||
self.assertTrue("Authorization" in e.headers)
|
||||
self.assertEqual(e.headers["Authorization"], "Basic dGVzdF91c2VybmFtZTp0ZXN0X3Bhc3N3b3Jk")
|
||||
|
||||
# test from_json, to_json, to_dict, from_dict
|
||||
def test_from_to_methods(self):
|
||||
json_str = ("{\"category\": {\"id\": 1, \"name\": \"dog\"},\n"
|
||||
" \"id\": 1,\n"
|
||||
" \"name\": \"test name\",\n"
|
||||
" \"photoUrls\": [\"string\"],\n"
|
||||
" \"status\": \"available\",\n"
|
||||
" \"tags\": [{\"id\": 1, \"name\": \"None\"}]}")
|
||||
pet = openapi_client.Pet.from_json(json_str)
|
||||
self.assertEqual(pet.id, 1)
|
||||
self.assertEqual(pet.status, "available")
|
||||
self.assertEqual(pet.photo_urls, ["string"])
|
||||
self.assertEqual(pet.tags[0].id, 1)
|
||||
self.assertEqual(pet.tags[0].name, "None")
|
||||
self.assertEqual(pet.category.id, 1)
|
||||
# test to_json
|
||||
self.assertEqual(pet.to_json(),
|
||||
'{"id": 1, "name": "test name", "category": {"id": 1, "name": "dog"}, "photoUrls": ['
|
||||
'"string"], "tags": [{"id": 1, "name": "None"}], "status": "available"}')
|
||||
|
||||
# test to_dict
|
||||
self.assertEqual(pet.to_dict(),
|
||||
{"id": 1, "name": "test name", "category": {"id": 1, "name": "dog"}, "photoUrls": ["string"],
|
||||
"tags": [{"id": 1, "name": "None"}], "status": "available"})
|
||||
|
||||
# test from_dict
|
||||
pet2 = openapi_client.Pet.from_dict(pet.to_dict())
|
||||
self.assertEqual(pet2.id, 1)
|
||||
self.assertEqual(pet2.status, "available")
|
||||
self.assertEqual(pet2.photo_urls, ["string"])
|
||||
self.assertEqual(pet2.tags[0].id, 1)
|
||||
self.assertEqual(pet2.tags[0].name, "None")
|
||||
self.assertEqual(pet2.category.id, 1)
|
||||
|
||||
def echoServerResponseParaserTest(self):
|
||||
s = """POST /echo/body/Pet/response_string HTTP/1.1
|
||||
Host: localhost:3000
|
||||
|
||||
Reference in New Issue
Block a user