  def testClusterListNodes(self, mock_k8s_api):
    """Test that nodes of a cluster are correctly listed."""

    # Create and assign mocks
    mock_nodes = k8s_mocks.V1NodeList(5)
    mock_k8s_api_func = mock_k8s_api.return_value.list_node
    mock_k8s_api_func.return_value = mock_nodes

    nodes = k8s_cluster.K8sCluster(
        api_client=k8s_mocks.MOCK_API_CLIENT).ListNodes()

    # 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()
    # Assert returned nodes correspond to provided response
    self.assertEqual(
        set(node.name for node in nodes),
        set(node.metadata.name for node in mock_nodes.items))
Test that nodes of a cluster are correctly listed.
tests/providers/kubernetes/test_base.py