karenbraganz commented on code in PR #65232:
URL: https://github.com/apache/airflow/pull/65232#discussion_r3083424453
##########
providers/cncf/kubernetes/tests/unit/cncf/kubernetes/operators/test_pod.py:
##########
@@ -2842,6 +2842,31 @@ def test_write_logs_gives_up_after_max_retries(
post_complete_action.assert_called_once()
assert "Reading of logs interrupted with error" in caplog.text
+ @patch(KUB_OP_PATH.format("client"))
+ def test_write_logs_with_valid_since_time(self, mocked_client):
+ """Test that since_seconds is calculated correctly when since_time is
a valid datetime."""
+ pod = k8s.V1Pod(metadata=k8s.V1ObjectMeta(name=TEST_NAME,
namespace=TEST_NAMESPACE))
+ since_time = datetime.datetime.now(tz=datetime.timezone.utc) -
datetime.timedelta(seconds=30)
+ k = KubernetesPodOperator(task_id="task", get_logs=True)
+
+ k._write_logs(pod, since_time=since_time)
+
+ _, call_kwargs = mocked_client.read_namespaced_pod_log.call_args
+ assert call_kwargs["since_seconds"] is not None
+ assert call_kwargs["since_seconds"] >= 30
+
+ @patch(KUB_OP_PATH.format("client"))
+ def test_write_logs_with_invalid_since_time_falls_back_to_none(self,
mocked_client, caplog):
Review Comment:
I have removed caplog.
--
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]