diff --git a/dandi/dandiapi.py b/dandi/dandiapi.py index 655cd5340..087594939 100644 --- a/dandi/dandiapi.py +++ b/dandi/dandiapi.py @@ -425,6 +425,7 @@ def version(self) -> Version: self._version_id is None or vdict["version"] == self.version_id ): self._version = Version.parse_obj(vdict) + self._version_id = self._version.identifier return self._version assert self._version_id is not None self._version = self.get_version(self._version_id) diff --git a/dandi/tests/test_dandiapi.py b/dandi/tests/test_dandiapi.py index 7f18544b7..36be8f5a0 100644 --- a/dandi/tests/test_dandiapi.py +++ b/dandi/tests/test_dandiapi.py @@ -563,3 +563,19 @@ def test_get_digest_nonexistent(text_dandiset): asset = text_dandiset["dandiset"].get_asset_by_path("file.txt") with pytest.raises(NotFoundError): asset.get_digest("md5") + + +def test_refresh(text_dandiset): + dandiset = text_dandiset["dandiset"] + mtime = dandiset.version.modified + md = dandiset.get_metadata() + md.description = "A test Dandiset with altered metadata" + dandiset.set_metadata(md) + dandiset.wait_until_valid() + dandiset.publish() + assert dandiset.version.modified == mtime + assert dandiset.most_recent_published_version is None + dandiset.refresh() + assert dandiset.version_id == DRAFT + assert dandiset.version.modified > mtime + assert dandiset.most_recent_published_version is not None