|
12 | 12 | TODO: tests for 3 options of the planet-subscriptions-results command. |
13 | 13 |
|
14 | 14 | """ |
| 15 | +import itertools |
15 | 16 | import json |
16 | 17 |
|
17 | 18 | from click.testing import CliRunner |
@@ -356,3 +357,46 @@ def test_request_pv_success(invoke, geom_geojson): |
356 | 357 | source = json.loads(result.output) |
357 | 358 | assert source["type"] == "biomass_proxy" |
358 | 359 | assert source["parameters"]["id"] == "BIOMASS-PROXY_V3.0_10" |
| 360 | + |
| 361 | + |
| 362 | +@pytest.mark.parametrize( |
| 363 | + # Test all the combinations of the three options plus some with dupes. |
| 364 | + "publishing_stages", |
| 365 | + list( |
| 366 | + itertools.chain.from_iterable( |
| 367 | + itertools.combinations(["preview", "standard", "finalized"], i) |
| 368 | + for i in range(1, 4))) + [("preview", "preview"), |
| 369 | + ("preview", "finalized", "preview")]) |
| 370 | +def test_catalog_source_publishing_stages(invoke, |
| 371 | + geom_geojson, |
| 372 | + publishing_stages): |
| 373 | + """Catalog source publishing stages are configured.""" |
| 374 | + result = invoke([ |
| 375 | + 'request-catalog', |
| 376 | + '--item-types=PSScene', |
| 377 | + '--asset-types=ortho_analytic_4b', |
| 378 | + f"--geometry={json.dumps(geom_geojson)}", |
| 379 | + '--start-time=2021-03-01T00:00:00', |
| 380 | + ] + [f'--publishing-stage={stage}' for stage in publishing_stages]) |
| 381 | + |
| 382 | + assert result.exit_code == 0 # success. |
| 383 | + req = json.loads(result.output) |
| 384 | + assert req['parameters']['publishing_stages'] == list( |
| 385 | + set(publishing_stages)) |
| 386 | + |
| 387 | + |
| 388 | +@pytest.mark.parametrize("time_range_type", ["acquired", "published"]) |
| 389 | +def test_catalog_source_time_range_type(invoke, geom_geojson, time_range_type): |
| 390 | + """Catalog source time range type is configured.""" |
| 391 | + result = invoke([ |
| 392 | + 'request-catalog', |
| 393 | + '--item-types=PSScene', |
| 394 | + '--asset-types=ortho_analytic_4b', |
| 395 | + f"--geometry={json.dumps(geom_geojson)}", |
| 396 | + '--start-time=2021-03-01T00:00:00', |
| 397 | + f'--time-range-type={time_range_type}', |
| 398 | + ]) |
| 399 | + |
| 400 | + assert result.exit_code == 0 # success. |
| 401 | + req = json.loads(result.output) |
| 402 | + assert req['parameters']['time_range_type'] == time_range_type |
0 commit comments