Skip to content

Commit e9f60e8

Browse files
fix: add isdir mock to filepath unit tests
Two tests that mock the storage backend were not setting mock_backend.isdir.return_value = False. The new encode() logic calls backend.isdir() before backend.size(), so without the mock isdir() returned a truthy MagicMock, making is_dir=True and skipping the size() call entirely (leaving size=None). Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
1 parent d66a288 commit e9f60e8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tests/unit/test_codecs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ def test_filepath_allows_user_paths(self):
548548
with patch("datajoint.hash_registry.get_store_backend") as mock_get_backend:
549549
mock_backend = MagicMock()
550550
mock_backend.exists.return_value = True
551+
mock_backend.isdir.return_value = False
551552
mock_backend.size.return_value = 1024
552553
mock_get_backend.return_value = mock_backend
553554

@@ -636,6 +637,7 @@ def test_filepath_enforces_filepath_prefix(self):
636637
with patch("datajoint.hash_registry.get_store_backend") as mock_get_backend:
637638
mock_backend = MagicMock()
638639
mock_backend.exists.return_value = True
640+
mock_backend.isdir.return_value = False
639641
mock_backend.size.return_value = 3072
640642
mock_get_backend.return_value = mock_backend
641643

0 commit comments

Comments
 (0)