Skip to content

Commit f1ed5fe

Browse files
roycaihwpalnabarun
authored andcommitted
add a test for default configuration behavior
1 parent 34ba5d8 commit f1ed5fe

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

kubernetes/test/test_configuration.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# coding: utf-8
2+
3+
import unittest
4+
5+
from kubernetes.client import Configuration
6+
7+
class TestConfiguration(unittest.TestCase):
8+
9+
def setUp(self):
10+
pass
11+
12+
def tearDown(self):
13+
# reset Configuration
14+
Configuration.set_default(None)
15+
16+
def testConfiguration(self):
17+
# check that different instances use different dictionaries
18+
c1 = Configuration()
19+
c2 = Configuration()
20+
self.assertNotEqual(id(c1.api_key), id(c2.api_key))
21+
self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix))
22+
23+
def testDefaultConfiguration(self):
24+
# prepare default configuration
25+
c1 = Configuration(host="example.com")
26+
c1.debug = True
27+
Configuration.set_default(c1)
28+
29+
# get default configuration
30+
c2 = Configuration.get_default_copy()
31+
self.assertEqual(c2.host, "example.com")
32+
self.assertTrue(c2.debug)
33+
34+
self.assertNotEqual(id(c1.api_key), id(c2.api_key))
35+
self.assertNotEqual(id(c1.api_key_prefix), id(c2.api_key_prefix))
36+
37+
38+
if __name__ == '__main__':
39+
unittest.main()

0 commit comments

Comments
 (0)