Skip to content

Commit

Permalink
add a test for default configuration behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
roycaihw committed Nov 4, 2020
1 parent b66cee1 commit 6ae4721
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions kubernetes/test/test_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding: utf-8

import unittest

from kubernetes.client import Configuration

class TestConfiguration(unittest.TestCase):

def setUp(self):
pass

def tearDown(self):
# reset Configuration
Configuration.set_default(None)

def testConfiguration(self):
# check that different instances use different dictionaries
c1 = Configuration()
c2 = Configuration()
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 = Configuration(host="example.com")
c1.debug = True
Configuration.set_default(c1)

# get default configuration
c2 = 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__':
unittest.main()

0 comments on commit 6ae4721

Please sign in to comment.