class_docstr: Test class for TableauHook
class_docstr_tok: ["Test","class","for","TableauHook"]
docstr: Test wait_for_state
docstr_tok: ["Test","wait_for_state"]
code: def test_wait_for_state(self, mock_tableau_server):
      """
      Test wait_for_state
      """
      # Test SUCCESS Positive
      with TableauHook(
          tableau_conn_id="tableau_test_password"
      ) as tableau_hook:
          tableau_hook.get_job_status = MagicMock(
              name="get_job_status",
              side_effect=[
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.SUCCESS,
              ],
          )
          assert tableau_hook.wait_for_state(
              job_id="j1",
              target_state=TableauJobFinishCode.SUCCESS,
              check_interval=1,
          )
  
      # Test SUCCESS Negative
      with TableauHook(
          tableau_conn_id="tableau_test_password"
      ) as tableau_hook:
          tableau_hook.get_job_status = MagicMock(
              name="get_job_status",
              side_effect=[
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.ERROR,
              ],
          )
          assert not tableau_hook.wait_for_state(
              job_id="j1",
              target_state=TableauJobFinishCode.SUCCESS,
              check_interval=1,
          )
  
      # Test ERROR Positive
      with TableauHook(
          tableau_conn_id="tableau_test_password"
      ) as tableau_hook:
          tableau_hook.get_job_status = MagicMock(
              name="get_job_status",
              side_effect=[
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.ERROR,
              ],
          )
          assert tableau_hook.wait_for_state(
              job_id="j1",
              target_state=TableauJobFinishCode.ERROR,
              check_interval=1,
          )
  
      # Test CANCELLED Positive
      with TableauHook(
          tableau_conn_id="tableau_test_password"
      ) as tableau_hook:
          tableau_hook.get_job_status = MagicMock(
              name="get_job_status",
              side_effect=[
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.CANCELED,
              ],
          )
          assert tableau_hook.wait_for_state(
              job_id="j1",
              target_state=TableauJobFinishCode.CANCELED,
              check_interval=1,
          )
  
      # Test PENDING Positive
      with TableauHook(
          tableau_conn_id="tableau_test_password"
      ) as tableau_hook:
          tableau_hook.get_job_status = MagicMock(
              name="get_job_status",
              side_effect=[
                  TableauJobFinishCode.PENDING,
                  TableauJobFinishCode.ERROR,
              ],
          )
          assert tableau_hook.wait_for_state(
              job_id="j1",
              target_state=TableauJobFinishCode.PENDING,
              check_interval=1,
          )
  
file_path: airflow/tests/providers/tableau/hooks/test_tableau.py
imports: from __future__ import annotations
  from unittest.mock import MagicMock, patch
  import pytest
  from airflow import configuration, models
  from airflow.providers.tableau.hooks.tableau import TableauHook, TableauJobFinishCode
  from airflow.utils import db
label_desc: Use image node_id 10 for calling the TestTableauHook obj's underlying member method code with example usage: obj.test_wait_for_state(mock_tableau_server) without return types