mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 21:02:42 +00:00
[python] add method to set/get default configuration (#5315)
* [python] add method to set/get default configuration * [python] change method name and fix handling api_key * python: using modified deepcopy to set/get default configuration * python: update samples * python: update samples
This commit is contained in:
@@ -22,14 +22,30 @@ class TestConfiguration(unittest.TestCase):
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
# reset Configuration
|
||||
petstore_api.Configuration.set_default(None)
|
||||
|
||||
def testConfiguration(self):
|
||||
# check that different instances use different dictionaries
|
||||
c1 = petstore_api.Configuration()
|
||||
c2 = petstore_api.Configuration()
|
||||
assert id(c1.api_key) != id(c2.api_key)
|
||||
assert id(c1.api_key_prefix) != id(c2.api_key_prefix)
|
||||
self.assertNotEqual(id(c1.api_key), id(c2.api_key))
|
||||
self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix))
|
||||
|
||||
def testDefaultConfiguration(self):
|
||||
|
||||
# prepare default configuration
|
||||
c1 = petstore_api.Configuration(host="example.com")
|
||||
c1.debug = True
|
||||
petstore_api.Configuration.set_default(c1)
|
||||
|
||||
# get default configuration
|
||||
c2 = petstore_api.Configuration.get_default_copy()
|
||||
self.assertEqual(c2.host, "example.com")
|
||||
self.assertTrue(c2.debug)
|
||||
|
||||
self.assertNotEqual(id(c1.api_key), id(c2.api_key))
|
||||
self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user