- .github
- devel
- doc
-
examples
-
dynamic-client
-
notebooks
-
watch
-
yaml_dir
- README.md
- __init__.py
- annotate_deployment.py
- api_discovery.py
- apply_from_dict.py
- apply_from_directory.py
- apply_from_single_file.py
- cluster_scoped_custom_object.py
- cronjob_crud.py
- deployment_create.py
- deployment_crud.py
- duration-gep2257.py
- in_cluster_config.py
- ingress_create.py
- job_crud.py
- multiple_clusters.py
- namespaced_custom_object.py
- node_labels.py
- out_of_cluster_config.py
- pick_kube_config_context.py
- pod_config_list.py
- pod_exec.py
- pod_portforward.py
- remote_cluster.py
- rollout-daemonset.py
- rollout-statefulset.py
-
dynamic-client
- kubernetes
- scripts
- .gitignore
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- MANIFEST.in
- OWNERS
- README.md
- SECURITY_CONTACTS
- code-of-conduct.md
- codecov.yml
- requirements.txt
- setup.cfg
- setup.py
- test-requirements.txt
- tox.ini
Explanation
This code defines a test suite for a websocket client implementation within the kubernetes-client
python library.
test_websocket_client
This tests the get_websocket_url
function which converts a given HTTP URL to its websocket equivalent. It iterates over different URL formats (with and without protocol, with and without trailing slashes) and asserts that the function correctly produces the expected websocket URL.
test_websocket_proxycare
This test checks how the websocket_proxycare
function handles proxy configurations. It iterates over various proxy settings, including different proxy URLs, authentication credentials, and no_proxy
settings. For each scenario, it sets up a Configuration
object with the relevant proxy parameters and calls websocket_proxycare
to get the connection options. It then asserts that the returned options (connect_opt
) contain the expected proxy host, port, authentication credentials, and no_proxy
list.
Key points:
get_websocket_url
simply replaces “http://” with “ws://” or “https://” with “wss://”, which is how websocket URLs are constructed.websocket_proxycare
uses the providedConfiguration
object to determine the proxy settings and then creates a dictionary (connect_opt
) containing the appropriate connection parameters for the websocket client.- The
dictval
helper function safely retrieves a value from a dictionary, returning a default value if the key is not found.
The tests cover various aspects of the websocket client’s handling of URLs and proxy configurations, ensuring that it behaves correctly in different scenarios.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph