code: def test_closest_ds_partition(self):
      date1 = datetime.strptime("2017-04-24", "%Y-%m-%d")
      date2 = datetime.strptime("2017-04-25", "%Y-%m-%d")
      date3 = datetime.strptime("2017-04-26", "%Y-%m-%d")
      date4 = datetime.strptime("2017-04-28", "%Y-%m-%d")
      date5 = datetime.strptime("2017-04-29", "%Y-%m-%d")
      target_dt = datetime.strptime("2017-04-27", "%Y-%m-%d")
      date_list = [date1, date2, date3, date4, date5]
  
      assert "2017-04-26" == str(
          hive._closest_date(target_dt, date_list, True)
      )
      assert "2017-04-28" == str(
          hive._closest_date(target_dt, date_list, False)
      )
  
      # when before is not set, the closest date should be returned
      assert "2017-04-26" == str(
          hive._closest_date(
              target_dt, [date1, date2, date3, date5], None
          )
      )
      assert "2017-04-28" == str(
          hive._closest_date(target_dt, [date1, date2, date4, date5])
      )
      assert "2017-04-26" == str(
          hive._closest_date(target_dt, date_list)
      )
  
imports: from __future__ import annotations
  from datetime import datetime
  from airflow.providers.apache.hive.macros import hive
label_desc: Use image node_id 1 for calling the TestHive obj's underlying member method code with example usage: obj.test_closest_ds_partition() without return types