hussein-awala commented on code in PR #34492:
URL: https://github.com/apache/airflow/pull/34492#discussion_r1332206397


##########
tests/serialization/serializers/test_serializers.py:
##########
@@ -51,6 +50,67 @@ def test_datetime(self):
         d = deserialize(s)
         assert i == d
 
+        i = datetime.datetime(
+            2022, 7, 10, 22, 10, 43, microsecond=0, 
tzinfo=pendulum.timezone("America/New_York")
+        )
+        s = serialize(i)
+        d = deserialize(s)
+        assert i.timestamp() == d.timestamp()
+
+        i = DateTime(2022, 7, 10, tzinfo=pendulum.timezone("America/New_York"))
+        s = serialize(i)
+        d = deserialize(s)
+        assert i.timestamp() == d.timestamp()
+
+    def test_deserialize_datetime_v1(self):
+
+        s = {
+            "__classname__": "pendulum.datetime.DateTime",
+            "__version__": 1,
+            "__data__": {"timestamp": 1657505443.0, "tz": "UTC"},
+        }
+        d = deserialize(s)
+        assert d.timestamp() == 1657505443.0
+        assert d.tzinfo.name == "UTC"
+
+        s["__data__"]["tz"] = "Europe/Paris"
+        d = deserialize(s)
+        assert d.timestamp() == 1657505443.0
+        assert d.tzinfo.name == "Europe/Paris"
+
+        s["__data__"]["tz"] = "America/New_York"
+        d = deserialize(s)
+        assert d.timestamp() == 1657505443.0
+        assert d.tzinfo.name == "America/New_York"
+
+        s["__data__"]["tz"] = "EDT"
+        d = deserialize(s)
+        assert d.timestamp() == 1657505443.0
+        assert d.tzinfo.name == "-04:00"
+        # assert that it's serializable with the new format
+        assert deserialize(serialize(d)) == d

Review Comment:
   This test ensures that the current version of the datetime Serializer fixes 
the bug by deserialize the US unsupported timezones, and that the deserialized 
values are serializable with the new format (if the user read an xcom 
serialized in version 1 and return it or send it to a new XCom)



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