From dd3b08f1df674ffa018a5c372a5aa8426f363b09 Mon Sep 17 00:00:00 2001 From: Rakes Date: Thu, 3 Sep 2026 14:10:51 +0530 Subject: [PATCH] test(lerobot): use realistic valid shas in cache-namespacing test The cache-namespacing test stubs _hf_repo_info wholesale, so its fixtures are never validated by the production hex-only sha guard. Replace the non-hex 'sha-a'/'sha-b' literals with 40-character hexadecimal shas and reference them by variable in the assertions, so a future bug in the validator or the cache-path construction has a test that can fail for the right reason. The test's contract is unchanged: two revisions that resolve to the same sha share one cache directory, a different sha gets its own. --- tests/test_lerobot_converter.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/test_lerobot_converter.py b/tests/test_lerobot_converter.py index 9075eca..39a24a1 100755 --- a/tests/test_lerobot_converter.py +++ b/tests/test_lerobot_converter.py @@ -393,7 +393,18 @@ def fake_dl(url: str, dest: Path, **kw: object) -> None: def test_import_namespaces_source_cache_by_resolved_revision( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: - resolved_shas = {"branch-a": "sha-a", "branch-b": "sha-b", "tag-a": "sha-a"} + # Realistic valid shas the production validator at + # src/hflow/importers/lerobot.py would accept: 40-character hexadecimal, + # visibly distinct at the start so a reader can tell them apart at a + # glance. ``branch-a`` and ``tag-a`` resolve to the same sha on purpose: + # they are the two-revisions-one-cache leg of the contract. + sha_a = "a1b2c3d4e5f60718293a4b5c6d7e8f9001020304" + sha_b = "f0e1d2c3b4a5968778695a4b3c2d1e0f00112233" + resolved_shas = { + "branch-a": sha_a, + "branch-b": sha_b, + "tag-a": sha_a, + } cache_observations: list[tuple[str, Path, str]] = [] monkeypatch.setattr( @@ -431,13 +442,13 @@ def fake_ensure_source_archive(dataset_source: prep.DatasetSource, cache_dir: Pa ) assert cache_observations == [ - ("sha-a", tmp_path / "_lerobot_cache" / "sha-a", "sha-a"), - ("sha-b", tmp_path / "_lerobot_cache" / "sha-b", "sha-b"), - ("sha-a", tmp_path / "_lerobot_cache" / "sha-a", "sha-a"), + (sha_a, tmp_path / "_lerobot_cache" / sha_a, sha_a), + (sha_b, tmp_path / "_lerobot_cache" / sha_b, sha_b), + (sha_a, tmp_path / "_lerobot_cache" / sha_a, sha_a), ] assert sorted(path.name for path in (tmp_path / "_lerobot_cache").iterdir()) == [ - "sha-a", - "sha-b", + sha_a, + sha_b, ]