code: def assert_results(
      s3objs,
      expected,
      info_should_be_empty=False,
      info_only=False,
      ranges_fetched=None,
      encryption=None,
  ):
      # did we receive all expected objects and nothing else?
      if info_only:
          info_should_be_empty = False
      if ranges_fetched is None:
          ranges_fetched = [None] * len(s3objs)
      assert len(s3objs) == len(ranges_fetched)
  
      for s3obj, range_info in zip(s3objs, ranges_fetched):
          # assert that all urls returned are unicode, if not None
          assert isinstance(s3obj.key, (unicode_type, type(None)))
          assert isinstance(s3obj.url, (unicode_type, type(None)))
          assert isinstance(s3obj.prefix, (unicode_type, type(None)))
  
          # is key actually a suffix?
          assert s3obj.url.endswith(s3obj.key)
          if s3obj.prefix:
              # is prefix actually a prefix?
              assert s3obj.url.startswith(s3obj.prefix)
              # key must look like a real key
              assert 0 < len(s3obj.key) < len(s3obj.url)
          else:
              # if there's no prefix, the key is the url
              assert s3obj.url == s3obj.key
  
          if range_info:
              expected_result = expected[s3obj.url].get(
                  (range_info.req_offset, range_info.req_size)
              )
          else:
              expected_result = expected[s3obj.url].get(None)
          assert expected_result
          size = expected_result.size
          checksum = expected_result.checksum
          content_type = expected_result.content_type
          metadata = expected_result.metadata
          range_to_match = expected_result.range
          if size is None:
              assert s3obj.exists is False
              assert s3obj.downloaded is False
          else:
              assert s3obj.exists is True
              if info_only:
                  assert s3obj.downloaded is False
              else:
                  assert s3obj.downloaded is True
                  # local file exists?
                  assert os.path.exists(s3obj.path)
                  # blob is ok?
                  blob = s3obj.blob
                  assert len(blob) == size
                  assert type(blob) == type(b"")
                  assert sha1(blob).hexdigest() == checksum
              # size is ok?
              assert s3obj.size == size
              if info_should_be_empty:
                  assert not s3obj.has_info
              else:
                  assert s3obj.has_info
                  # Content_type is OK
                  if content_type is None:
                      # Default content-type when nothing is supplied
                      assert s3obj.content_type == "binary/octet-stream"
                  else:
                      assert s3obj.content_type == content_type
                  # Range information is properly reported. Note that in this case, even
                  # for whole files we return a range. Ranges don't exist for just information
                  # on files
                  if not info_only:
                      s3obj_range_info = s3obj.range_info
                      assert s3obj_range_info is not None
                      if range_to_match is None:
                          # This is the entire file
                          assert s3obj_range_info.total_size == size
                          assert s3obj_range_info.request_offset == 0
                          assert s3obj_range_info.request_length == size
                      else:
                          # A specific range of the file
                          assert (
                              s3obj_range_info.total_size
                              == range_to_match.total_size
                          )
                          assert (
                              s3obj_range_info.request_offset
                              == range_to_match.result_offset
                          )
                          assert (
                              s3obj_range_info.request_length
                              == range_to_match.result_size
                          )
                  # metadata is OK
                  if metadata is None:
                      assert s3obj.metadata is None
                  else:
                      s3objmetadata = s3obj.metadata
                      assert s3objmetadata is not None
                      found = set()
                      for k, v in metadata.items():
                          v1 = s3objmetadata.get(k, None)
                          assert v1 == v, "Metadata %s mismatch" % k
                          found.add(k)
                      extra_keys = set(s3objmetadata.keys()) - found
                      assert (
                          not extra_keys
                      ), "Additional metadata present %s" % str(
                          extra_keys
                      )
                  # if encryption was used
                  if encryption:
                      assert s3obj.encryption == encryption
  
imports: import os
  from re import I
  import shutil
  from hashlib import sha1
  from tempfile import mkdtemp
  from itertools import groupby, starmap
  import random
  from uuid import uuid4
  from metaflow.plugins.datatools import s3
  import pytest
  from metaflow import current, namespace, Run
  from metaflow.plugins.datatools.s3 import S3, MetaflowS3AccessDenied, MetaflowS3NotFound, MetaflowS3URLException, MetaflowS3InvalidObject, S3PutObject, S3GetObject
  from metaflow.util import to_bytes, unicode_type
  from .None import s3_data
  from ..None import FakeFlow, DO_TEST_RUN
label_desc: Use image node_id 2 for calling a global function with example usage: assert_results(s3objs, expected, info_should_be_empty, info_only, ranges_fetched, encryption) without return types