  def testClusterListNamespacedPods(self, mock_k8s_api):
    """Test that namespaced pods of a cluster are correctly listed."""

    # Create and assign mocks
    mock_namespace = mock.Mock()
    mock_pods = k8s_mocks.V1PodList(5)
    mock_k8s_api_func = mock_k8s_api.return_value.list_namespaced_pod
    mock_k8s_api_func.return_value = mock_pods

    pods = k8s_cluster.K8sCluster(
        api_client=k8s_mocks.MOCK_API_CLIENT).ListPods(mock_namespace)

    # Assert API and corresponding function was called appropriately
    mock_k8s_api.assert_called_with(k8s_mocks.MOCK_API_CLIENT)
    mock_k8s_api_func.assert_called_with(mock_namespace)
    # Assert returned pods correspond to provided response
    self.assertEqual(
        set(pod.name for pod in pods),
        set(pod.metadata.name for pod in mock_pods.items))
Test that namespaced pods of a cluster are correctly listed.
tests/providers/kubernetes/test_base.py