mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Fix fileserver roots tests
This commit is contained in:
parent
1700a10ebe
commit
d79f1a1961
@ -57,6 +57,12 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
||||
cls.test_symlink_list_file_roots = {'base': [root_dir]}
|
||||
else:
|
||||
cls.test_symlink_list_file_roots = None
|
||||
cls.tmp_dir = tempfile.mkdtemp(dir=TMP)
|
||||
full_path_to_file = os.path.join(FILES, 'file', 'base', 'testfile')
|
||||
with salt.utils.fopen(full_path_to_file, 'rb') as s_fp:
|
||||
with salt.utils.fopen(os.path.join(cls.tmp_dir, 'testfile'), 'wb') as d_fp:
|
||||
for line in s_fp:
|
||||
d_fp.write(line.rstrip(b'\n').rstrip(b'\r') + os.linesep)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@ -68,6 +74,7 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
||||
salt.utils.rm_rf(cls.test_symlink_list_file_roots['base'][0])
|
||||
except OSError:
|
||||
pass
|
||||
salt.utils.rm_rf(cls.tmp_dir)
|
||||
|
||||
def tearDown(self):
|
||||
del self.opts
|
||||
@ -86,10 +93,10 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
||||
def test_serve_file(self):
|
||||
with patch.dict(roots.__opts__, {'file_buffer_size': 262144}):
|
||||
load = {'saltenv': 'base',
|
||||
'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
'loc': 0
|
||||
}
|
||||
fnd = {'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
fnd = {'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
'rel': 'testfile'}
|
||||
ret = roots.serve_file(load, fnd)
|
||||
|
||||
@ -134,10 +141,10 @@ class RootsTest(TestCase, AdaptedConfigurationTestCaseMixin, LoaderModuleMockMix
|
||||
def test_file_hash(self):
|
||||
load = {
|
||||
'saltenv': 'base',
|
||||
'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
}
|
||||
fnd = {
|
||||
'path': os.path.join(FILES, 'file', 'base', 'testfile'),
|
||||
'path': os.path.join(self.tmp_dir, 'testfile'),
|
||||
'rel': 'testfile'
|
||||
}
|
||||
ret = roots.file_hash(load, fnd)
|
||||
|
Loading…
Reference in New Issue
Block a user