code: def test_dpi_needed(image, text, vector, result, rgb_image, outdir):
      c = Canvas(str(outdir / "dpi.pdf"), pagesize=(5 * inch, 5 * inch))
      if image:
          c.drawImage(
              rgb_image,
              1 * inch,
              1 * inch,
              width=1 * inch,
              height=1 * inch,
          )
      if text:
          c.drawString(1 * inch, 4 * inch, "Actual text")
      if vector:
          c.ellipse(3 * inch, 3 * inch, 4 * inch, 4 * inch)
      c.showPage()
      c.save()
  
      pi = pdfinfo.PdfInfo(outdir / "dpi.pdf")
      pageinfo = pi[0]
      ctx = Mock()
      ctx.options.oversample = DUMMY_OVERSAMPLE_RESOLUTION[0]
      ctx.pageinfo = pageinfo
  
      assert _pipeline.get_canvas_square_dpi(ctx) == result
      assert _pipeline.get_page_square_dpi(ctx) == result
  
file_path: OCRmyPDF/tests/test_pipeline.py
imports: from __future__ import annotations
  import warnings
  from unittest.mock import Mock
  import pytest
  from PIL import Image
  from reportlab.lib.units import inch
  from reportlab.lib.utils import ImageReader
  from reportlab.pdfgen.canvas import Canvas
  from ocrmypdf import _pipeline, pdfinfo
  from ocrmypdf.helpers import Resolution
label_desc: Use image node_id 2 for calling a global function with example usage: test_dpi_needed(image, text, vector, result, rgb_image, outdir) without return types