From 1560544de29b85fffddfdea39a3113460a4ccaac Mon Sep 17 00:00:00 2001 From: mgrani Date: Thu, 6 Aug 2026 17:00:07 +0200 Subject: [PATCH] test(remote): stop the pull sidecar test writing into the repo The counter-case test added in 1a11291 requested `tmp_path` and never used it, so `remote_pull` ran with `manager.local.create()` left as a bare MagicMock. `_write_pull_sidecars` -> core/sync.py takes the local dataset path, and a MagicMock resolves through __fspath__ to a repr-derived *relative* path -- so every run mkdir'd `MagicMock/mock.local.create().path//` into the current working directory. That is the untracked MagicMock/ directory in the tree. Point the local dataset at tmp_path, which is what requesting the fixture implied, and assert the absence afterwards so a future sidecar write that escapes into the working directory fails the test rather than littering. Fixing rather than gitignoring: a .gitignore entry would have silenced the symptom and left tests writing outside their sandbox. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_017phbSd6D8u4iEQsCAPEw6s --- tests/owilix/core/tasks/test_remote.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/owilix/core/tasks/test_remote.py b/tests/owilix/core/tasks/test_remote.py index 5f3d98c..9ef8df7 100644 --- a/tests/owilix/core/tasks/test_remote.py +++ b/tests/owilix/core/tasks/test_remote.py @@ -8,6 +8,7 @@ import json import os import tempfile from collections import Counter +from pathlib import Path from types import SimpleNamespace from unittest.mock import MagicMock, patch, PropertyMock @@ -780,12 +781,22 @@ class TestRemotePull: ds = _make_mock_dataset() manager = _make_mock_manager(datasets=[ds]) manager.remote_data.files.return_value = [] + # remote_pull writes sync sidecars under the *local* dataset path + # (_write_pull_sidecars -> core/sync.py). Left as a bare MagicMock, that + # path resolves through __fspath__ to a repr-derived relative path and + # the run mkdirs `MagicMock/mock.local.create().path//` into the + # current working directory -- i.e. into the repo. Point it at tmp_path. + local_target = tmp_path / "pulled-dataset" + local_target.mkdir() + manager.local.create.return_value.path = str(local_target) result = remote_pull( manager, specifier="dc1/public", files="['**/*']", console=MagicMock() ) assert result.success is True + # The sidecars belong to the dataset, not to wherever the process ran. + assert not (Path.cwd() / "MagicMock").exists() @patch("owilix.core.tasks.remote.ask_yes_no", return_value=False) def test_user_declines(self, mock_ask): -- 2.51.2