Skip to content

Commit ec1e85e

Browse files
committed
test: self._cache = json.load(f, cls=partial(CacheDecoder, self.client))
1 parent 18a5ccc commit ec1e85e

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

dynamic/test_discovery.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2019 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
import unittest
17+
18+
from kubernetes.e2e_test import base
19+
from kubernetes.client import api_client
20+
21+
from . import DynamicClient
22+
23+
24+
class TestDiscoverer(unittest.TestCase):
25+
26+
@classmethod
27+
def setUpClass(cls):
28+
cls.config = base.get_e2e_configuration()
29+
30+
def test_init_cache_from_file(self):
31+
client = DynamicClient(api_client.ApiClient(configuration=self.config))
32+
client.resources.get(api_version='v1', kind='Node')
33+
mtime1 = os.path.getmtime(client.resources._Discoverer__cache_file)
34+
35+
client = DynamicClient(api_client.ApiClient(configuration=self.config))
36+
client.resources.get(api_version='v1', kind='Node')
37+
mtime2 = os.path.getmtime(client.resources._Discoverer__cache_file)
38+
39+
# test no Discoverer._write_cache called
40+
self.assertTrue(mtime1 == mtime2)

0 commit comments

Comments
 (0)