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:
William Cheng
2023-10-01 17:34:52 +08:00
committed by GitHub
parent c6e9a4e1ae
commit 3fcf5584c6
81 changed files with 9398 additions and 1 deletions

View File

@@ -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