code: def test_list(context_objs, sagemaker_session):
      slack = datetime.timedelta(minutes=1)
      now = datetime.datetime.now(datetime.timezone.utc)
      context_names = [
          context_obj.context_name for context_obj in context_objs
      ]
  
      for sort_order in ["Ascending", "Descending"]:
          context_names_listed = [
              context_listed.context_name
              for context_listed in context.Context.list(
                  created_after=now - slack,
                  created_before=now + slack,
                  sort_by="CreationTime",
                  sort_order=sort_order,
                  sagemaker_session=sagemaker_session,
              )
              if context_listed.context_name in context_names
          ]
  
      if sort_order == "Descending":
          context_names_listed = context_names_listed[::-1]
      assert context_names == context_names_listed
      # sanity check
      assert context_names
  
file_path: sagemaker-python-sdk/tests/integ/sagemaker/lineage/test_context.py
imports: from __future__ import absolute_import
  import datetime
  import logging
  import time
  import pytest
  from sagemaker.lineage import context
  from sagemaker.lineage.query import LineageQueryDirectionEnum
label_desc: Use image node_id 6 for calling a global function with example usage: test_list(context_objs, sagemaker_session) without return types