Skip to content

Commit 3027101

Browse files
committed
add tests
1 parent b2166ce commit 3027101

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

tests/integration/test_orders_cli.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,49 @@ def test_cli_orders_request_product_bundle_incompatible(mock_bundles, invoke):
514514
assert result.exit_code == 2
515515

516516

517+
@pytest.mark.parametrize(
518+
"bundle, fallback_bundle",
519+
[
520+
('analytic_8b_udm2', 'analytic_udm2'),
521+
('analytic_8b_udm2', 'analytic_udm2,analytic_3b_udm2'),
522+
])
523+
def test_cli_orders_request_fallback_bundle_success(mock_bundles,
524+
invoke,
525+
bundle,
526+
fallback_bundle):
527+
result = invoke([
528+
'request',
529+
'--item-type=PSScene',
530+
f'--bundle={bundle}',
531+
f'--fallback-bundle={fallback_bundle}',
532+
'--name=my order',
533+
'20250130_035211_69_2516'
534+
])
535+
assert result.exit_code == 0
536+
537+
538+
@pytest.mark.parametrize(
539+
"bundle, fallback_bundle",
540+
[
541+
('analytic_8b_udm2', ''),
542+
('analytic_8b_udm2', 'analytic_udm2;analytic_3b_udm2'),
543+
('analytic_8b_udm2', 'analytic_udm2,analytic_3b_udm2,fake_bundle'),
544+
])
545+
def test_cli_orders_request_fallback_bundle_fail(mock_bundles,
546+
invoke,
547+
bundle,
548+
fallback_bundle):
549+
result = invoke([
550+
'request',
551+
'--item-type=PSScene',
552+
f'--bundle={bundle}',
553+
f'--fallback-bundle={fallback_bundle}',
554+
'--name=my order',
555+
'20250130_035211_69_2516'
556+
])
557+
assert result.exit_code == 2
558+
559+
517560
def test_cli_orders_request_id_empty(mock_bundles, invoke):
518561
result = invoke([
519562
'request', '--item-type=PSScene', '--bundle=visual', '--name=test', ''

tests/unit/test_order_request.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,3 +404,38 @@ def test_sentinel_hub_collection_configuration():
404404
}
405405
}
406406
assert sh_config == expected
407+
408+
409+
@pytest.mark.parametrize(
410+
"bundle, fallback_bundle",
411+
[
412+
('analytic_8b_udm2', 'analytic_udm2'),
413+
('analytic_8b_udm2', 'analytic_udm2,analytic_3b_udm2'),
414+
])
415+
def test_fallback_bundle_success(bundle, fallback_bundle):
416+
product = order_request.product(["20250130_035211_69_2516"],
417+
bundle,
418+
"PSScene",
419+
fallback_bundle=fallback_bundle)
420+
421+
expected = {
422+
"item_ids": ["20250130_035211_69_2516"],
423+
"item_type": "PSScene",
424+
"product_bundle": f"{bundle},{fallback_bundle}"
425+
}
426+
assert product == expected
427+
428+
429+
@pytest.mark.parametrize(
430+
"bundle, fallback_bundle",
431+
[
432+
('analytic_8b_udm2', ''),
433+
('analytic_8b_udm2', 'analytic_udm2;analytic_3b_udm2'),
434+
('analytic_8b_udm2', 'analytic_udm2,analytic_3b_udm2,fake_bundle'),
435+
])
436+
def test_fallback_bundle_invalid(bundle, fallback_bundle):
437+
with pytest.raises(specs.SpecificationException):
438+
_ = order_request.product(["20250130_035211_69_2516"],
439+
bundle,
440+
"PSScene",
441+
fallback_bundle=fallback_bundle)

0 commit comments

Comments
 (0)