code: def test_invoke(
      self, runspace_pool, powershell, ws_man, logging_level
  ):
      runspace_options = {"connection_name": "foo"}
      wsman_options = {"encryption": "auto"}
  
      options = {}
      if logging_level is not None:
          options["logging_level"] = logging_level
  
      on_output_callback = Mock()
  
      with PsrpHook(
          CONNECTION_ID,
          runspace_options=runspace_options,
          wsman_options=wsman_options,
          on_output_callback=on_output_callback,
          **options,
      ) as hook, patch.object(type(hook), "log") as logger:
          try:
              with hook.invoke() as ps:
                  assert ps.state == PSInvocationState.NOT_STARTED
  
                  # We're simulating an error in order to test error
                  # handling as well as the logging of error exception
                  # details.
                  ps.had_errors = True
          except AirflowException as exc:
              assert str(exc) == "Process had one or more errors"
          else:
              self.fail("Expected an error")
          assert ps.state == PSInvocationState.COMPLETED
  
      assert on_output_callback.mock_calls == [call("output")]
      assert runspace_pool.return_value.__exit__.mock_calls == [
          call(None, None, None)
      ]
      assert ws_man().__exit__.mock_calls == [call(None, None, None)]
      assert ws_man.call_args_list[0][1]["encryption"] == "auto"
      assert logger.method_calls[0] == call.setLevel(
          logging_level or DEBUG
      )
  
      def assert_log(level, *args):
          assert call.log(level, *args) in logger.method_calls
  
      assert_log(DEBUG, "%s: %s", "command", "debug1")
      assert_log(DEBUG, "%s", "debug2")
      assert_log(ERROR, "%s: %s", "command", "error")
      assert_log(INFO, "%s: %s", "command", "verbose")
      assert_log(WARNING, "%s: %s", "command", "warning")
      assert_log(INFO, "Progress: %s (%s)", "activity", "description")
      assert_log(INFO, "%s (%s): %s", "computer", "user", "information")
      assert_log(INFO, "%s: %s", "reason", ps.streams.error[0])
      assert_log(INFO, DUMMY_STACKTRACE[0])
      assert_log(INFO, DUMMY_STACKTRACE[1])
  
      assert (
          call("Invocation state: %s", "Completed")
          in logger.info.mock_calls
      )
      args, kwargs = runspace_pool.call_args
      assert args == (ws_man.return_value,)
      assert kwargs["connection_name"] == "foo"
      assert isinstance(kwargs["host"], PSHost)
  
imports: from __future__ import annotations
  from logging import DEBUG, ERROR, INFO, WARNING
  from unittest.mock import MagicMock, Mock, call, patch
  import pytest
  from pypsrp.host import PSHost
  from pypsrp.messages import MessageType
  from pypsrp.powershell import PSInvocationState
  from airflow.exceptions import AirflowException
  from airflow.models import Connection
  from airflow.providers.microsoft.psrp.hooks.psrp import PsrpHook
label_desc: Use image node_id 3 for calling the TestPsrpHook obj's underlying member method code with example usage: obj.test_invoke(runspace_pool, powershell, ws_man, logging_level) without return types