SameerMesiah97 commented on code in PR #74143:
URL: https://github.com/apache/airflow/pull/74143#discussion_r4172868341
##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/triggers/test_job.py:
##########
@@ -83,6 +83,31 @@ def test_serialize(self, trigger):
"do_xcom_push": XCOM_PUSH,
}
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize("poll_interval", [0.5, 60])
+ @mock.patch(f"{HOOK_PATH}.get_job_status", autospec=True)
+
@mock.patch("airflow.providers.cncf.kubernetes.hooks.kubernetes.asyncio.sleep",
autospec=True)
+ async def test_run_uses_configured_poll_interval(
+ self, mock_sleep, mock_get_job_status, trigger, poll_interval
+ ):
+ trigger.poll_interval = poll_interval
+ pending_job = k8s.V1Job(
+ metadata=k8s.V1ObjectMeta(name=JOB_NAME, namespace=NAMESPACE),
+ status=k8s.V1JobStatus(),
+ )
+ completed_job = k8s.V1Job(
+ metadata=k8s.V1ObjectMeta(name=JOB_NAME, namespace=NAMESPACE),
+
status=k8s.V1JobStatus(conditions=[k8s.V1JobCondition(type="Complete",
status="True")]),
+ )
+ mock_get_job_status.side_effect = [pending_job, completed_job]
+
+ event = await trigger.run().asend(None)
+
+ mock_sleep.assert_awaited_once_with(poll_interval)
+ assert mock_get_job_status.await_count == 2
+ assert event.payload["status"] == "success"
+ assert event.payload["job"] == completed_job.to_dict()
Review Comment:
Not a blocking concern but you could just remove this test and parameterize
the existing success test for the 2 non-default poll_interval values you are
covering. I dont think a new dedicated test is needed just for an additional
parameter.
--
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]