Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
test_discovery.py62 linesDownload Raw Back to dynamic
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 at6#7#     http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# 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 and13# limitations under the License.14 15import os16import unittest17 18from kubernetes.e2e_test import base19from kubernetes.client import api_client20 21from . import DynamicClient22 23 24class TestDiscoverer(unittest.TestCase):25 26    @classmethod27    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 called40        self.assertTrue(mtime1 == mtime2)41 42    def test_cache_decoder_resource_and_subresource(self):43        client = DynamicClient(api_client.ApiClient(configuration=self.config))44        # first invalidate cache45        client.resources.invalidate_cache()46 47        # do Discoverer.__init__48        client = DynamicClient(api_client.ApiClient(configuration=self.config))49        # the resources of client will use _cache['resources'] in memory50        deploy1 = client.resources.get(kind='Deployment')51 52        # do Discoverer.__init__53        client = DynamicClient(api_client.ApiClient(configuration=self.config))54        # the resources of client will use _cache['resources'] decode from cache file55        deploy2 = client.resources.get(kind='Deployment')56 57        # test Resource is the same58        self.assertTrue(deploy1 == deploy2)59 60        # test Subresource is the same61        self.assertTrue(deploy1.status == deploy2.status)62 
codekingpro/portable-devtools · Team Ai