Lee-W commented on code in PR #55110:
URL: https://github.com/apache/airflow/pull/55110#discussion_r2431778745
##########
providers/google/tests/unit/google/cloud/hooks/test_bigquery.py:
##########
@@ -673,11 +676,25 @@ def test_job_id_validity(self, mock_md5, test_dag_id,
expected_job_id):
job_id=None,
dag_id=test_dag_id,
task_id="test_job_id",
- logical_date=datetime(2020, 1, 23),
+ logical_date=None,
configuration=configuration,
+ run_after=datetime(2020, 1, 23),
)
assert job_id == expected_job_id
+ def test_get_run_after_or_logical_date(self):
+ if AIRFLOW_V_3_0_PLUS:
+ from airflow.models import DagRun
+ from airflow.sdk.definitions.context import Context
+
+ ctx = Context(dag_run=DagRun(run_after=pendulum.datetime(2025, 1,
1)))
+ assert self.hook.get_run_after_or_logical_date(ctx) ==
pendulum.datetime(2025, 1, 1)
+ else:
+ from airflow.utils.context import Context
+
+ ctx = Context(logical_date=pendulum.datetime(2025, 1, 1))
+ assert self.hook.get_run_after_or_logical_date(ctx) ==
pendulum.datetime(2025, 1, 1)
Review Comment:
```suggestion
if AIRFLOW_V_3_0_PLUS:
from airflow.models import DagRun
ctx = Context(dag_run=DagRun(run_after=pendulum.datetime(2025,
1, 1)))
else:
ctx = Context(logical_date=pendulum.datetime(2025, 1, 1))
assert self.hook.get_run_after_or_logical_date(ctx) ==
pendulum.datetime(2025, 1, 1)
```
let's move the context import to top like
`providers/google/tests/unit/google/cloud/operators/test_workflows.py`
--
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]