abhishekbhakat commented on PR #54775:
URL: https://github.com/apache/airflow/pull/54775#issuecomment-3210281895

   Added tests that fail without the changes:
   
   ```bash
   _________________________________ 
test_dag_deserialize_ignores_templated_date_strings 
__________________________________
   
       def test_dag_deserialize_ignores_templated_date_strings():
           """
           Ensure that deserializing a DAG with a templated string in a *_date 
field
           does not attempt datetime coercion that would crash with a TypeError.
       
           This would fail prior to the guard that checks the value type is 
numeric.
           """
           dag = DAG(
               dag_id="test_templated_date_in_dag",
               schedule=None,
               start_date=timezone.datetime(2021, 1, 1),
           )
       
           dag.end_date = TEMPLATE_STR
       
           serialized = SerializedDAG.serialize_dag(dag)
           assert serialized.get("end_date") == TEMPLATE_STR
       
           # Would raise TypeError before the fix; should round-trip now
   >       deserialized = SerializedDAG.deserialize_dag(serialized)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   
   tests/serialization/test_templated_date_fields.py:76: 
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
   airflow/serialization/serialized_objects.py:1711: in deserialize_dag
       v = cls._deserialize_datetime(v)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
   
   timestamp = "{{ (data_interval_end - 
macros.timedelta(days=4)).strftime('%Y-%m-%d') }}", tz = Timezone('UTC')
   
       def from_timestamp(
           timestamp: int | float, tz: str | FixedTimezone | Timezone | 
Literal["local"] = utc
       ) -> DateTime:
           """
           Parse timestamp and return DateTime in a given time zone.
       
           :param timestamp: epoch time in seconds.
           :param tz: In which timezone should return a resulting object.
               Could be either one of pendulum timezone, IANA timezone or 
`local` literal.
       
           :meta private:
           """
   >       result = coerce_datetime(dt.datetime.fromtimestamp(timestamp, 
tz=utc))
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   E       TypeError: 'str' object cannot be interpreted as an integer
   
   airflow/utils/timezone.py:316: TypeError
   =============================================== short test summary info 
================================================
   FAILED 
tests/serialization/test_templated_date_fields.py::test_operator_deserialize_ignores_templated_date_strings
 - TypeError: 'str' object cannot be interpreted as an integer
   FAILED 
tests/serialization/test_templated_date_fields.py::test_dag_deserialize_ignores_templated_date_strings
 - TypeError: 'str' object cannot be interpreted as an integer
   ================================================== 2 failed in 0.99s 
===================================================
   ```
   


-- 
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