Commit 3c9c261
committed
fix(tests): mock shutil.which so existing tests pass without sf installed
The previous commit replaced shell=True + "sf" string with shutil.which()
to resolve the sf executable path before calling subprocess.run. This
moved the "sf not found" check earlier — before _run_sf_command is even
defined — meaning tests that only mocked subprocess.run were now hitting
the shutil.which() call for real. On CI (Linux, no SF CLI), which()
returns None and raises immediately, causing all 11 SFCLITokenProvider
and SFCLIDataCloudReader tests to fail with "sf command was not found"
rather than exercising the error condition they were testing.
Fix: mock shutil.which alongside subprocess.run in each affected test,
using the same unittest.mock.patch pattern already used throughout the
test suite. return_value="sf" keeps the resolved path consistent with the
hardcoded "sf" string the command-list assertions in test_sf_cli.py
expect. The "sf not found" tests are updated to patch shutil.which
returning None instead of patching subprocess.run with FileNotFoundError,
since that FileNotFoundError path was removed from the production code.
No new test files, no new imports, no new patterns — all changes are
confined to existing test classes and follow the same nesting style used
in TestCredentialsTokenProvider and the rest of the suite.1 parent 6ee5618 commit 3c9c261
2 files changed
Lines changed: 30 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
118 | 123 | | |
119 | 124 | | |
120 | 125 | | |
121 | | - | |
| 126 | + | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
182 | | - | |
183 | | - | |
184 | | - | |
185 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
186 | 187 | | |
187 | | - | |
| 188 | + | |
188 | 189 | | |
189 | | - | |
190 | | - | |
191 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
192 | 193 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
199 | 200 | | |
200 | 201 | | |
201 | 202 | | |
| |||
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | | - | |
228 | | - | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
229 | 231 | | |
230 | | - | |
231 | | - | |
232 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
233 | 235 | | |
234 | 236 | | |
235 | | - | |
| 237 | + | |
236 | 238 | | |
237 | 239 | | |
238 | | - | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
0 commit comments