class_docstr: tests for caliban.platform.gke.util
class_docstr_tok: ["tests","for","caliban.platform.gke.util"]
docstr: tests wait_for_operation method
code: def test_wait_for_operation(self, results, conds, invalid_cond):
      """tests wait_for_operation method"""
  
      class mock_api:
          def projects(self):
              return self
  
          def locations(self):
              return self
  
          def operations(self):
              return self
  
          def get(self, name):
              return self
  
      def _raises():
          raise Exception("exception")
  
      def _return_results():
          for r in results:
              yield {"status": r.value}
          _raises()
  
      api = mock_api()
      api.execute = _raises
  
      # we run without the wait spinner here as it causes the tests
      # to take about a factor of 100 longer
  
      # empty condition list
      self.assertIsNone(
          util.wait_for_operation(api, "name", [], spinner=False)
      )
  
      # exception
      self.assertIsNone(
          util.wait_for_operation(
              api, "name", list(conds), 0, spinner=False
          )
      )
  
      # normal operation
      rsp_generator = _return_results()
      api.execute = lambda: next(rsp_generator)
  
      expected_response = None
      for r in results:
          if r in conds:
              expected_response = r.value
              break
  
      if expected_response is not None:
          self.assertEqual(
              {"status": expected_response},
              util.wait_for_operation(
                  api, "name", list(conds), 0, spinner=True
              ),
          )
      else:
          self.assertIsNone(
              util.wait_for_operation(
                  api, "name", list(conds), 0, spinner=False
              )
          )
  
      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 6 for calling the UtilTestSuite obj's underlying member method code with example usage: obj.test_wait_for_operation(results, conds, invalid_cond) and returns: self, self, self, self