fix(cli): limit team workspace guard to bisync

Signed-off-by: Drew Cain <groksrc@gmail.com>
This commit is contained in:
Drew Cain
2026-05-27 19:12:55 -05:00
committed by Paul Hernandez
parent d0ae373f45
commit 8bf7bdbc0d
2 changed files with 60 additions and 20 deletions
+53 -7
View File
@@ -99,15 +99,12 @@ def test_cloud_bisync_fails_fast_when_sync_entry_disappears(monkeypatch, config_
@pytest.mark.parametrize(
"argv",
[
["cloud", "sync", "--name", "research"],
["cloud", "bisync", "--name", "research"],
["cloud", "check", "--name", "research"],
["cloud", "bisync-reset", "research"],
["cloud", "sync-setup", "research", "/tmp/research"],
],
)
def test_cloud_sync_commands_block_organization_workspace(monkeypatch, argv, config_manager):
"""Rclone sync commands should fail before setup/execution for Team workspaces."""
def test_cloud_bisync_commands_block_organization_workspace(monkeypatch, argv, config_manager):
"""Bisync commands should fail before setup/execution for Team workspaces."""
project_sync_command = importlib.import_module("basic_memory.cli.commands.cloud.project_sync")
config = config_manager.load_config()
@@ -130,13 +127,62 @@ def test_cloud_sync_commands_block_organization_workspace(monkeypatch, argv, con
"get_mount_info",
lambda: pytest.fail("workspace guard should run before mount lookup"),
)
monkeypatch.setattr(
project_sync_command,
"get_project_bisync_state",
lambda _name: pytest.fail("workspace guard should run before bisync state lookup"),
)
result = runner.invoke(app, argv)
assert result.exit_code == 1, result.output
output = " ".join(result.output.split())
assert "Mirror-style rclone sync/bisync is supported only for Personal workspaces" in output
assert "overwrite or delete shared cloud files" in output
assert "The bisync operation is only supported on Personal workspaces" in output
assert "Use `bm cloud sync --name research` instead" in output
def test_cloud_sync_allows_organization_workspace(monkeypatch, config_manager):
"""Team workspaces can still use the one-way sync command."""
project_sync_command = importlib.import_module("basic_memory.cli.commands.cloud.project_sync")
config = config_manager.load_config()
config.cloud_api_key = "bmc_test"
config.projects["research"] = ProjectEntry(
path="/tmp/research",
mode=ProjectMode.CLOUD,
workspace_id="team-tenant",
local_sync_path="/tmp/research",
)
config_manager.save_config(config)
monkeypatch.setattr(
project_sync_command,
"get_available_workspaces",
lambda: pytest.fail("sync should not require a personal workspace"),
)
monkeypatch.setattr(
project_sync_command,
"get_mount_info",
lambda: _async_value(SimpleNamespace(bucket_name="tenant-bucket")),
)
monkeypatch.setattr(
project_sync_command,
"_get_cloud_project",
lambda _name: _async_value(
SimpleNamespace(name="research", external_id="external-project-id", path="research")
),
)
monkeypatch.setattr(
project_sync_command,
"_get_sync_project",
lambda _name, _config, _project_data: (SimpleNamespace(name="research"), "/tmp/research"),
)
monkeypatch.setattr(project_sync_command, "project_sync", lambda *args, **kwargs: True)
result = runner.invoke(app, ["cloud", "sync", "--name", "research"])
assert result.exit_code == 0, result.output
assert "research synced successfully" in result.output
def test_require_personal_workspace_allows_personal_workspace(monkeypatch, config_manager):