SEPURI-SAI-KRISHNA commented on code in PR #74171:
URL: https://github.com/apache/airflow/pull/74171#discussion_r4176058982
##########
providers/amazon/tests/unit/amazon/aws/operators/test_batch.py:
##########
@@ -92,6 +92,28 @@ def setup_method(self, _, get_client_type_mock):
self.mock_context = mock.MagicMock()
+ @patch.object(BatchClientHook, "get_job_awslogs_info")
+ def test_get_batch_log_fetcher_uses_operator_aws_configuration(self,
mock_get_job_awslogs_info):
+ mock_get_job_awslogs_info.return_value = {
+ "awslogs_region": "us-east-1",
+ "awslogs_group": "/aws/batch/job",
+ "awslogs_stream_name": "stream1",
+ }
+ batch = BatchOperator(
+ task_id="test_log_fetcher_configuration",
+ job_name=JOB_NAME,
+ job_queue="queue",
+ job_definition="hello-world",
+ awslogs_enabled=True,
+ verify="/path/to/ca-bundle.pem",
+ botocore_config={"read_timeout": 10},
+ )
+
+ fetcher = batch._get_batch_log_fetcher(JOB_ID)
+
+ assert fetcher.hook._verify == "/path/to/ca-bundle.pem"
+ assert fetcher.hook._config.read_timeout == 10
Review Comment:
Done, all three now assert at the interface.
The fetcher test mocks `AwsLogsHook` and asserts the whole call, which also
pins that `botocore_config` is forwarded as `config=`, the name
`AwsGenericHook` uses. The two operator tests mock `AwsTaskLogFetcher` and
assert only `verify` and `botocore_config` out of `call_args.kwargs`, since
that constructor takes eight arguments and pinning all of them would couple the
test to ones this change does not touch.
Worth noting for anyone copying it: the patch target has to be the operator
module, `airflow.providers.amazon.aws.operators.ecs.AwsTaskLogFetcher`, because
both operators import the name directly, so patching
`...utils.task_log_fetcher.AwsTaskLogFetcher` does not intercept construction.
`test_execute_complete_log_hook_uses_operator_aws_configuration` already does
it that way for `AwsLogsHook`.
Three pass with the change and three fail with it reverted.
--
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]