MCPcopy Create free account
hub / github.com/cft0808/edict / TestSyncScriptsToWorkspaces

Class TestSyncScriptsToWorkspaces

tests/test_sync_symlinks.py:134–227  ·  view source on GitHub ↗

Integration tests for the full ``sync_scripts_to_workspaces`` flow.

Source from the content-addressed store, hash-verified

132
133
134class TestSyncScriptsToWorkspaces:
135 """Integration tests for the full ``sync_scripts_to_workspaces`` flow."""
136
137 def test_creates_symlinks_in_workspace(self, project):
138 sac.sync_scripts_to_workspaces()
139
140 ws = project.home / '.openclaw' / 'workspace-aaa' / 'scripts'
141 assert ws.is_dir()
142
143 kb = ws / 'kanban_update.py'
144 assert kb.is_symlink(), 'expected symlink, got physical file'
145 assert kb.resolve() == (project.scripts / 'kanban_update.py').resolve()
146
147 rf = ws / 'refresh_live_data.py'
148 assert rf.is_symlink()
149
150 def test_skips_dunder_files(self, project):
151 sac.sync_scripts_to_workspaces()
152
153 ws = project.home / '.openclaw' / 'workspace-aaa' / 'scripts'
154 assert not (ws / '__init__.py').exists()
155
156 def test_legacy_workspace_main(self, project):
157 sac.sync_scripts_to_workspaces()
158
159 ws_main = project.home / '.openclaw' / 'workspace-main' / 'scripts'
160 assert ws_main.is_dir()
161
162 kb = ws_main / 'kanban_update.py'
163 assert kb.is_symlink()
164 assert kb.resolve() == (project.scripts / 'kanban_update.py').resolve()
165
166 def test_idempotent_rerun(self, project):
167 sac.sync_scripts_to_workspaces()
168 sac.sync_scripts_to_workspaces() # second run should be a no-op
169
170 ws = project.home / '.openclaw' / 'workspace-aaa' / 'scripts'
171 kb = ws / 'kanban_update.py'
172 assert kb.is_symlink()
173
174 def test_replaces_old_physical_copies(self, project):
175 """Simulate pre-existing physical copies (old behaviour) and verify
176 they get replaced by symlinks on the next sync run."""
177 ws = project.home / '.openclaw' / 'workspace-aaa' / 'scripts'
178 ws.mkdir(parents=True, exist_ok=True)
179 old_copy = ws / 'kanban_update.py'
180 old_copy.write_text('# stale physical copy')
181
182 sac.sync_scripts_to_workspaces()
183
184 assert old_copy.is_symlink(), 'old physical copy should be replaced'
185 assert old_copy.resolve() == (project.scripts / 'kanban_update.py').resolve()
186
187 def test_file_resolves_to_project_root(self, project):
188 """The whole point of #56: __file__ should resolve to project scripts/,
189 so Path(__file__).resolve().parent.parent == project root."""
190 sac.sync_scripts_to_workspaces()
191

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected