class_docstr: tests for caliban.platform.gke.util
class_docstr_tok: ["tests","for","caliban.platform.gke.util"]
docstr: tests get_zone_tpu_types
code: def test_get_zone_tpu_types(self, tpu_types, invalid_types):
      """tests get_zone_tpu_types"""
  
      tpus = [
          "{}-{}".format(x[1].name.lower(), x[0]) for x in tpu_types
      ]
  
      invalid_types = list(invalid_types)
  
      responses = tpus + invalid_types
      random.shuffle(responses)
  
      class mock_api:
          def projects(self):
              return self
  
          def locations(self):
              return self
  
          def acceleratorTypes(self):
              return self
  
          def list(self, parent):
              return self
  
      def _raises():
          raise Exception("exception")
  
      def _response():
          return {"acceleratorTypes": [{"type": x} for x in responses]}
  
      def _invalid_response():
          return {"foo": "bar"}
  
      api = mock_api()
  
      # exception handling
      api.execute = _raises
      self.assertIsNone(util.get_zone_tpu_types(api, "p", "z"))
  
      # invalid response
      api.execute = _invalid_response
      self.assertIsNone(util.get_zone_tpu_types(api, "p", "z"))
  
      # normal mode
      api.execute = _response
      self.assertEqual(
          sorted(tpus),
          sorted(
              [
                  "{}-{}".format(x.name.lower(), x.count)
                  for x in util.get_zone_tpu_types(api, "p", "z")
              ]
          ),
      )
  
      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 7 for calling the UtilTestSuite obj's underlying member method code with example usage: obj.test_get_zone_tpu_types(tpu_types, invalid_types) and returns: dict, dict, self, self, self, self