Skip to content

Commit

Permalink
Fixed tests for fail_on_file_not_exist option.
Browse files Browse the repository at this point in the history
  • Loading branch information
Guaqamole committed Nov 25, 2024
1 parent 2984be7 commit ae25482
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion providers/tests/amazon/aws/transfers/test_sftp_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,17 @@ def test_sftp_to_s3_fail_on_file_not_exist(self, fail_on_file_not_exist):
conn.create_bucket(Bucket=self.s3_bucket)
assert s3_hook.check_for_bucket(self.s3_bucket)

if fail_on_file_not_exist:
self.sftp_client.stat.return_value = FileNotFoundError
else:
self.sftp_client.stat.return_value = None

if fail_on_file_not_exist:
with pytest.raises(FileNotFoundError):
SFTPToS3Operator(
s3_bucket=self.s3_bucket,
s3_key=self.s3_key,
sftp_path=self.sftp_path,
sftp_path="/tmp/wrong_path.txt",
sftp_conn_id=SFTP_CONN_ID,
s3_conn_id=S3_CONN_ID,
fail_on_file_not_exist=fail_on_file_not_exist,
Expand All @@ -154,5 +159,6 @@ def test_sftp_to_s3_fail_on_file_not_exist(self, fail_on_file_not_exist):
dag=self.dag,
).execute(None)

conn.delete_object(Bucket=self.s3_bucket, Key=self.s3_key)
conn.delete_bucket(Bucket=self.s3_bucket)
assert not s3_hook.check_for_bucket(self.s3_bucket)

0 comments on commit ae25482

Please sign in to comment.