ferruzzi commented on code in PR #29144: URL: https://github.com/apache/airflow/pull/29144#discussion_r1086120021
########## tests/providers/amazon/aws/operators/test_lambda_function.py: ########## @@ -90,65 +84,69 @@ def test_init(self): assert lambda_operator.log_type == "None" assert lambda_operator.aws_conn_id == "aws_conn_test" - @staticmethod - def create_zip(body): - code = body - zip_output = io.BytesIO() - with zipfile.ZipFile(zip_output, "w", zipfile.ZIP_DEFLATED) as zip_file: - zip_file.writestr("lambda_function.py", code) - zip_output.seek(0) - return zip_output.read() - - @staticmethod - def create_iam_role(role_name: str): - iam = AwsBaseHook("aws_conn_test", client_type="iam") - resp = iam.conn.create_role( - RoleName=role_name, - AssumeRolePolicyDocument=json.dumps( - { - "Version": "2012-10-17", - "Statement": [ - { - "Effect": "Allow", - "Principal": {"Service": "lambda.amazonaws.com"}, - "Action": "sts:AssumeRole", - } - ], - } - ), - Description="IAM role for Lambda execution.", + @patch( Review Comment: Mocks are still a bit of black magic for me, but I think the same thing would be achieved in much shorter code using ```suggestion @patch.object(AwsLambdaInvokeFunctionOperator, "hook", new_callable=mock.PropertyMock) ``` But I'm still wrong on occasion about when to use `@patch.object` vs `@patch` -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org