Skip to content
Snippets Groups Projects
Unverified Commit 3f5c168a authored by Varac's avatar Varac
Browse files

Docstrings in test_resources.py

parent fb76c4d7
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,20 @@ import pytest
# Helper functions
def check_resource(api, api_group, api_version, plural, name, namespace):
"""Returns status contition for resource in given namespace"""
"""Returns status contition for resource in given namespace
:param api: The api object used to query the custom objects
:param api_group: The api group used to query the custom objects
:type api_group: str
:param api_version: The api version used to query the custom objects
:type api_version: str
:param plural: The custom resource's plural name
:type plural: str
:param name: The custom object's name
:type name: str
:param name: The custom object's namespace
:type namespace: str
"""
if not namespace:
namespace='flux-system'
print(f'Resource "{name}" in namespace "{namespace}" '
......@@ -52,6 +65,18 @@ def check_custom_objects(api, api_group, api_version, plural, name, namespace='f
We can't get a list of custom objects from all namespaces,
so we have to iterate over all namespaces. See
https://github.com/kubernetes-client/python/issues/1377
:param api: The api object used to query the custom objects
:param api_group: The api group used to query the custom objects
:type api_group: str
:param api_version: The api version used to query the custom objects
:type api_version: str
:param plural: The custom resource's plural name
:type plural: str
:param name: The custom object's name
:type name: str
:param name: The custom object's namespace
:type namespace: str
"""
failed = 0
......@@ -96,11 +121,19 @@ def check_custom_objects(api, api_group, api_version, plural, name, namespace='f
def check_all_pods_running(pods):
"""
Loop through all the pods in an API result.
Loop through all the given V1Pods list.
If a pod does not have an element `status.phase` with the value "Running",
return False. Otherwise, returns True.
:param kubernetes.V1Pod[] pods: list of V1Pod elements to check
Parameters
----------
pods: kubernetes.V1Pod[]
List of V1Pod elements to check
Returns
-------
bool
"""
ret = True
for pod in pods:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment