docstr: Test operator on_kill method if APIClient created.
docstr_tok: ["Test","operator","on_kill","method","if","APIClient","created","."]
code: def test_on_kill_client_created(
      self, docker_api_client_patcher, service_exists
  ):
      """Test operator on_kill method if APIClient created."""
      op = DockerSwarmOperator(image="", task_id="test_on_kill")
      op.service = {"ID": "some_id"} if service_exists else None
  
      op.hook.get_conn()  # Try to create APIClient
      op.on_kill()
      if service_exists:
          docker_api_client_patcher.return_value.remove_service.assert_called_once_with(
              "some_id"
          )
      else:
          docker_api_client_patcher.return_value.remove_service.assert_not_called()
  
file_path: airflow/tests/providers/docker/operators/test_docker_swarm.py
imports: from __future__ import annotations
  from unittest import mock
  import pytest
  from docker import APIClient, types
  from docker.constants import DEFAULT_TIMEOUT_SECONDS
  from docker.errors import APIError
  from airflow.exceptions import AirflowException
  from airflow.providers.docker.operators.docker_swarm import DockerSwarmOperator
label_desc: Use image node_id 5 for calling the TestDockerSwarmOperator obj's underlying member method code with example usage: obj.test_on_kill_client_created(docker_api_client_patcher, service_exists) without return types