class_docstr: tests for caliban.platform.gke.util
class_docstr_tok: ["tests","for","caliban.platform.gke.util"]
docstr: test getting gke cluster
code: def test_get_gke_cluster(self, names, invalid):
      """test getting gke cluster"""
  
      class mock_cluster:
          def __init__(self, name):
              self.name = name
              return
  
      class mock_cluster_list:
          def __init__(self):
              self.clusters = [mock_cluster(x) for x in names]
              return
  
      class mock_api:
          self.throws = False
  
          def list_clusters(self, project_id, zone):
              if self.throws:
                  raise Exception("exception")
              return mock_cluster_list()
  
      api = mock_api()
      api.throws = True
  
      # exception handling
      self.assertIsNone(util.get_gke_cluster(api, "foo", "p"))
  
      api.throws = False
      # single cluster
      if len(names) > 0:
          cname = names[random.randint(0, len(names) - 1)]
          self.assertEqual(
              cname, util.get_gke_cluster(api, cname, "p").name
          )
  
      # name not in name list
      self.assertIsNone(util.get_gke_cluster(api, invalid, "p"))
  
      return
  
imports: import random
  import unittest
  from typing import List, Optional, Dict
  from unittest import mock
  import uuid
  import json
  import os
  import tempfile
  import yaml
  import hypothesis.strategies
  from hypothesis import given, settings
  from kubernetes.client.api_client import ApiClient
  from kubernetes.client import V1Job
  import pytest
  import argparse
  import google
  import caliban.platform.cloud.types
  import caliban.platform.gke.constants
  import caliban.platform.gke.util
  from caliban.platform.gke.types import NodeImage, OpStatus
  from caliban.platform.gke.util import trap
label_desc: Use image node_id 12 for calling the UtilTestSuite obj's underlying member method code with example usage: obj.test_get_gke_cluster(names, invalid) and returns: mock_cluster_list