MCPcopy Index your code
hub / github.com/saltstack/salt / test_cache_master

Function test_cache_master

tests/pytests/unit/fileclient/test_fileclient_cache.py:350–374  ·  view source on GitHub ↗

Test caching multiple files

(mocked_opts, minion_opts, fs_root)

Source from the content-addressed store, hash-verified

348
349
350def test_cache_master(mocked_opts, minion_opts, fs_root):
351 """
352 Test caching multiple files
353 """
354 patched_opts = minion_opts.copy()
355 patched_opts.update(mocked_opts)
356
357 with patch.dict(fileclient.__opts__, patched_opts):
358 client = fileclient.get_file_client(fileclient.__opts__, pillar=False)
359 for saltenv in _saltenvs():
360 assert client.cache_master(saltenv=saltenv)
361 for dirpath, _, filenames in os.walk(os.path.join(fs_root, saltenv)):
362 for fn in filenames:
363 fileserver_path = os.path.relpath(
364 os.path.join(dirpath, fn), fs_root
365 )
366 cachedir_path = os.path.join(
367 fileclient.__opts__["cachedir"], "files", fileserver_path
368 )
369 assert os.path.exists(cachedir_path)
370 with salt.utils.files.fopen(cachedir_path) as fp_:
371 content = fp_.read()
372 log.debug("cache_loc = %s", cachedir_path)
373 log.debug("content = %s", content)
374 assert saltenv in content
375
376
377def test_cache_file_with_alternate_cachedir_and_absolute_path(

Callers

nothing calls this directly

Calls 8

cache_masterMethod · 0.80
debugMethod · 0.80
_saltenvsFunction · 0.70
copyMethod · 0.45
updateMethod · 0.45
relpathMethod · 0.45
existsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected