From 293da2ea72edb33653c85b9e590c80b169306404 Mon Sep 17 00:00:00 2001 From: Isaac To Date: Mon, 27 Jul 2026 15:43:51 -0700 Subject: [PATCH] test: build expected metadata with the server's DANDI schema version `test_update_dandiset_from_doi` builds the expected metadata with the `DANDI_SCHEMA_VERSION` of the client's `dandischema`, while the value in the metadata under test is the server's. The test therefore incidentally requires dandi-cli and the dandi-archive instance to carry the same `DANDI_SCHEMA_VERSION`. Retrieve it from the server's `/info/` instead. Co-Authored-By: Claude Code 2.1.220 / Claude Opus 5 --- dandi/cli/tests/test_service_scripts.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dandi/cli/tests/test_service_scripts.py b/dandi/cli/tests/test_service_scripts.py index 9c9ced5be..10a0a8713 100644 --- a/dandi/cli/tests/test_service_scripts.py +++ b/dandi/cli/tests/test_service_scripts.py @@ -9,7 +9,6 @@ import anys from click.testing import CliRunner -from dandischema.consts import DANDI_SCHEMA_VERSION from dandischema.models import ID_PATTERN import pytest @@ -104,18 +103,21 @@ def test_update_dandiset_from_doi( ) assert r.exit_code == 0 metadata = new_dandiset.dandiset.get_raw_metadata() + # The DANDI schema version in the metadata under test is the server's, + # not this client's. + server_schema_version = new_dandiset.client.get("/info/")["schema_version"] with (DATA_DIR / "update_dandiset_from_doi" / f"{name}.json").open() as fp: expected = json.load(fp) expected["id"] = anys.AnyFullmatch(rf"{ID_PATTERN}:{dandiset_id}/draft") expected["url"] = f"{repository}/dandiset/{dandiset_id}/draft" expected["@context"] = ( "https://raw.githubusercontent.com/dandi/schema/master/releases" - f"/{DANDI_SCHEMA_VERSION}/context.json" + f"/{server_schema_version}/context.json" ) expected["identifier"] = anys.AnyFullmatch(rf"{ID_PATTERN}:{dandiset_id}") expected["repository"] = repository expected["dateCreated"] = anys.ANY_AWARE_DATETIME_STR - expected["schemaVersion"] = DANDI_SCHEMA_VERSION + expected["schemaVersion"] = server_schema_version expected["wasGeneratedBy"][0]["id"] = anys.AnyFullmatch( r"urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" )