def test_kubernetes_metrics_resource_metrics_as_dict_missing( kubernetes_metrics_obj: KubernetesMetrics) -> None: """ This test verifies that KubernetesMetrics.resource_metrics_as_dict() returns None for undefined resource metrics. :param kubernetes_metrics_obj: The pre-loaded KubernetesMetrics fixture object for testing. """ assert kubernetes_metrics_obj.resource_metrics_as_dict("foo") is None
def test_kubernetes_metrics_resource_metrics_as_dict( kubernetes_metrics_obj: KubernetesMetrics) -> None: """ This test verifies that KubernetesMetrics.resource_metrics_as_dict() returns the correct dictionary for defined resource metrics. :param kubernetes_metrics_obj: The pre-loaded KubernetesMetrics fixture object for testing. """ # get a single metrics dict node_metrics: Dict = kubernetes_metrics_obj.resource_metrics_as_dict( "node") # make sure it is the correct type, length, and has the expected keys assert isinstance(node_metrics, dict) assert len(node_metrics) == 4 assert KubernetesMetrics.Keys.CPU_CORES in node_metrics assert KubernetesMetrics.Keys.CPU_USED in node_metrics assert KubernetesMetrics.Keys.MEMORY_BYTES in node_metrics assert KubernetesMetrics.Keys.MEMORY_USED in node_metrics