mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Update old utils paths to new paths
This commit is contained in:
parent
893196d3e6
commit
4ad50bbdee
9 changed files with 32 additions and 29 deletions
|
@ -6,18 +6,18 @@
|
|||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import yaml
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
import salt.utils
|
||||
import salt.utils.files
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.unit import expectedFailure
|
||||
from tests.support import win_installer
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('CLOUD-TEST-')
|
||||
|
@ -50,7 +50,7 @@ class EC2Test(ShellCase):
|
|||
'''
|
||||
name = win_installer.latest_installer_name()
|
||||
path = os.path.join(FILES, name)
|
||||
with salt.utils.fopen(path, 'wb') as fp:
|
||||
with salt.utils.files.fopen(path, 'wb') as fp:
|
||||
win_installer.download_and_verify(fp, name)
|
||||
return name
|
||||
|
||||
|
@ -117,10 +117,10 @@ class EC2Test(ShellCase):
|
|||
|
||||
def override_profile_config(self, name, data):
|
||||
conf_path = os.path.join(self.get_config_dir(), 'cloud.profiles.d', 'ec2.conf')
|
||||
with salt.utils.fopen(conf_path, 'r') as fp:
|
||||
with salt.utils.files.fopen(conf_path, 'r') as fp:
|
||||
conf = yaml.safe_load(fp)
|
||||
conf[name].update(data)
|
||||
with salt.utils.fopen(conf_path, 'w') as fp:
|
||||
with salt.utils.files.fopen(conf_path, 'w') as fp:
|
||||
yaml.dump(conf, fp)
|
||||
|
||||
def copy_file(self, name):
|
||||
|
@ -131,8 +131,8 @@ class EC2Test(ShellCase):
|
|||
'''
|
||||
src = os.path.join(FILES, name)
|
||||
dst = os.path.join(self.get_config_dir(), name)
|
||||
with salt.utils.fopen(src, 'rb') as sfp:
|
||||
with salt.utils.fopen(dst, 'wb') as dfp:
|
||||
with salt.utils.files.fopen(src, 'rb') as sfp:
|
||||
with salt.utils.files.fopen(dst, 'wb') as dfp:
|
||||
dfp.write(sfp.read())
|
||||
return dst
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import os
|
|||
import shutil
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils
|
||||
import salt.utils.platform
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
|
@ -16,7 +16,7 @@ from tests.support.paths import TMP
|
|||
from tests.support.unit import skipIf
|
||||
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'minion is windows')
|
||||
@skipIf(salt.utils.platform.is_windows(), 'minion is windows')
|
||||
class ManTest(ModuleCase):
|
||||
rootdir = os.path.join(TMP, 'mantest')
|
||||
# Map filenames to search strings which should be in the manpage
|
||||
|
|
|
@ -8,7 +8,9 @@ import os
|
|||
import sys
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils
|
||||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
# Import Salt Tesing libs
|
||||
|
@ -35,7 +37,7 @@ def search(manpages, rootdir):
|
|||
# Using list because we will be modifying the set during iteration
|
||||
for manpage_fn in list(manpage_fns):
|
||||
if manpage_fn in files:
|
||||
manpage_path = salt.utils.path_join(root, manpage_fn)
|
||||
manpage_path = salt.utils.path.join(root, manpage_fn)
|
||||
manpage_paths[manpage_fn] = manpage_path
|
||||
manpage_fns.remove(manpage_fn)
|
||||
|
||||
|
@ -49,8 +51,8 @@ def search(manpages, rootdir):
|
|||
|
||||
failed = {}
|
||||
for manpage in sorted(manpages):
|
||||
with salt.utils.fopen(manpage_paths[manpage]) as fp_:
|
||||
contents = salt.utils.to_unicode(fp_.read())
|
||||
with salt.utils.files.fopen(manpage_paths[manpage]) as fp_:
|
||||
contents = salt.utils.stringutils.to_unicode(fp_.read())
|
||||
# Check for search string in contents
|
||||
for search_string in manpages[manpage]:
|
||||
if search_string not in contents:
|
||||
|
|
|
@ -648,7 +648,7 @@ class CPModuleTest(ModuleCase):
|
|||
@with_tempfile
|
||||
def test_get_file_from_env_in_url(self, tgt):
|
||||
self.run_function('cp.get_file', ['salt://cheese?saltenv=prod', tgt])
|
||||
with salt.utils.fopen(tgt, 'r') as cheese:
|
||||
with salt.utils.files.fopen(tgt, 'r') as cheese:
|
||||
data = cheese.read()
|
||||
self.assertIn('Gromit', data)
|
||||
self.assertIn('Comte', data)
|
||||
|
|
|
@ -15,6 +15,7 @@ from tests.support.unit import skipIf
|
|||
from salt.ext import six
|
||||
from salt.ext.six.moves import range
|
||||
import salt.utils.files
|
||||
import salt.utils.platform
|
||||
import salt.utils.stringutils
|
||||
|
||||
|
||||
|
@ -191,7 +192,7 @@ class GroupModuleTest(ModuleCase):
|
|||
self.assertEqual(group_info['gid'], self._gid)
|
||||
self.assertIn(self._user, str(group_info['members']))
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'gid test skipped on windows')
|
||||
@skipIf(salt.utils.platform.is_windows(), 'gid test skipped on windows')
|
||||
def test_chgid(self):
|
||||
'''
|
||||
Test the change gid function
|
||||
|
|
|
@ -59,7 +59,7 @@ class AuthTest(ShellCase):
|
|||
def setUp(self):
|
||||
for user in (self.userA, self.userB):
|
||||
try:
|
||||
if salt.utils.is_darwin() and user not in str(self.run_call('user.list_users')):
|
||||
if salt.utils.platform.is_darwin() and user not in str(self.run_call('user.list_users')):
|
||||
# workaround for https://github.com/saltstack/salt-jenkins/issues/504
|
||||
raise KeyError
|
||||
pwd.getpwnam(user)
|
||||
|
@ -68,7 +68,7 @@ class AuthTest(ShellCase):
|
|||
|
||||
# only put userB into the group for the group auth test
|
||||
try:
|
||||
if salt.utils.is_darwin() and self.group not in str(self.run_call('group.info {0}'.format(self.group))):
|
||||
if salt.utils.platform.is_darwin() and self.group not in str(self.run_call('group.info {0}'.format(self.group))):
|
||||
# workaround for https://github.com/saltstack/salt-jenkins/issues/504
|
||||
raise KeyError
|
||||
grp.getgrnam(self.group)
|
||||
|
|
|
@ -15,7 +15,7 @@ from tests.support.mock import (
|
|||
import salt.states.environ as envstate
|
||||
import salt.modules.environ as envmodule
|
||||
import salt.modules.reg
|
||||
import salt.utils
|
||||
import salt.utils.platform
|
||||
|
||||
|
||||
class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
||||
|
@ -54,7 +54,7 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
ret = envstate.setenv('test', 'other')
|
||||
self.assertEqual(ret['changes'], {})
|
||||
|
||||
@skipIf(not salt.utils.is_windows(), 'Windows only')
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Windows only')
|
||||
def test_setenv_permanent(self):
|
||||
'''
|
||||
test that we can set perminent environment variables (requires pywin32)
|
||||
|
@ -100,7 +100,7 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
ret = envstate.setenv('test', 'value', clear_all=True)
|
||||
self.assertEqual(ret['changes'], {'test': 'value', 'INITIAL': ''})
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'TEST': 'value', 'INITIAL': ''})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'test': 'value', 'INITIAL': ''})
|
||||
|
@ -112,7 +112,7 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
'''
|
||||
ret = envstate.setenv('test', 'value', false_unsets=True, clear_all=True)
|
||||
self.assertEqual(ret['changes'], {'test': 'value', 'INITIAL': None})
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'TEST': 'value'})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'test': 'value'})
|
||||
|
@ -128,7 +128,7 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
ret = envstate.setenv(
|
||||
'notimportant', {'test': False, 'foo': 'baz'}, false_unsets=True)
|
||||
self.assertEqual(ret['changes'], {'test': None, 'foo': 'baz'})
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'FOO': 'baz'})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'foo': 'baz'})
|
||||
|
@ -136,7 +136,7 @@ class TestEnvironState(TestCase, LoaderModuleMockMixin):
|
|||
with patch.dict(envstate.__salt__, {'reg.read_value': MagicMock()}):
|
||||
ret = envstate.setenv('notimportant', {'test': False, 'foo': 'bax'})
|
||||
self.assertEqual(ret['changes'], {'test': '', 'foo': 'bax'})
|
||||
if salt.utils.is_windows():
|
||||
if salt.utils.platform.is_windows():
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'FOO': 'bax', 'TEST': ''})
|
||||
else:
|
||||
self.assertEqual(envstate.os.environ, {'INITIAL': 'initial', 'foo': 'bax', 'test': ''})
|
||||
|
|
|
@ -1850,7 +1850,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
|||
|
||||
class TestFindKeepFiles(TestCase):
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'Do not run on Windows')
|
||||
@skipIf(salt.utils.platform.is_windows(), 'Do not run on Windows')
|
||||
def test__find_keep_files_unix(self):
|
||||
keep = filestate._find_keep_files(
|
||||
'/test/parent_folder',
|
||||
|
@ -1865,7 +1865,7 @@ class TestFindKeepFiles(TestCase):
|
|||
actual = sorted(list(keep))
|
||||
assert actual == expected, actual
|
||||
|
||||
@skipIf(not salt.utils.is_windows(), 'Only run on Windows')
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Only run on Windows')
|
||||
def test__find_keep_files_win32(self):
|
||||
keep = filestate._find_keep_files(
|
||||
'c:\\test\\parent_folder',
|
||||
|
|
|
@ -13,7 +13,7 @@ from tests.support.mock import patch, NO_MOCK, NO_MOCK_REASON
|
|||
|
||||
# Import Salt libs
|
||||
from salt import client
|
||||
import salt.utils
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import (
|
||||
EauthAuthenticationError, SaltInvocationError, SaltClientError, SaltReqTimeoutError
|
||||
)
|
||||
|
@ -70,7 +70,7 @@ class LocalClientTestCase(TestCase,
|
|||
kwarg=None, tgt_type='list',
|
||||
ret='')
|
||||
|
||||
@skipIf(salt.utils.is_windows(), 'Not supported on Windows')
|
||||
@skipIf(salt.utils.platform.is_windows(), 'Not supported on Windows')
|
||||
def test_pub(self):
|
||||
'''
|
||||
Tests that the client cleanly returns when the publisher is not running
|
||||
|
@ -93,7 +93,7 @@ class LocalClientTestCase(TestCase,
|
|||
self.client.pub,
|
||||
'non_existent_group', 'test.ping', tgt_type='nodegroup')
|
||||
|
||||
@skipIf(not salt.utils.is_windows(), 'Windows only test')
|
||||
@skipIf(not salt.utils.platform.is_windows(), 'Windows only test')
|
||||
def test_pub_win32(self):
|
||||
'''
|
||||
Tests that the client raises a timeout error when using ZeroMQ's TCP
|
||||
|
|
Loading…
Add table
Reference in a new issue