  def testListNamespacedNetworkPolicy(self, mock_list_network_policy):
    """Test network policies list API is correctly called and used."""
    fake_network_policy_list = k8s_mocks.V1NetworkPolicyList(4, 'default')

    mock_list_network_policy.return_value = fake_network_policy_list

    cluster = k8s_cluster.K8sCluster(api_client=k8s_mocks.MOCK_API_CLIENT)
    self.assertEqual(
      {(np.metadata.name, np.metadata.namespace)
       for np in fake_network_policy_list.items},
      {(np.name, np.namespace)
       for np in cluster.ListNetworkPolicies('namespace-bpvnxfvs')})

    mock_list_network_policy.assert_called_once_with('namespace-bpvnxfvs')
Test network policies list API is correctly called and used.
tests/providers/kubernetes/test_base.py