Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/providers/amazon/aws/hooks/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def parse_s3_url(s3url: str) -> Tuple[str, str]:
raise AirflowException(f'Please provide a bucket_name instead of "{s3url}"')

bucket_name = parsed_url.netloc
key = parsed_url.path.strip('/')
key = parsed_url.path.lstrip('/')

return bucket_name, key

Expand Down
4 changes: 4 additions & 0 deletions tests/providers/amazon/aws/hooks/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def test_parse_s3_url(self):
parsed = S3Hook.parse_s3_url("s3://test/this/is/not/a-real-key.txt")
assert parsed == ("test", "this/is/not/a-real-key.txt"), "Incorrect parsing of the s3 url"

def test_parse_s3_object_directory(self):
parsed = S3Hook.parse_s3_url("s3://test/this/is/not/a-real-s3-directory/")
assert parsed == ("test", "this/is/not/a-real-s3-directory/"), "Incorrect parsing of the s3 url"

def test_check_for_bucket(self, s3_bucket):
hook = S3Hook()
assert hook.check_for_bucket(s3_bucket) is True
Expand Down