MCPcopy
hub / github.com/saltstack/salt / test_update

Method test_update

tests/integration/runners/test_fileserver.py:200–272  ·  view source on GitHub ↗

fileserver.update

(self)

Source from the content-addressed store, hash-verified

198
199 @pytest.mark.slow_test
200 def test_update(self):
201 """
202 fileserver.update
203 """
204 ret = self.run_run_plus(fun="fileserver.update")
205 self.assertTrue(ret["return"] is True)
206
207 # Backend submitted as a string
208 ret = self.run_run_plus(fun="fileserver.update", backend="roots")
209 self.assertTrue(ret["return"] is True)
210
211 # Backend submitted as a list
212 ret = self.run_run_plus(fun="fileserver.update", backend=["roots"])
213 self.assertTrue(ret["return"] is True)
214
215 # Possible '__pub_user' is removed from kwargs
216 ret = self.run_run_plus(
217 fun="fileserver.update", backend=["roots"], __pub_user="foo"
218 )
219 self.assertTrue(ret["return"] is True)
220
221 # Unknown arguments
222 ret = self.run_run_plus(
223 fun="fileserver.update", backend=["roots"], unknown_arg="foo"
224 )
225 self.assertIn(
226 "Passed invalid arguments: update() got an unexpected keyword argument"
227 " 'unknown_arg'",
228 ret["return"],
229 )
230
231 # Other arguments are passed to backend
232 def mock_gitfs_update(remotes=None):
233 pass
234
235 mock_backend_func = create_autospec(mock_gitfs_update)
236 mock_return_value = {
237 "gitfs.envs": None, # This is needed to activate the backend
238 "gitfs.update": mock_backend_func,
239 }
240 with patch("salt.loader.fileserver", MagicMock(return_value=mock_return_value)):
241 ret = self.run_run_plus(
242 fun="fileserver.update", backend="gitfs", remotes="myrepo,yourrepo"
243 )
244 self.assertTrue(ret["return"] is True)
245 mock_backend_func.assert_called_once_with(remotes="myrepo,yourrepo")
246
247 # Possible '__pub_user' arguments are removed from kwargs
248 mock_backend_func = create_autospec(mock_gitfs_update)
249 mock_return_value = {
250 "gitfs.envs": None, # This is needed to activate the backend
251 "gitfs.update": mock_backend_func,
252 }
253 with patch("salt.loader.fileserver", MagicMock(return_value=mock_return_value)):
254 ret = self.run_run_plus(
255 fun="fileserver.update",
256 backend="gitfs",
257 remotes="myrepo,yourrepo",

Callers

nothing calls this directly

Calls 2

run_run_plusMethod · 0.80
patchFunction · 0.50

Tested by

no test coverage detected