Skip to content

Commit 82a4310

Browse files
committed
Document default configuration breaking change
add unit test
1 parent 38a0ab4 commit 82a4310

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ Kubernetes API Version: 1.16.14
2424

2525
Kubernetes API Version: 1.16.14
2626

27+
**Breaking Change:**
28+
- `kubernetes.config.Configuration()` no longer returns the default configuration. Use `kubernetes.config.Configuration.get_default_copy()` now to get the default configuration. [OpenAPITools/openapi-generator#4485](https://github.com/OpenAPITools/openapi-generator/pull/4485), [OpenAPITools/openapi-generator#5315](https://github.com/OpenAPITools/openapi-generator/pull/5315)
29+
2730
**API Change:**
2831

2932
- Resolve regression in metadata.managedFields handling in update/patch requests submitted by older API clients ([#91748](https://github.com/kubernetes/kubernetes/pull/91748), [@apelisse](https://github.com/apelisse)) [SIG API Machinery and Testing]

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)