Use BASE_FILES instead of redundant STATE_DIR

This commit is contained in:
Erik Johnson 2018-08-03 16:46:01 -05:00
parent 612ffb5fe8
commit 2dd1f31d23
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -22,7 +22,7 @@ log = logging.getLogger(__name__)
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.unit import skipIf
from tests.support.paths import FILES, TMP, TMP_STATE_TREE
from tests.support.paths import BASE_FILES, FILES, TMP, TMP_STATE_TREE
from tests.support.helpers import (
destructiveTest,
skip_if_not_root,
@ -61,7 +61,6 @@ IS_WINDOWS = salt.utils.platform.is_windows()
BINARY_FILE = b'GIF89a\x01\x00\x01\x00\x80\x00\x00\x05\x04\x04\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;'
STATE_DIR = os.path.join(FILES, 'file', 'base')
if IS_WINDOWS:
FILEPILLAR = 'C:\\Windows\\Temp\\filepillar-python'
FILEPILLARDEF = 'C:\\Windows\\Temp\\filepillar-defaultvalue'
@ -77,7 +76,7 @@ def _test_managed_file_mode_keep_helper(testcase, local=False):
DRY helper function to run the same test with a local or remote path
'''
name = os.path.join(TMP, 'scene33')
grail_fs_path = os.path.join(FILES, 'file', 'base', 'grail', 'scene33')
grail_fs_path = os.path.join(BASE_FILES, 'grail', 'scene33')
grail = 'salt://grail/scene33' if not local else grail_fs_path
# Get the current mode so that we can put the file back the way we
@ -248,9 +247,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
ret = self.run_state(
'file.managed', name=name, source='salt://grail/scene33'
)
src = os.path.join(
FILES, 'file', 'base', 'grail', 'scene33'
)
src = os.path.join(BASE_FILES, 'grail', 'scene33')
with salt.utils.files.fopen(src, 'r') as fp_:
master_data = fp_.read()
with salt.utils.files.fopen(name, 'r') as fp_:
@ -464,11 +461,11 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
funny_file = salt.utils.files.mkstemp(prefix='?f!le? n@=3&', suffix='.file type')
funny_file_name = os.path.split(funny_file)[1]
funny_url = 'salt://|' + funny_file_name
funny_url_path = os.path.join(STATE_DIR, funny_file_name)
funny_url_path = os.path.join(BASE_FILES, funny_file_name)
state_name = 'funny_file'
state_file_name = state_name + '.sls'
state_file = os.path.join(STATE_DIR, state_file_name)
state_file = os.path.join(BASE_FILES, state_file_name)
state_key = 'file_|-{0}_|-{0}_|-managed'.format(funny_file)
self.addCleanup(os.remove, state_file)
@ -495,7 +492,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
'''
state_name = 'file-FileTest-test_managed_contents'
state_filename = state_name + '.sls'
state_file = os.path.join(STATE_DIR, state_filename)
state_file = os.path.join(BASE_FILES, state_filename)
managed_files = {}
state_keys = {}
@ -589,7 +586,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
Make sure that we enforce the source_hash even with local files
'''
name = os.path.join(TMP, 'local_source_with_source_hash')
local_path = os.path.join(FILES, 'file', 'base', 'grail', 'scene33')
local_path = os.path.join(BASE_FILES, 'grail', 'scene33')
actual_hash = '567fd840bf1548edc35c48eb66cdd78bfdfcccff'
# Reverse the actual hash
bad_hash = actual_hash[::-1]
@ -645,7 +642,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
Make sure that we exit gracefully when a local source doesn't exist
'''
name = os.path.join(TMP, 'local_source_does_not_exist')
local_path = os.path.join(FILES, 'file', 'base', 'grail', 'scene99')
local_path = os.path.join(BASE_FILES, 'grail', 'scene99')
for proto in ('file://', ''):
source = proto + local_path
@ -671,7 +668,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
name = os.path.join(TMP, 'source_hash_indifferent_case')
state_name = 'file_|-{0}_|' \
'-{0}_|-managed'.format(name)
local_path = os.path.join(FILES, 'file', 'base', 'hello_world.txt')
local_path = os.path.join(BASE_FILES, 'hello_world.txt')
actual_hash = 'c98c24b677eff44860afea6f493bbaec5bb1c4cbb209c6fc2bbb47f66ff2ad31'
uppercase_hash = actual_hash.upper()
@ -921,7 +918,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
'''
state_name = 'file-FileTest-test_directory_clean_require_in'
state_filename = state_name + '.sls'
state_file = os.path.join(STATE_DIR, state_filename)
state_file = os.path.join(BASE_FILES, state_filename)
directory = tempfile.mkdtemp()
self.addCleanup(lambda: shutil.rmtree(directory))
@ -956,7 +953,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
'''
state_name = 'file-FileTest-test_directory_clean_require_in_with_id'
state_filename = state_name + '.sls'
state_file = os.path.join(STATE_DIR, state_filename)
state_file = os.path.join(BASE_FILES, state_filename)
directory = tempfile.mkdtemp()
self.addCleanup(lambda: shutil.rmtree(directory))
@ -992,7 +989,7 @@ class FileTest(ModuleCase, SaltReturnAssertsMixin):
'''
state_name = 'file-FileTest-test_directory_clean_require_in_with_id'
state_filename = state_name + '.sls'
state_file = os.path.join(STATE_DIR, state_filename)
state_file = os.path.join(BASE_FILES, state_filename)
directory = tempfile.mkdtemp()
self.addCleanup(lambda: shutil.rmtree(directory))