Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test case for s3-to-dc single absolute s3 path uri #486

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions apps/dc_tools/tests/test_s3_to_dc.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,24 @@ def test_s3_to_dc_stac(aws_env):
assert result.output == "Added 1 datasets and failed 0 datasets.\n"


@pytest.mark.depends(on=['add_products'])
def test_s3_to_dc_single_stac(aws_env):
runner = CliRunner()
# This will fail if requester pays is enabled
result = runner.invoke(
cli,
[
"--no-sign-request",
"--stac",
"--update-if-exists",
"s3://sentinel-cogs/sentinel-s2-l2a-cogs/42/T/UM/2022/1/S2B_42TUM_20220114_0_L2A/S2B_42TUM_20220114_0_L2A.json",
"s2_l2a",
],
)
assert result.exit_code == 0
assert result.output == "Added 1 datasets and failed 0 datasets.\n"


@pytest.mark.depends(on=['add_products'])
def test_s3_to_dc_stac_update_if_exist(aws_env):
runner = CliRunner()
Expand Down
5 changes: 5 additions & 0 deletions libs/cloud/odc/aws/_find.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,10 @@ def is_glob(s):

base = "/".join(base)
base = base.rstrip("/") + "/"
if not depth and not _file and not glob:
if '.' in base.split("/")[-2]:
_file = base.split("/")[-2]
base = "/".join(base.split("/")[:-2]) + "/"


return SimpleNamespace(base=base, depth=depth, file=_file, glob=glob)
5 changes: 4 additions & 1 deletion libs/cloud/tests/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,15 @@ def test_get_queues_empty(aws_env):

def test_parse_query():
E = SimpleNamespace
base = "s3://bucket/path/a/"
base = "s3://bucket.aws/path/a/"

assert parse_query(base) == E(base=base, depth=None, glob=None, file=None)
assert parse_query(base + "some") == E(
base=base + "some/", depth=None, glob=None, file=None
)
assert parse_query(base + "something/file.yaml") == E(
base=base+"something/", depth=None, glob=None, file="file.yaml"
)
assert parse_query(base + "*") == E(base=base, depth=0, glob="*", file=None)
assert parse_query(base + "*/*txt") == E(base=base, depth=1, glob="*txt", file=None)
assert parse_query(base + "*/*/*txt") == E(
Expand Down