You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/01/12 13:38:31 UTC

[GitHub] [airflow] ashb opened a new pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

ashb opened a new pull request #20826:
URL: https://github.com/apache/airflow/pull/20826


   - Testing BashOperator lives in tests.operators.test_bash
   - CheckOperator and ValueCheckOperator already tested in
     tests.operators.test.sql (using the non-deprecated names)
   - on_failure_callback already tested in test_local_task_job
   - SqliteOperator already tested in the sqlite provider
   - PythonOperator already extensively tested in
     tests.operators.test_python
   - trigger_rule tested in test_baseoperator
   - Testing the task context was partially covvered already.
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb merged pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

Posted by GitBox <gi...@apache.org>.
ashb merged pull request #20826:
URL: https://github.com/apache/airflow/pull/20826


   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #20826:
URL: https://github.com/apache/airflow/pull/20826#discussion_r783084638



##########
File path: tests/models/test_taskinstance.py
##########
@@ -1616,7 +1616,34 @@ def test_template_with_json_variable_missing(self, create_task_instance):
         with pytest.raises(KeyError):
             ti.task.render_template('{{ var.json.get("missing_variable") }}', context)
 
-    def test_tempalte_with_custom_timetable_deprecated_context(self, create_task_instance):
+    @pytest.mark.parametrize(
+        ("field", "expected"),
+        [
+            ("next_ds", "2016-01-01"),
+            ("next_ds_nodash", "20160101"),
+            ("prev_ds", "2015-12-31"),
+            ("prev_ds_nodash", "20151231"),
+            ("yesterday_ds", "2015-12-31"),
+            ("yesterday_ds_nodash", "20151231"),
+            ("tomorrow_ds", "2016-01-02"),
+            ("tomorrow_ds_nodash", "20160102"),
+        ],
+    )
+    def test_deprecated_context(self, field, expected, create_task_instance):
+        ti = create_task_instance(execution_date=DEFAULT_DATE)
+        context = ti.get_template_context()
+        with pytest.deprecated_call() as recorder:
+            assert context[field] == expected
+        message_beginning = (
+            f"Accessing {field!r} from the template is deprecated and "
+            f"will be removed in a future version."
+        )
+
+        recorded_message = [str(m.message) for m in recorder]
+        assert len(recorded_message) == 1
+        assert recorded_message[0].startswith(message_beginning)
+
+    def test_templte_with_custom_timetable_deprecated_context(self, create_task_instance):

Review comment:
       Whoops, typo'd the typo fix 😁 




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] potiuk commented on a change in pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #20826:
URL: https://github.com/apache/airflow/pull/20826#discussion_r783083652



##########
File path: tests/models/test_taskinstance.py
##########
@@ -1616,7 +1616,34 @@ def test_template_with_json_variable_missing(self, create_task_instance):
         with pytest.raises(KeyError):
             ti.task.render_template('{{ var.json.get("missing_variable") }}', context)
 
-    def test_tempalte_with_custom_timetable_deprecated_context(self, create_task_instance):
+    @pytest.mark.parametrize(
+        ("field", "expected"),
+        [
+            ("next_ds", "2016-01-01"),
+            ("next_ds_nodash", "20160101"),
+            ("prev_ds", "2015-12-31"),
+            ("prev_ds_nodash", "20151231"),
+            ("yesterday_ds", "2015-12-31"),
+            ("yesterday_ds_nodash", "20151231"),
+            ("tomorrow_ds", "2016-01-02"),
+            ("tomorrow_ds_nodash", "20160102"),
+        ],
+    )
+    def test_deprecated_context(self, field, expected, create_task_instance):
+        ti = create_task_instance(execution_date=DEFAULT_DATE)
+        context = ti.get_template_context()
+        with pytest.deprecated_call() as recorder:
+            assert context[field] == expected
+        message_beginning = (
+            f"Accessing {field!r} from the template is deprecated and "
+            f"will be removed in a future version."
+        )
+
+        recorded_message = [str(m.message) for m in recorder]
+        assert len(recorded_message) == 1
+        assert recorded_message[0].startswith(message_beginning)
+
+    def test_templte_with_custom_timetable_deprecated_context(self, create_task_instance):

Review comment:
       ```suggestion
       def test_template_with_custom_timetable_deprecated_context(self, create_task_instance):
   ```




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on a change in pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

Posted by GitBox <gi...@apache.org>.
ashb commented on a change in pull request #20826:
URL: https://github.com/apache/airflow/pull/20826#discussion_r783154034



##########
File path: tests/core/test_core.py
##########
@@ -16,32 +16,21 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import os
-import signal
-from datetime import timedelta
+from datetime import datetime, timedelta

Review comment:
       ```suggestion
   from datetime import timedelta
   ```

##########
File path: tests/core/test_core.py
##########
@@ -16,32 +16,21 @@
 # specific language governing permissions and limitations
 # under the License.
 
-import os
-import signal
-from datetime import timedelta
+from datetime import datetime, timedelta
 from time import sleep
-from unittest.mock import MagicMock
 
 import pytest
 
 from airflow import settings
-from airflow.exceptions import AirflowException, AirflowTaskTimeout
-from airflow.hooks.base import BaseHook
-from airflow.models import DagBag, TaskFail, TaskInstance
+from airflow.exceptions import AirflowTaskTimeout
+from airflow.models import TaskFail, TaskInstance
 from airflow.operators.bash import BashOperator
-from airflow.operators.check_operator import CheckOperator, ValueCheckOperator
 from airflow.operators.dummy import DummyOperator
 from airflow.operators.python import PythonOperator
-from airflow.utils.dates import days_ago
-from airflow.utils.state import State
-from airflow.utils.timezone import datetime
 from airflow.utils.types import DagRunType

Review comment:
       ```suggestion
   from airflow.utils.timezone import datetime
   from airflow.utils.types import DagRunType
   ```




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] github-actions[bot] commented on pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #20826:
URL: https://github.com/apache/airflow/pull/20826#issuecomment-1011059757


   The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [airflow] ashb commented on pull request #20826: Move tests out of test core that are duplicated/should live elsewhere

Posted by GitBox <gi...@apache.org>.
ashb commented on pull request #20826:
URL: https://github.com/apache/airflow/pull/20826#issuecomment-1011331183


   One flaky DASK test on a single matrix:
   
   ```
   tests/executors/test_dask_executor.py::TestDaskExecutorQueue::test_dask_queues: ValueError: The futures should have finished; there is probably an error communicating with the Dask cluster.
   ```


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org