|
| 1 | +# Copyright 2017 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 | +import unittest |
| 15 | +import urllib3 |
| 16 | + |
| 17 | +from mock import patch |
| 18 | + |
| 19 | +from kubernetes.client import Configuration |
| 20 | +from kubernetes.client.rest import RESTClientObject |
| 21 | + |
| 22 | + |
| 23 | +class RestTest(unittest.TestCase): |
| 24 | + |
| 25 | + def test_poolmanager(self): |
| 26 | + 'Test that a poolmanager is created for rest client' |
| 27 | + with patch.object(urllib3, 'PoolManager') as pool: |
| 28 | + RESTClientObject(config=Configuration()) |
| 29 | + pool.assert_called_once() |
| 30 | + |
| 31 | + def test_proxy(self): |
| 32 | + 'Test that proxy is created when the config especifies it' |
| 33 | + config = Configuration() |
| 34 | + config.http_proxy_url = 'http://proxy.example.com' |
| 35 | + |
| 36 | + with patch.object(urllib3, 'proxy_from_url') as proxy: |
| 37 | + RESTClientObject(config=config) |
| 38 | + proxy.assert_called_once() |
| 39 | + |
| 40 | + |
| 41 | +if __name__ == '__main__': |
| 42 | + unittest.main() |
0 commit comments