-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: safely import azure-storage-blob and boto3
- Loading branch information
1 parent
1b8302d
commit 9f740f6
Showing
6 changed files
with
111 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,10 +54,14 @@ tiff = | |
s3 = | ||
boto3 | ||
|
||
az = | ||
azure-storage-blob | ||
|
||
all = | ||
%(warp)s | ||
%(tiff)s | ||
%(s3)s | ||
%(az)s | ||
|
||
test = | ||
pytest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
from odc.geo.cog._s3 import MultiPartUpload | ||
"""Tests for odc.geo.cog._s3.""" | ||
|
||
# TODO: moto | ||
import unittest | ||
|
||
from odc.geo.cog._s3 import S3MultiPartUpload | ||
|
||
# Conditional import for S3 support | ||
try: | ||
from odc.geo.cog._s3 import S3MultiPartUpload | ||
|
||
HAVE_S3 = True | ||
except ImportError: | ||
S3MultiPartUpload = None | ||
HAVE_S3 = False | ||
|
||
|
||
def require_s3(test_func): | ||
"""Decorator to skip tests if s3 dependencies are not installed.""" | ||
return unittest.skipUnless(HAVE_S3, "s3 dependencies are not installed")(test_func) | ||
|
||
|
||
@require_s3 | ||
def test_s3_mpu(): | ||
mpu = MultiPartUpload("bucket", "file.dat") | ||
assert mpu.bucket == "bucket" | ||
assert mpu.key == "file.dat" | ||
"""Test S3MultiPartUpload class initialization.""" | ||
mpu = S3MultiPartUpload("bucket", "file.dat") | ||
if mpu.bucket != "bucket": | ||
raise ValueError("Invalid bucket") | ||
if mpu.key != "file.dat": | ||
raise ValueError("Invalid key") |