|
| 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