ashb commented on a change in pull request #16599:
URL: https://github.com/apache/airflow/pull/16599#discussion_r656514287



##########
File path: tests/models/test_dag.py
##########
@@ -621,6 +621,46 @@ def test_following_schedule_relativedelta(self):
         _next = dag.following_schedule(_next)
         assert _next.isoformat() == "2015-01-02T02:00:00+00:00"
 
+    def test_previous_schedule_datetime_timezone(self):
+        # Check that we don't get an AttributeError 'name' for self.timezone
+
+        start = datetime.datetime(2018, 3, 25, 2, tzinfo=datetime.timezone.utc)
+        dag = DAG('tz_dag', start_date=start, schedule_interval='@hourly')
+        _next = dag.previous_schedule(start)
+        assert _next.isoformat() == "2018-03-25T01:00:00+00:00"
+
+    def test_following_schedule_datetime_timezone(self):
+        # Check that we don't get an AttributeError 'name' for self.timezone
+
+        start = datetime.datetime(2018, 3, 25, 2, tzinfo=datetime.timezone.utc)
+        dag = DAG('tz_dag', start_date=start, schedule_interval='@hourly')
+        _next = dag.following_schedule(start)
+        assert _next.isoformat() == "2018-03-25T03:00:00+00:00"
+
+    def test_following_schedule_datetime_timezone_utc0530(self):
+        # Check that we don't get an AttributeError 'name' for self.timezone
+        class UTC0530(datetime.tzinfo):
+            """tzinfo derived concrete class named "+0530" with offset of 
19800"""
+
+            # can be configured here
+            _offset = datetime.timedelta(seconds=19800)
+            _dst = datetime.timedelta(0)
+            _name = "+0530"
+
+            def utcoffset(self, dt):
+                return self.__class__._offset
+
+            def dst(self, dt):
+                return self.__class__._dst
+
+            def tzname(self, dt):
+                return self.__class__._name
+
+        start = datetime.datetime(2018, 3, 25, 10, tzinfo=UTC0530())
+        dag = DAG('tz_dag', start_date=start, schedule_interval='@hourly')
+        _next = dag.following_schedule(start)
+        assert _next.isoformat() == "2018-03-25T05:30:00+00:00"

Review comment:
       ```suggestion
           when = dag.following_schedule(start)
           assert when.isoformat() == "2018-03-25T05:30:00+00:00"
   ```

##########
File path: tests/models/test_dag.py
##########
@@ -621,6 +621,46 @@ def test_following_schedule_relativedelta(self):
         _next = dag.following_schedule(_next)
         assert _next.isoformat() == "2015-01-02T02:00:00+00:00"
 
+    def test_previous_schedule_datetime_timezone(self):
+        # Check that we don't get an AttributeError 'name' for self.timezone
+
+        start = datetime.datetime(2018, 3, 25, 2, tzinfo=datetime.timezone.utc)
+        dag = DAG('tz_dag', start_date=start, schedule_interval='@hourly')
+        _next = dag.previous_schedule(start)
+        assert _next.isoformat() == "2018-03-25T01:00:00+00:00"
+
+    def test_following_schedule_datetime_timezone(self):
+        # Check that we don't get an AttributeError 'name' for self.timezone
+
+        start = datetime.datetime(2018, 3, 25, 2, tzinfo=datetime.timezone.utc)
+        dag = DAG('tz_dag', start_date=start, schedule_interval='@hourly')
+        _next = dag.following_schedule(start)
+        assert _next.isoformat() == "2018-03-25T03:00:00+00:00"

Review comment:
       ```suggestion
           when = dag.following_schedule(start)
           assert when.isoformat() == "2018-03-25T03:00:00+00:00"
   ```

##########
File path: tests/models/test_dag.py
##########
@@ -621,6 +621,46 @@ def test_following_schedule_relativedelta(self):
         _next = dag.following_schedule(_next)
         assert _next.isoformat() == "2015-01-02T02:00:00+00:00"
 
+    def test_previous_schedule_datetime_timezone(self):
+        # Check that we don't get an AttributeError 'name' for self.timezone
+
+        start = datetime.datetime(2018, 3, 25, 2, tzinfo=datetime.timezone.utc)
+        dag = DAG('tz_dag', start_date=start, schedule_interval='@hourly')
+        _next = dag.previous_schedule(start)
+        assert _next.isoformat() == "2018-03-25T01:00:00+00:00"

Review comment:
       ```suggestion
           when = dag.previous_schedule(start)
           assert when.isoformat() == "2018-03-25T01:00:00+00:00"
   ```




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

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


Reply via email to