feluelle commented on a change in pull request #9246:
URL: https://github.com/apache/airflow/pull/9246#discussion_r501633221
##########
File path: tests/providers/amazon/aws/transfers/test_s3_to_redshift.py
##########
@@ -71,3 +71,56 @@ def test_execute(self, mock_run, mock_session):
assert mock_run.call_count == 1
assert_equal_ignore_multiple_spaces(self, mock_run.call_args[0][0],
copy_query)
+
+ @mock.patch("boto3.session.Session")
+ @mock.patch("airflow.providers.postgres.hooks.postgres.PostgresHook.run")
+ def test_truncate(self, mock_run, mock_session):
+ access_key = "aws_access_key_id"
+ secret_key = "aws_secret_access_key"
+ mock_session.return_value = Session(access_key, secret_key)
+
+ 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,
+ truncate_table=True,
+ redshift_conn_id="redshift_conn_id",
+ aws_conn_id="aws_conn_id",
+ task_id="task_id",
+ dag=None,
+ )
+ op.execute(None)
+
+ copy_statement = """
+ COPY {schema}.{table}
+ FROM 's3://{s3_bucket}/{s3_key}'
+ with credentials
+
'aws_access_key_id={access_key};aws_secret_access_key={secret_key}'
+ {copy_options};
+ """.format(
+ schema=schema,
+ table=table,
+ s3_bucket=s3_bucket,
+ s3_key=s3_key,
+ access_key=access_key,
+ secret_key=secret_key,
+ copy_options=copy_options,
+ )
Review comment:
Could you also use the f-strings here, please? :)
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]