code: def test_is_mandatory():
      c = Connection(
          None, None, "destination_component", InputSocket("in", int)
      )
      assert c.is_mandatory
  
      c = Connection(
          None,
          None,
          "destination_component",
          InputSocket("in", int, 42),
      )
      assert not c.is_mandatory
  
      c = Connection(
          "source_component", OutputSocket("out", int), None, None
      )
      assert not c.is_mandatory
  
file_path: haystack/test/core/component/test_connection.py
imports: from haystack.core.component.connection import Connection
  from haystack.core.component.sockets import InputSocket, OutputSocket
  from haystack.core.errors import PipelineConnectError
  import pytest
label_desc: Use image node_id 2 for calling a global function with example usage: test_is_mandatory() without return types