Skip to content

Commit bebc642

Browse files
arne-aignxclaude
andcommitted
test(application): link custom-metadata tests to TC-APPLICATION-CLI-07 scenarios [PYSDK-130][PYSDK-147]
Add record_property("tested-item-id", ...) traceability from the pytest tests to the TC-APPLICATION-CLI-07 test-case scenarios, SWR-APPLICATION-2-17, and the platform/application SIS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 9e78319 commit bebc642

3 files changed

Lines changed: 80 additions & 24 deletions

File tree

tests/aignostics/application/cli_test.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,9 @@ def test_cli_run_update_metadata_not_dict(runner: CliRunner) -> None:
11611161

11621162

11631163
@pytest.mark.unit
1164-
def test_cli_run_update_metadata_forwards_checksum(runner: CliRunner) -> None:
1164+
def test_cli_run_update_metadata_forwards_checksum(runner: CliRunner, record_property) -> None:
11651165
"""Check run update-metadata forwards --checksum to the service as a keyword argument."""
1166+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-01, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
11661167
with patch("aignostics.application._cli.Service") as mock_service_cls:
11671168
result = runner.invoke(
11681169
cli,
@@ -1184,8 +1185,9 @@ def test_cli_run_update_metadata_forwards_checksum(runner: CliRunner) -> None:
11841185

11851186

11861187
@pytest.mark.unit
1187-
def test_cli_run_update_metadata_default_enrich_sdk_metadata_true(runner: CliRunner) -> None:
1188+
def test_cli_run_update_metadata_default_enrich_sdk_metadata_true(runner: CliRunner, record_property) -> None:
11881189
"""Check run update-metadata passes enrich_sdk_metadata=True to the service by default."""
1190+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-04, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
11891191
with patch("aignostics.application._cli.Service") as mock_service_cls:
11901192
result = runner.invoke(cli, ["application", "run", "update-metadata", "run-123", '{"key": "value"}'])
11911193

@@ -1196,8 +1198,11 @@ def test_cli_run_update_metadata_default_enrich_sdk_metadata_true(runner: CliRun
11961198

11971199

11981200
@pytest.mark.unit
1199-
def test_cli_run_update_metadata_no_enrich_sdk_metadata_reaches_service_false(runner: CliRunner) -> None:
1201+
def test_cli_run_update_metadata_no_enrich_sdk_metadata_reaches_service_false(
1202+
runner: CliRunner, record_property
1203+
) -> None:
12001204
"""Check run update-metadata --no-enrich-sdk-metadata reaches the service as enrich_sdk_metadata=False."""
1205+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-03, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
12011206
with patch("aignostics.application._cli.Service") as mock_service_cls:
12021207
result = runner.invoke(
12031208
cli,
@@ -1218,8 +1223,9 @@ def test_cli_run_update_metadata_no_enrich_sdk_metadata_reaches_service_false(ru
12181223

12191224

12201225
@pytest.mark.unit
1221-
def test_cli_run_update_metadata_concurrency_conflict_exits_3(runner: CliRunner) -> None:
1226+
def test_cli_run_update_metadata_concurrency_conflict_exits_3(runner: CliRunner, record_property) -> None:
12221227
"""Check run update-metadata exits with code 3 when the service raises ConcurrencyConflictError."""
1228+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-02, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
12231229
with patch("aignostics.application._cli.Service") as mock_service_cls:
12241230
mock_service_cls.return_value.application_run_update_custom_metadata.side_effect = ConcurrencyConflictError(
12251231
"stale checksum"
@@ -1231,8 +1237,9 @@ def test_cli_run_update_metadata_concurrency_conflict_exits_3(runner: CliRunner)
12311237

12321238

12331239
@pytest.mark.unit
1234-
def test_cli_run_update_item_metadata_forwards_checksum(runner: CliRunner) -> None:
1240+
def test_cli_run_update_item_metadata_forwards_checksum(runner: CliRunner, record_property) -> None:
12351241
"""Check run update-item-metadata forwards --checksum to the service as a keyword argument."""
1242+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
12361243
with patch("aignostics.application._cli.Service") as mock_service_cls:
12371244
result = runner.invoke(
12381245
cli,
@@ -1255,8 +1262,14 @@ def test_cli_run_update_item_metadata_forwards_checksum(runner: CliRunner) -> No
12551262

12561263

12571264
@pytest.mark.unit
1258-
def test_cli_run_update_item_metadata_no_enrich_sdk_metadata_reaches_service_false(runner: CliRunner) -> None:
1265+
def test_cli_run_update_item_metadata_no_enrich_sdk_metadata_reaches_service_false(
1266+
runner: CliRunner, record_property
1267+
) -> None:
12591268
"""Check run update-item-metadata --no-enrich-sdk-metadata reaches the service as enrich_sdk_metadata=False."""
1269+
record_property(
1270+
"tested-item-id",
1271+
"TC-APPLICATION-CLI-07-03, TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE",
1272+
)
12601273
with patch("aignostics.application._cli.Service") as mock_service_cls:
12611274
result = runner.invoke(
12621275
cli,
@@ -1278,8 +1291,12 @@ def test_cli_run_update_item_metadata_no_enrich_sdk_metadata_reaches_service_fal
12781291

12791292

12801293
@pytest.mark.unit
1281-
def test_cli_run_update_item_metadata_concurrency_conflict_exits_3(runner: CliRunner) -> None:
1294+
def test_cli_run_update_item_metadata_concurrency_conflict_exits_3(runner: CliRunner, record_property) -> None:
12821295
"""Check run update-item-metadata exits with code 3 when the service raises ConcurrencyConflictError."""
1296+
record_property(
1297+
"tested-item-id",
1298+
"TC-APPLICATION-CLI-07-02, TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE",
1299+
)
12831300
with patch("aignostics.application._cli.Service") as mock_service_cls:
12841301
mock_service_cls.return_value.application_run_update_item_custom_metadata.side_effect = (
12851302
ConcurrencyConflictError("stale checksum")
@@ -1293,8 +1310,9 @@ def test_cli_run_update_item_metadata_concurrency_conflict_exits_3(runner: CliRu
12931310

12941311

12951312
@pytest.mark.unit
1296-
def test_cli_run_dump_metadata_show_checksum(runner: CliRunner) -> None:
1313+
def test_cli_run_dump_metadata_show_checksum(runner: CliRunner, record_property) -> None:
12971314
"""Check run dump-metadata --show-checksum wraps output with the checksum."""
1315+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-05, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
12981316
mock_run_data = MagicMock()
12991317
mock_run_data.custom_metadata = {"key": "value"}
13001318
mock_run_data.custom_metadata_checksum = "checksum-abc"
@@ -1312,8 +1330,9 @@ def test_cli_run_dump_metadata_show_checksum(runner: CliRunner) -> None:
13121330

13131331

13141332
@pytest.mark.unit
1315-
def test_cli_run_dump_item_metadata_show_checksum(runner: CliRunner) -> None:
1333+
def test_cli_run_dump_item_metadata_show_checksum(runner: CliRunner, record_property) -> None:
13161334
"""Check run dump-item-metadata --show-checksum wraps output with the checksum."""
1335+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-05, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
13171336
mock_item = MagicMock()
13181337
mock_item.external_id = "item-ext-id"
13191338
mock_item.custom_metadata = {"key": "value"}

tests/aignostics/application/service_test.py

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,9 @@ def test_application_run_update_custom_metadata_success(mock_get_client: MagicMo
521521

522522
@pytest.mark.unit
523523
@patch("aignostics.application._service.Service._get_platform_client")
524-
def test_application_run_update_custom_metadata_forwards_checksum(mock_get_client: MagicMock) -> None:
524+
def test_application_run_update_custom_metadata_forwards_checksum(mock_get_client: MagicMock, record_property) -> None:
525525
"""Test that custom_metadata_checksum is forwarded to the platform layer."""
526+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-01, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
526527
mock_client = MagicMock()
527528
mock_run = MagicMock()
528529
mock_client.run.return_value = mock_run
@@ -540,8 +541,11 @@ def test_application_run_update_custom_metadata_forwards_checksum(mock_get_clien
540541

541542
@pytest.mark.unit
542543
@patch("aignostics.application._service.Service._get_platform_client")
543-
def test_application_run_update_custom_metadata_forwards_enrich_sdk_metadata_false(mock_get_client: MagicMock) -> None:
544+
def test_application_run_update_custom_metadata_forwards_enrich_sdk_metadata_false(
545+
mock_get_client: MagicMock, record_property
546+
) -> None:
544547
"""Test that enrich_sdk_metadata=False is forwarded to the platform layer."""
548+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-03, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
545549
mock_client = MagicMock()
546550
mock_run = MagicMock()
547551
mock_client.run.return_value = mock_run
@@ -560,9 +564,10 @@ def test_application_run_update_custom_metadata_forwards_enrich_sdk_metadata_fal
560564
@pytest.mark.unit
561565
@patch("aignostics.application._service.Service._get_platform_client")
562566
def test_application_run_update_custom_metadata_static_forwards_enrich_sdk_metadata(
563-
mock_get_client: MagicMock,
567+
mock_get_client: MagicMock, record_property
564568
) -> None:
565569
"""Test that the static wrapper forwards enrich_sdk_metadata."""
570+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-03, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
566571
mock_client = MagicMock()
567572
mock_run = MagicMock()
568573
mock_client.run.return_value = mock_run
@@ -579,8 +584,11 @@ def test_application_run_update_custom_metadata_static_forwards_enrich_sdk_metad
579584

580585
@pytest.mark.unit
581586
@patch("aignostics.application._service.Service._get_platform_client")
582-
def test_application_run_update_custom_metadata_static_forwards_checksum(mock_get_client: MagicMock) -> None:
587+
def test_application_run_update_custom_metadata_static_forwards_checksum(
588+
mock_get_client: MagicMock, record_property
589+
) -> None:
583590
"""Test that the static wrapper forwards custom_metadata_checksum."""
591+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-01, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
584592
mock_client = MagicMock()
585593
mock_run = MagicMock()
586594
mock_client.run.return_value = mock_run
@@ -597,8 +605,11 @@ def test_application_run_update_custom_metadata_static_forwards_checksum(mock_ge
597605

598606
@pytest.mark.unit
599607
@patch("aignostics.application._service.Service._get_platform_client")
600-
def test_application_run_update_custom_metadata_concurrency_conflict(mock_get_client: MagicMock) -> None:
608+
def test_application_run_update_custom_metadata_concurrency_conflict(
609+
mock_get_client: MagicMock, record_property
610+
) -> None:
601611
"""Test that a 412 ApiException is mapped to ConcurrencyConflictError."""
612+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-02, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
602613
mock_client = MagicMock()
603614
mock_run = MagicMock()
604615
mock_run.update_custom_metadata.side_effect = ApiException(
@@ -619,8 +630,11 @@ def test_application_run_update_custom_metadata_concurrency_conflict(mock_get_cl
619630

620631
@pytest.mark.unit
621632
@patch("aignostics.application._service.Service._get_platform_client")
622-
def test_application_run_update_custom_metadata_non_412_api_exception_unchanged(mock_get_client: MagicMock) -> None:
633+
def test_application_run_update_custom_metadata_non_412_api_exception_unchanged(
634+
mock_get_client: MagicMock, record_property
635+
) -> None:
623636
"""Test that a non-412 ApiException keeps the pre-existing behavior (RuntimeError)."""
637+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-02, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
624638
mock_client = MagicMock()
625639
mock_run = MagicMock()
626640
mock_run.update_custom_metadata.side_effect = ApiException(
@@ -636,8 +650,9 @@ def test_application_run_update_custom_metadata_non_412_api_exception_unchanged(
636650

637651

638652
@pytest.mark.unit
639-
def test_concurrency_conflict_error_is_value_error() -> None:
653+
def test_concurrency_conflict_error_is_value_error(record_property) -> None:
640654
"""Test that ConcurrencyConflictError subclasses ValueError."""
655+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-02, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE")
641656
assert issubclass(ConcurrencyConflictError, ValueError)
642657

643658

@@ -683,9 +698,13 @@ def test_application_run_update_item_custom_metadata_success(mock_get_client: Ma
683698
@pytest.mark.unit
684699
@patch("aignostics.application._service.Service._get_platform_client")
685700
def test_application_run_update_item_custom_metadata_forwards_enrich_sdk_metadata_false(
686-
mock_get_client: MagicMock,
701+
mock_get_client: MagicMock, record_property
687702
) -> None:
688703
"""Test that enrich_sdk_metadata=False is forwarded for item metadata updates."""
704+
record_property(
705+
"tested-item-id",
706+
"TC-APPLICATION-CLI-07-03, TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE",
707+
)
689708
mock_client = MagicMock()
690709
mock_run = MagicMock()
691710
mock_client.run.return_value = mock_run
@@ -706,9 +725,13 @@ def test_application_run_update_item_custom_metadata_forwards_enrich_sdk_metadat
706725
@pytest.mark.unit
707726
@patch("aignostics.application._service.Service._get_platform_client")
708727
def test_application_run_update_item_custom_metadata_static_forwards_enrich_sdk_metadata(
709-
mock_get_client: MagicMock,
728+
mock_get_client: MagicMock, record_property
710729
) -> None:
711730
"""Test that the item static wrapper forwards enrich_sdk_metadata."""
731+
record_property(
732+
"tested-item-id",
733+
"TC-APPLICATION-CLI-07-03, TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE",
734+
)
712735
mock_client = MagicMock()
713736
mock_run = MagicMock()
714737
mock_client.run.return_value = mock_run
@@ -725,8 +748,14 @@ def test_application_run_update_item_custom_metadata_static_forwards_enrich_sdk_
725748

726749
@pytest.mark.unit
727750
@patch("aignostics.application._service.Service._get_platform_client")
728-
def test_application_run_update_item_custom_metadata_concurrency_conflict(mock_get_client: MagicMock) -> None:
751+
def test_application_run_update_item_custom_metadata_concurrency_conflict(
752+
mock_get_client: MagicMock, record_property
753+
) -> None:
729754
"""Test that a 412 ApiException for an item update is mapped to ConcurrencyConflictError."""
755+
record_property(
756+
"tested-item-id",
757+
"TC-APPLICATION-CLI-07-02, TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-APPLICATION-SERVICE",
758+
)
730759
mock_client = MagicMock()
731760
mock_run = MagicMock()
732761
mock_run.update_item_custom_metadata.side_effect = ApiException(

tests/aignostics/platform/resources/runs_test.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,9 @@ def test_results_omits_none_filters(app_run, mock_api) -> None:
13191319

13201320

13211321
@pytest.mark.unit
1322-
def test_update_custom_metadata_forwards_checksum(app_run, mock_api) -> None:
1322+
def test_update_custom_metadata_forwards_checksum(app_run, mock_api, record_property) -> None:
13231323
"""update_custom_metadata forwards custom_metadata_checksum on the update request."""
1324+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-01, SWR-APPLICATION-2-17, SPEC-PLATFORM-SERVICE")
13241325
with patch(_PATCH_BUILD_RUN_SDK_METADATA, return_value={}), patch(_PATCH_VALIDATE_RUN_SDK_METADATA):
13251326
app_run.update_custom_metadata({"key": "value"}, custom_metadata_checksum="abc123")
13261327

@@ -1330,8 +1331,9 @@ def test_update_custom_metadata_forwards_checksum(app_run, mock_api) -> None:
13301331

13311332

13321333
@pytest.mark.unit
1333-
def test_update_custom_metadata_enrich_default_calls_sdk_metadata_builders(app_run, mock_api) -> None:
1334+
def test_update_custom_metadata_enrich_default_calls_sdk_metadata_builders(app_run, mock_api, record_property) -> None:
13341335
"""Default enrich_sdk_metadata=True merges and validates SDK metadata."""
1336+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-04, SWR-APPLICATION-2-17, SPEC-PLATFORM-SERVICE")
13351337
mock_api.put_run_custom_metadata_v1_runs_run_id_custom_metadata_put.return_value = None
13361338
with (
13371339
patch(_PATCH_BUILD_RUN_SDK_METADATA, return_value={"schema_version": "0.0.1"}) as mock_build,
@@ -1348,8 +1350,9 @@ def test_update_custom_metadata_enrich_default_calls_sdk_metadata_builders(app_r
13481350

13491351

13501352
@pytest.mark.unit
1351-
def test_update_custom_metadata_no_enrich_skips_sdk_metadata_builders(app_run, mock_api) -> None:
1353+
def test_update_custom_metadata_no_enrich_skips_sdk_metadata_builders(app_run, mock_api, record_property) -> None:
13521354
"""enrich_sdk_metadata=False skips build/validate and forwards custom_metadata verbatim."""
1355+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-03, SWR-APPLICATION-2-17, SPEC-PLATFORM-SERVICE")
13531356
with (
13541357
patch(_PATCH_BUILD_RUN_SDK_METADATA) as mock_build,
13551358
patch(_PATCH_VALIDATE_RUN_SDK_METADATA) as mock_validate,
@@ -1365,8 +1368,9 @@ def test_update_custom_metadata_no_enrich_skips_sdk_metadata_builders(app_run, m
13651368

13661369

13671370
@pytest.mark.unit
1368-
def test_update_item_custom_metadata_forwards_checksum(app_run, mock_api) -> None:
1371+
def test_update_item_custom_metadata_forwards_checksum(app_run, mock_api, record_property) -> None:
13691372
"""update_item_custom_metadata forwards custom_metadata_checksum on the update request."""
1373+
record_property("tested-item-id", "TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-PLATFORM-SERVICE")
13701374
with patch(_PATCH_BUILD_ITEM_SDK_METADATA, return_value={}), patch(_PATCH_VALIDATE_ITEM_SDK_METADATA):
13711375
app_run.update_item_custom_metadata("item-ext-id", {"key": "value"}, custom_metadata_checksum="xyz789")
13721376

@@ -1378,8 +1382,12 @@ def test_update_item_custom_metadata_forwards_checksum(app_run, mock_api) -> Non
13781382

13791383

13801384
@pytest.mark.unit
1381-
def test_update_item_custom_metadata_no_enrich_skips_sdk_metadata_builders(app_run, mock_api) -> None:
1385+
def test_update_item_custom_metadata_no_enrich_skips_sdk_metadata_builders(app_run, mock_api, record_property) -> None:
13821386
"""enrich_sdk_metadata=False skips build/validate for items and forwards metadata verbatim."""
1387+
record_property(
1388+
"tested-item-id",
1389+
"TC-APPLICATION-CLI-07-03, TC-APPLICATION-CLI-07-06, SWR-APPLICATION-2-17, SPEC-PLATFORM-SERVICE",
1390+
)
13831391
with (
13841392
patch(_PATCH_BUILD_ITEM_SDK_METADATA) as mock_build,
13851393
patch(_PATCH_VALIDATE_ITEM_SDK_METADATA) as mock_validate,

0 commit comments

Comments
 (0)