SapphicCode commented on code in PR #33406:
URL: https://github.com/apache/airflow/pull/33406#discussion_r1331076663


##########
tests/sensors/test_time_sensor.py:
##########
@@ -73,3 +74,15 @@ def test_target_time_aware(self):
             op = TimeSensorAsync(task_id="test", target_time=aware_time)
             assert hasattr(op.target_datetime.tzinfo, "offset")
             assert op.target_datetime.tzinfo.offset == 0
+
+    def test_target_time_naive_dag_timezone(self):
+        """
+        Tests that naive target_time gets converted correctly using the DAG's 
timezone.
+        """
+        with DAG(
+            "test_target_time_naive_dag_timezone",
+            start_date=pendulum.datetime(2020, 1, 1, 0, 0, 
tz=DEFAULT_TIMEZONE),
+        ):
+            op = TimeSensorAsync(task_id="test", target_time=pendulum.time(9, 
0))
+            assert op.target_datetime.time() == pendulum.time(1, 0)
+            assert op.target_datetime.tzinfo == UTC

Review Comment:
   The line you're referring to here, `target_datetime`, is the datetime being 
given to `DateTimeTrigger` -> `defer`. It must always be converted to UTC.
   ![Code - 2023-09-20 08 40 
43](https://github.com/apache/airflow/assets/10685096/a52465ff-b36f-4b6b-9ae9-f9164b699a48)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to