Adaverse commented on code in PR #32328:
URL: https://github.com/apache/airflow/pull/32328#discussion_r1250937194
##########
tests/providers/amazon/aws/transfers/test_s3_to_redshift.py:
##########
@@ -324,6 +324,55 @@ def test_execute_role_arn(self, mock_run, mock_session,
mock_connection, mock_ho
assert mock_run.call_count == 1
assert_equal_ignore_multiple_spaces(mock_run.call_args.args[0],
copy_statement)
+ @mock.patch("airflow.providers.amazon.aws.hooks.s3.S3Hook.get_connection")
+ @mock.patch("airflow.models.connection.Connection")
+ @mock.patch("boto3.session.Session")
+
@mock.patch("airflow.providers.amazon.aws.hooks.redshift_sql.RedshiftSQLHook.run")
+ def test_different_region(self, mock_run, mock_session, mock_connection,
mock_hook):
+ access_key = "aws_access_key_id"
+ secret_key = "aws_secret_access_key"
+ extra = {"region": "eu-central-1"}
+ mock_session.return_value = Session(access_key, secret_key)
+ mock_session.return_value.access_key = access_key
+ mock_session.return_value.secret_key = secret_key
+ mock_session.return_value.token = None
+
+ mock_connection.return_value = Connection(extra=extra)
+ mock_hook.return_value = Connection(extra=extra)
+
+ schema = "schema"
+ table = "table"
+ s3_bucket = "bucket"
+ s3_key = "key"
+ copy_options = ""
+
+ op = S3ToRedshiftOperator(
+ schema=schema,
+ table=table,
+ s3_bucket=s3_bucket,
+ s3_key=s3_key,
+ copy_options=copy_options,
+ redshift_conn_id="redshift_conn_id",
+ aws_conn_id="aws_conn_id",
+ task_id="task_id",
+ dag=None,
+ )
+ op.execute(None)
+ copy_query = """
+ COPY schema.table
+ FROM 's3://bucket/key'
+ credentials
+
'aws_access_key_id=aws_access_key_id;aws_secret_access_key=aws_secret_access_key'
+ region 'eu-central-1'
+ ;
+ """
+
+ assert access_key in copy_query
+ assert secret_key in copy_query
+ assert extra["region"] in copy_query
Review Comment:
Yes, i think the return value of `_build_copy_query` should cover the
changes made with these assertions.
--
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]