parent
8a348c9989
commit
28efbe7cf3
@ -1,387 +0,0 @@
|
|||||||
diff -ur a/salt/grains/core.py b/salt/grains/core.py
|
|
||||||
--- a/salt/grains/core.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/salt/grains/core.py 2015-07-10 16:24:29.097483841 -0500
|
|
||||||
@@ -1042,28 +1042,29 @@
|
|
||||||
with salt.utils.fopen('/proc/1/cmdline') as fhr:
|
|
||||||
init_cmdline = fhr.read().replace('\x00', ' ').split()
|
|
||||||
init_bin = salt.utils.which(init_cmdline[0])
|
|
||||||
- supported_inits = ('upstart', 'sysvinit', 'systemd')
|
|
||||||
- edge_len = max(len(x) for x in supported_inits) - 1
|
|
||||||
- buf_size = __opts__['file_buffer_size']
|
|
||||||
- try:
|
|
||||||
- with open(init_bin, 'rb') as fp_:
|
|
||||||
- buf = True
|
|
||||||
- edge = ''
|
|
||||||
- buf = fp_.read(buf_size).lower()
|
|
||||||
- while buf:
|
|
||||||
- buf = edge + buf
|
|
||||||
- for item in supported_inits:
|
|
||||||
- if item in buf:
|
|
||||||
- grains['init'] = item
|
|
||||||
- buf = ''
|
|
||||||
- break
|
|
||||||
- edge = buf[-edge_len:]
|
|
||||||
+ if init_bin:
|
|
||||||
+ supported_inits = ('upstart', 'sysvinit', 'systemd')
|
|
||||||
+ edge_len = max(len(x) for x in supported_inits) - 1
|
|
||||||
+ buf_size = __opts__['file_buffer_size']
|
|
||||||
+ try:
|
|
||||||
+ with open(init_bin, 'rb') as fp_:
|
|
||||||
+ buf = True
|
|
||||||
+ edge = ''
|
|
||||||
buf = fp_.read(buf_size).lower()
|
|
||||||
- except (IOError, OSError) as exc:
|
|
||||||
- log.error(
|
|
||||||
- 'Unable to read from init_bin ({0}): {1}'
|
|
||||||
- .format(init_bin, exc)
|
|
||||||
- )
|
|
||||||
+ while buf:
|
|
||||||
+ buf = edge + buf
|
|
||||||
+ for item in supported_inits:
|
|
||||||
+ if item in buf:
|
|
||||||
+ grains['init'] = item
|
|
||||||
+ buf = ''
|
|
||||||
+ break
|
|
||||||
+ edge = buf[-edge_len:]
|
|
||||||
+ buf = fp_.read(buf_size).lower()
|
|
||||||
+ except (IOError, OSError) as exc:
|
|
||||||
+ log.error(
|
|
||||||
+ 'Unable to read from init_bin ({0}): {1}'
|
|
||||||
+ .format(init_bin, exc)
|
|
||||||
+ )
|
|
||||||
|
|
||||||
# Add lsb grains on any distro with lsb-release
|
|
||||||
try:
|
|
||||||
diff -ur a/tests/unit/modules/artifactory_test.py b/tests/unit/modules/artifactory_test.py
|
|
||||||
--- a/tests/unit/modules/artifactory_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/artifactory_test.py 2015-07-10 12:11:33.942671443 -0500
|
|
||||||
@@ -1,9 +1,10 @@
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from salt.modules import artifactory
|
|
||||||
-from salttesting import TestCase
|
|
||||||
+from salttesting import TestCase, skipIf
|
|
||||||
from salttesting.mock import MagicMock
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Not failing in Jenkins')
|
|
||||||
class ArtifactoryTestCase(TestCase):
|
|
||||||
|
|
||||||
org_module_functions = {}
|
|
||||||
diff -ur a/tests/unit/modules/gpg_test.py b/tests/unit/modules/gpg_test.py
|
|
||||||
--- a/tests/unit/modules/gpg_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/gpg_test.py 2015-07-10 12:11:33.942671443 -0500
|
|
||||||
@@ -16,7 +16,11 @@
|
|
||||||
)
|
|
||||||
|
|
||||||
from salttesting.helpers import ensure_in_syspath
|
|
||||||
-from mock import mock_open
|
|
||||||
+try:
|
|
||||||
+ from mock import mock_open
|
|
||||||
+ HAS_MOCK_OPEN = True
|
|
||||||
+except ImportError:
|
|
||||||
+ HAS_MOCK_OPEN = False
|
|
||||||
|
|
||||||
ensure_in_syspath('../../')
|
|
||||||
|
|
||||||
@@ -315,6 +319,7 @@
|
|
||||||
|
|
||||||
# 'import_key' function tests: 1
|
|
||||||
|
|
||||||
+ @skipIf(not HAS_MOCK_OPEN, 'Missing mock_open')
|
|
||||||
def test_import_key(self):
|
|
||||||
'''
|
|
||||||
Tests if it import a key from text or file.
|
|
||||||
diff -ur a/tests/unit/modules/groupadd_test.py b/tests/unit/modules/groupadd_test.py
|
|
||||||
--- a/tests/unit/modules/groupadd_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/groupadd_test.py 2015-07-10 12:11:33.946004899 -0500
|
|
||||||
@@ -4,7 +4,7 @@
|
|
||||||
'''
|
|
||||||
|
|
||||||
# Import Salt Testing Libs
|
|
||||||
-from salttesting import TestCase
|
|
||||||
+from salttesting import TestCase, skipIf
|
|
||||||
from salttesting.mock import MagicMock, patch
|
|
||||||
#-------- from salt.exceptions import SaltInvocationError, CommandExecutionError
|
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@
|
|
||||||
import grp
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Not failing in Jenkins')
|
|
||||||
class GroupAddTestCase(TestCase):
|
|
||||||
'''
|
|
||||||
TestCase for salt.modules.groupadd
|
|
||||||
diff -ur a/tests/unit/modules/jboss7_test.py b/tests/unit/modules/jboss7_test.py
|
|
||||||
--- a/tests/unit/modules/jboss7_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/jboss7_test.py 2015-07-10 12:11:33.946004899 -0500
|
|
||||||
@@ -4,7 +4,7 @@
|
|
||||||
|
|
||||||
from salt.modules import jboss7
|
|
||||||
|
|
||||||
-from salttesting import TestCase
|
|
||||||
+from salttesting import TestCase, skipIf
|
|
||||||
from salttesting.mock import MagicMock
|
|
||||||
|
|
||||||
try:
|
|
||||||
@@ -15,6 +15,7 @@
|
|
||||||
__builtin__.__salt__ = {}
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Not failing in Jenkins')
|
|
||||||
class JBoss7TestCase(TestCase):
|
|
||||||
jboss_config = {}
|
|
||||||
org_run_operation = None
|
|
||||||
diff -ur a/tests/unit/modules/rh_ip_test.py b/tests/unit/modules/rh_ip_test.py
|
|
||||||
--- a/tests/unit/modules/rh_ip_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/rh_ip_test.py 2015-07-10 12:11:33.946004899 -0500
|
|
||||||
@@ -32,6 +32,7 @@
|
|
||||||
'''
|
|
||||||
Test cases for salt.modules.rh_ip
|
|
||||||
'''
|
|
||||||
+ @skipIf(True, 'Not failing in Jenkins')
|
|
||||||
def test_build_bond(self):
|
|
||||||
'''
|
|
||||||
Test to create a bond script in /etc/modprobe.d with the passed
|
|
||||||
diff -ur a/tests/unit/modules/tls_test.py b/tests/unit/modules/tls_test.py
|
|
||||||
--- a/tests/unit/modules/tls_test.py 2015-07-01 16:33:42.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/tls_test.py 2015-07-10 13:19:32.433749450 -0500
|
|
||||||
@@ -187,7 +187,6 @@
|
|
||||||
@patch('os.path.exists', MagicMock(return_value=True))
|
|
||||||
@patch('salt.modules.tls.maybe_fix_ssl_version',
|
|
||||||
MagicMock(return_value=True))
|
|
||||||
- @patch('salt.utils.fopen', mock_open(read_data=_TLS_TEST_DATA['ca_cert']))
|
|
||||||
def test_get_ca_text(self):
|
|
||||||
'''
|
|
||||||
Test get_ca text
|
|
||||||
@@ -195,9 +194,11 @@
|
|
||||||
ca_path = '/tmp/test_tls'
|
|
||||||
ca_name = 'test_ca'
|
|
||||||
mock_opt = MagicMock(return_value=ca_path)
|
|
||||||
- with patch.dict(tls.__salt__, {'config.option': mock_opt}):
|
|
||||||
- self.assertEqual(tls.get_ca(ca_name, as_text=True),
|
|
||||||
- _TLS_TEST_DATA['ca_cert'])
|
|
||||||
+ with patch('salt.utils.fopen',
|
|
||||||
+ mock_open(read_data=_TLS_TEST_DATA['ca_cert'])):
|
|
||||||
+ with patch.dict(tls.__salt__, {'config.option': mock_opt}):
|
|
||||||
+ self.assertEqual(tls.get_ca(ca_name, as_text=True),
|
|
||||||
+ _TLS_TEST_DATA['ca_cert'])
|
|
||||||
|
|
||||||
@patch('os.path.exists', MagicMock(return_value=True))
|
|
||||||
@patch('salt.modules.tls.maybe_fix_ssl_version',
|
|
||||||
@@ -219,7 +220,6 @@
|
|
||||||
@patch('os.path.exists', MagicMock(return_value=True))
|
|
||||||
@patch('salt.modules.tls.maybe_fix_ssl_version',
|
|
||||||
MagicMock(return_value=True))
|
|
||||||
- @patch('salt.utils.fopen', mock_open(read_data=_TLS_TEST_DATA['ca_cert']))
|
|
||||||
def test_cert_info(self):
|
|
||||||
'''
|
|
||||||
Test cert info
|
|
||||||
diff -ur a/tests/unit/modules/win_network_test.py b/tests/unit/modules/win_network_test.py
|
|
||||||
--- a/tests/unit/modules/win_network_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/modules/win_network_test.py 2015-07-10 12:11:33.946004899 -0500
|
|
||||||
@@ -172,7 +172,7 @@
|
|
||||||
['Ethernet'])
|
|
||||||
|
|
||||||
# 'interfaces' function tests: 1
|
|
||||||
-
|
|
||||||
+ @skipIf(not salt.utils.is_windows(), 'Not being run on Windows')
|
|
||||||
def test_interfaces(self):
|
|
||||||
'''
|
|
||||||
Test if it return information about all the interfaces on the minion
|
|
||||||
@@ -215,6 +215,7 @@
|
|
||||||
|
|
||||||
# 'ip_addrs' function tests: 1
|
|
||||||
|
|
||||||
+ @skipIf(not salt.utils.is_windows(), 'Not being run on Windows')
|
|
||||||
def test_ip_addrs(self):
|
|
||||||
'''
|
|
||||||
Test if it returns a list of IPv4 addresses assigned to the host.
|
|
||||||
@@ -223,6 +224,7 @@
|
|
||||||
|
|
||||||
# 'ip_addrs6' function tests: 1
|
|
||||||
|
|
||||||
+ @skipIf(not salt.utils.is_windows(), 'Not being run on Windows')
|
|
||||||
def test_ip_addrs6(self):
|
|
||||||
'''
|
|
||||||
Test if it returns a list of IPv6 addresses assigned to the host.
|
|
||||||
diff -ur a/tests/unit/pydsl_test.py b/tests/unit/pydsl_test.py
|
|
||||||
--- a/tests/unit/pydsl_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/pydsl_test.py 2015-07-10 12:11:33.946004899 -0500
|
|
||||||
@@ -10,7 +10,7 @@
|
|
||||||
from cStringIO import StringIO
|
|
||||||
|
|
||||||
# Import Salt Testing libs
|
|
||||||
-from salttesting import TestCase
|
|
||||||
+from salttesting import TestCase, skipIf
|
|
||||||
from salttesting.helpers import ensure_in_syspath
|
|
||||||
|
|
||||||
ensure_in_syspath('../')
|
|
||||||
@@ -299,6 +299,7 @@
|
|
||||||
finally:
|
|
||||||
shutil.rmtree(dirpath, ignore_errors=True)
|
|
||||||
|
|
||||||
+ @skipIf(True, 'Not failing in Jenkins')
|
|
||||||
def test_rendering_includes(self):
|
|
||||||
dirpath = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
|
|
||||||
if not os.path.isdir(dirpath):
|
|
||||||
diff -ur a/tests/unit/pyobjects_test.py b/tests/unit/pyobjects_test.py
|
|
||||||
--- a/tests/unit/pyobjects_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/pyobjects_test.py 2015-07-10 17:17:44.566196926 -0500
|
|
||||||
@@ -5,7 +5,7 @@
|
|
||||||
import tempfile
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
-from salttesting import TestCase
|
|
||||||
+from salttesting import TestCase, skipIf
|
|
||||||
from salttesting.helpers import ensure_in_syspath
|
|
||||||
|
|
||||||
ensure_in_syspath('../')
|
|
||||||
@@ -105,6 +105,7 @@
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Skipped until these are more stable')
|
|
||||||
class StateTests(TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
Registry.empty()
|
|
||||||
@@ -254,6 +255,7 @@
|
|
||||||
state.opts['renderer'])
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Skipped until these are more stable')
|
|
||||||
class RendererTests(RendererMixin, StateTests):
|
|
||||||
def test_basic(self):
|
|
||||||
ret = self.render(basic_template)
|
|
||||||
@@ -346,6 +348,7 @@
|
|
||||||
]))
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Skipped until these are more stable')
|
|
||||||
class MapTests(RendererMixin, TestCase):
|
|
||||||
def test_map(self):
|
|
||||||
def samba_with_grains(grains):
|
|
||||||
@@ -374,6 +377,7 @@
|
|
||||||
assert_ret(ret, 'samba', 'samba', 'smb')
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Skipped until these are more stable')
|
|
||||||
class SaltObjectTests(TestCase):
|
|
||||||
def test_salt_object(self):
|
|
||||||
def attr_fail():
|
|
||||||
diff -ur a/tests/unit/states/archive_test.py b/tests/unit/states/archive_test.py
|
|
||||||
--- a/tests/unit/states/archive_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/states/archive_test.py 2015-07-10 12:11:33.946004899 -0500
|
|
||||||
@@ -78,9 +78,7 @@
|
|
||||||
running_as = 'root'
|
|
||||||
filename = os.path.join(
|
|
||||||
tmp_dir,
|
|
||||||
- 'files/test/_tmp{0}_test_archive_.tar'.format(
|
|
||||||
- '' if running_as == 'root' else '_{0}'.format(running_as)
|
|
||||||
- )
|
|
||||||
+ 'files/test/_tmp_test_archive_.tar'
|
|
||||||
)
|
|
||||||
for test_opts, ret_opts in zip(test_tar_opts, ret_tar_opts):
|
|
||||||
ret = archive.extracted(tmp_dir,
|
|
||||||
diff -ur a/tests/unit/states/file_test.py b/tests/unit/states/file_test.py
|
|
||||||
--- a/tests/unit/states/file_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/states/file_test.py 2015-07-10 12:11:33.949338355 -0500
|
|
||||||
@@ -252,81 +252,6 @@
|
|
||||||
(name, target, user=user,
|
|
||||||
group=group), ret)
|
|
||||||
|
|
||||||
- # 'absent' function tests: 1
|
|
||||||
- @patch.object(os.path, 'islink', MagicMock(return_value=False))
|
|
||||||
- def test_absent(self):
|
|
||||||
- '''
|
|
||||||
- Test to make sure that the named file or directory is absent.
|
|
||||||
- '''
|
|
||||||
- name = '/fake/file.conf'
|
|
||||||
-
|
|
||||||
- ret = {'name': name,
|
|
||||||
- 'result': False,
|
|
||||||
- 'comment': '',
|
|
||||||
- 'changes': {}}
|
|
||||||
-
|
|
||||||
- mock_t = MagicMock(return_value=True)
|
|
||||||
- mock_f = MagicMock(return_value=False)
|
|
||||||
- mock_file = MagicMock(side_effect=[True, CommandExecutionError])
|
|
||||||
- mock_tree = MagicMock(side_effect=[True, OSError])
|
|
||||||
-
|
|
||||||
- comt = ('Must provide name to file.absent')
|
|
||||||
- ret.update({'comment': comt, 'name': ''})
|
|
||||||
- self.assertDictEqual(filestate.absent(''), ret)
|
|
||||||
-
|
|
||||||
- with patch.object(os.path, 'isabs', mock_f):
|
|
||||||
- comt = ('Specified file {0} is not an absolute path'
|
|
||||||
- .format(name))
|
|
||||||
- ret.update({'comment': comt, 'name': name})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- with patch.object(os.path, 'isabs', mock_t):
|
|
||||||
- comt = ('Refusing to make "/" absent')
|
|
||||||
- ret.update({'comment': comt, 'name': '/'})
|
|
||||||
- self.assertDictEqual(filestate.absent('/'), ret)
|
|
||||||
-
|
|
||||||
- with patch.object(os.path, 'isfile', mock_t):
|
|
||||||
- with patch.dict(filestate.__opts__, {'test': True}):
|
|
||||||
- comt = ('File {0} is set for removal'.format(name))
|
|
||||||
- ret.update({'comment': comt, 'name': name, 'result': None})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- with patch.dict(filestate.__opts__, {'test': False}):
|
|
||||||
- with patch.dict(filestate.__salt__,
|
|
||||||
- {'file.remove': mock_file}):
|
|
||||||
- comt = ('Removed file {0}'.format(name))
|
|
||||||
- ret.update({'comment': comt, 'result': True,
|
|
||||||
- 'changes': {'removed': name}})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- comt = ('Removed file {0}'.format(name))
|
|
||||||
- ret.update({'comment': '', 'result': False, 'changes': {}})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- with patch.object(os.path, 'isfile', mock_f):
|
|
||||||
- with patch.object(os.path, 'isdir', mock_t):
|
|
||||||
- with patch.dict(filestate.__opts__, {'test': True}):
|
|
||||||
- comt = ('Directory {0} is set for removal'.format(name))
|
|
||||||
- ret.update({'comment': comt, 'result': None})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- with patch.dict(filestate.__opts__, {'test': False}):
|
|
||||||
- with patch.object(shutil, 'rmtree', mock_tree):
|
|
||||||
- comt = ('Removed directory {0}'.format(name))
|
|
||||||
- ret.update({'comment': comt, 'result': True,
|
|
||||||
- 'changes': {'removed': name}})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- comt = ('Failed to remove directory {0}'.format(name))
|
|
||||||
- ret.update({'comment': comt, 'result': False,
|
|
||||||
- 'changes': {}})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
-
|
|
||||||
- with patch.object(os.path, 'isdir', mock_f):
|
|
||||||
- with patch.dict(filestate.__opts__, {'test': True}):
|
|
||||||
- comt = ('File {0} is not present'.format(name))
|
|
||||||
- ret.update({'comment': comt, 'result': True})
|
|
||||||
- self.assertDictEqual(filestate.absent(name), ret)
|
|
||||||
|
|
||||||
# 'exists' function tests: 1
|
|
||||||
|
|
||||||
diff -ur a/tests/unit/states/jboss7_test.py b/tests/unit/states/jboss7_test.py
|
|
||||||
--- a/tests/unit/states/jboss7_test.py 2015-07-07 15:42:37.000000000 -0500
|
|
||||||
+++ b/tests/unit/states/jboss7_test.py 2015-07-10 12:11:33.949338355 -0500
|
|
||||||
@@ -1,5 +1,5 @@
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
-from salttesting import TestCase
|
|
||||||
+from salttesting import TestCase, skipIf
|
|
||||||
from salttesting.mock import MagicMock
|
|
||||||
from salt.states import jboss7
|
|
||||||
from salt.exceptions import CommandExecutionError
|
|
||||||
@@ -13,6 +13,7 @@
|
|
||||||
__builtin__.__salt__ = {}
|
|
||||||
|
|
||||||
|
|
||||||
+@skipIf(True, 'Not failing in Jenkins')
|
|
||||||
class JBoss7StateTestCase(TestCase):
|
|
||||||
|
|
||||||
org_module_functions = {}
|
|
@ -0,0 +1,245 @@
|
|||||||
|
diff --git a/tests/unit/modules/artifactory_test.py b/tests/unit/modules/artifactory_test.py
|
||||||
|
index 33774e3..faecc58 100644
|
||||||
|
--- a/tests/unit/modules/artifactory_test.py
|
||||||
|
+++ b/tests/unit/modules/artifactory_test.py
|
||||||
|
@@ -1,9 +1,10 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from salt.modules import artifactory
|
||||||
|
-from salttesting import TestCase
|
||||||
|
-from salttesting.mock import MagicMock
|
||||||
|
+from salttesting import TestCase, skipIf
|
||||||
|
+from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON
|
||||||
|
|
||||||
|
|
||||||
|
+@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||||
|
class ArtifactoryTestCase(TestCase):
|
||||||
|
|
||||||
|
org_module_functions = {}
|
||||||
|
diff --git a/tests/unit/modules/gpg_test.py b/tests/unit/modules/gpg_test.py
|
||||||
|
index 8bc6065..111dbe9 100644
|
||||||
|
--- a/tests/unit/modules/gpg_test.py
|
||||||
|
+++ b/tests/unit/modules/gpg_test.py
|
||||||
|
@@ -10,13 +10,13 @@ from __future__ import absolute_import
|
||||||
|
from salttesting import TestCase, skipIf
|
||||||
|
from salttesting.mock import (
|
||||||
|
MagicMock,
|
||||||
|
+ mock_open,
|
||||||
|
patch,
|
||||||
|
NO_MOCK,
|
||||||
|
NO_MOCK_REASON
|
||||||
|
)
|
||||||
|
|
||||||
|
from salttesting.helpers import ensure_in_syspath
|
||||||
|
-from mock import mock_open
|
||||||
|
|
||||||
|
ensure_in_syspath('../../')
|
||||||
|
|
||||||
|
diff --git a/tests/unit/modules/groupadd_test.py b/tests/unit/modules/groupadd_test.py
|
||||||
|
index 7b7254e..04b0fdc 100644
|
||||||
|
--- a/tests/unit/modules/groupadd_test.py
|
||||||
|
+++ b/tests/unit/modules/groupadd_test.py
|
||||||
|
@@ -4,8 +4,8 @@
|
||||||
|
'''
|
||||||
|
|
||||||
|
# Import Salt Testing Libs
|
||||||
|
-from salttesting import TestCase
|
||||||
|
-from salttesting.mock import MagicMock, patch
|
||||||
|
+from salttesting import TestCase, skipIf
|
||||||
|
+from salttesting.mock import MagicMock, patch, NO_MOCK, NO_MOCK_REASON
|
||||||
|
#-------- from salt.exceptions import SaltInvocationError, CommandExecutionError
|
||||||
|
|
||||||
|
# Import Salt Libs
|
||||||
|
@@ -15,6 +15,7 @@ from salt.modules import groupadd
|
||||||
|
import grp
|
||||||
|
|
||||||
|
|
||||||
|
+@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||||
|
class GroupAddTestCase(TestCase):
|
||||||
|
'''
|
||||||
|
TestCase for salt.modules.groupadd
|
||||||
|
diff --git a/tests/unit/modules/jboss7_test.py b/tests/unit/modules/jboss7_test.py
|
||||||
|
index ec83a8b..670a515 100644
|
||||||
|
--- a/tests/unit/modules/jboss7_test.py
|
||||||
|
+++ b/tests/unit/modules/jboss7_test.py
|
||||||
|
@@ -4,8 +4,8 @@ from salt.utils.odict import OrderedDict
|
||||||
|
|
||||||
|
from salt.modules import jboss7
|
||||||
|
|
||||||
|
-from salttesting import TestCase
|
||||||
|
-from salttesting.mock import MagicMock
|
||||||
|
+from salttesting import TestCase, skipIf
|
||||||
|
+from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON
|
||||||
|
|
||||||
|
try:
|
||||||
|
# will pass if executed along with other tests
|
||||||
|
@@ -15,6 +15,7 @@ except NameError:
|
||||||
|
__builtin__.__salt__ = {}
|
||||||
|
|
||||||
|
|
||||||
|
+@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||||
|
class JBoss7TestCase(TestCase):
|
||||||
|
jboss_config = {}
|
||||||
|
org_run_operation = None
|
||||||
|
diff --git a/tests/unit/pydsl_test.py b/tests/unit/pydsl_test.py
|
||||||
|
index a1dbda6..9b1beed 100644
|
||||||
|
--- a/tests/unit/pydsl_test.py
|
||||||
|
+++ b/tests/unit/pydsl_test.py
|
||||||
|
@@ -10,7 +10,7 @@ import copy
|
||||||
|
from cStringIO import StringIO
|
||||||
|
|
||||||
|
# Import Salt Testing libs
|
||||||
|
-from salttesting import TestCase
|
||||||
|
+from salttesting import TestCase, skipIf
|
||||||
|
from salttesting.helpers import ensure_in_syspath
|
||||||
|
|
||||||
|
ensure_in_syspath('../')
|
||||||
|
@@ -299,6 +299,7 @@ class PyDSLRendererTestCase(TestCase):
|
||||||
|
finally:
|
||||||
|
shutil.rmtree(dirpath, ignore_errors=True)
|
||||||
|
|
||||||
|
+ @skipIf(True, 'Not failing in Jenkins')
|
||||||
|
def test_rendering_includes(self):
|
||||||
|
dirpath = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
|
||||||
|
if not os.path.isdir(dirpath):
|
||||||
|
diff --git a/tests/unit/states/file_test.py b/tests/unit/states/file_test.py
|
||||||
|
index f1876bd..4db6a2f 100644
|
||||||
|
--- a/tests/unit/states/file_test.py
|
||||||
|
+++ b/tests/unit/states/file_test.py
|
||||||
|
@@ -253,7 +253,6 @@ class FileTestCase(TestCase):
|
||||||
|
group=group), ret)
|
||||||
|
|
||||||
|
# 'absent' function tests: 1
|
||||||
|
- @patch.object(os.path, 'islink', MagicMock(return_value=False))
|
||||||
|
def test_absent(self):
|
||||||
|
'''
|
||||||
|
Test to make sure that the named file or directory is absent.
|
||||||
|
@@ -272,61 +271,69 @@ class FileTestCase(TestCase):
|
||||||
|
|
||||||
|
comt = ('Must provide name to file.absent')
|
||||||
|
ret.update({'comment': comt, 'name': ''})
|
||||||
|
- self.assertDictEqual(filestate.absent(''), ret)
|
||||||
|
|
||||||
|
- with patch.object(os.path, 'isabs', mock_f):
|
||||||
|
- comt = ('Specified file {0} is not an absolute path'
|
||||||
|
- .format(name))
|
||||||
|
- ret.update({'comment': comt, 'name': name})
|
||||||
|
- self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
+ with patch.object(os.path, 'islink', MagicMock(return_value=False)):
|
||||||
|
+ self.assertDictEqual(filestate.absent(''), ret)
|
||||||
|
|
||||||
|
- with patch.object(os.path, 'isabs', mock_t):
|
||||||
|
- comt = ('Refusing to make "/" absent')
|
||||||
|
- ret.update({'comment': comt, 'name': '/'})
|
||||||
|
- self.assertDictEqual(filestate.absent('/'), ret)
|
||||||
|
-
|
||||||
|
- with patch.object(os.path, 'isfile', mock_t):
|
||||||
|
- with patch.dict(filestate.__opts__, {'test': True}):
|
||||||
|
- comt = ('File {0} is set for removal'.format(name))
|
||||||
|
- ret.update({'comment': comt, 'name': name, 'result': None})
|
||||||
|
+ with patch.object(os.path, 'isabs', mock_f):
|
||||||
|
+ comt = ('Specified file {0} is not an absolute path'
|
||||||
|
+ .format(name))
|
||||||
|
+ ret.update({'comment': comt, 'name': name})
|
||||||
|
self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
|
||||||
|
- with patch.dict(filestate.__opts__, {'test': False}):
|
||||||
|
- with patch.dict(filestate.__salt__,
|
||||||
|
- {'file.remove': mock_file}):
|
||||||
|
- comt = ('Removed file {0}'.format(name))
|
||||||
|
- ret.update({'comment': comt, 'result': True,
|
||||||
|
- 'changes': {'removed': name}})
|
||||||
|
- self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
-
|
||||||
|
- comt = ('Removed file {0}'.format(name))
|
||||||
|
- ret.update({'comment': '', 'result': False, 'changes': {}})
|
||||||
|
- self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
+ with patch.object(os.path, 'isabs', mock_t):
|
||||||
|
+ comt = ('Refusing to make "/" absent')
|
||||||
|
+ ret.update({'comment': comt, 'name': '/'})
|
||||||
|
+ self.assertDictEqual(filestate.absent('/'), ret)
|
||||||
|
|
||||||
|
- with patch.object(os.path, 'isfile', mock_f):
|
||||||
|
- with patch.object(os.path, 'isdir', mock_t):
|
||||||
|
+ with patch.object(os.path, 'isfile', mock_t):
|
||||||
|
with patch.dict(filestate.__opts__, {'test': True}):
|
||||||
|
- comt = ('Directory {0} is set for removal'.format(name))
|
||||||
|
- ret.update({'comment': comt, 'result': None})
|
||||||
|
+ comt = ('File {0} is set for removal'.format(name))
|
||||||
|
+ ret.update({'comment': comt,
|
||||||
|
+ 'name': name,
|
||||||
|
+ 'result': None})
|
||||||
|
self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
|
||||||
|
with patch.dict(filestate.__opts__, {'test': False}):
|
||||||
|
- with patch.object(shutil, 'rmtree', mock_tree):
|
||||||
|
- comt = ('Removed directory {0}'.format(name))
|
||||||
|
+ with patch.dict(filestate.__salt__,
|
||||||
|
+ {'file.remove': mock_file}):
|
||||||
|
+ comt = ('Removed file {0}'.format(name))
|
||||||
|
ret.update({'comment': comt, 'result': True,
|
||||||
|
'changes': {'removed': name}})
|
||||||
|
self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
|
||||||
|
- comt = ('Failed to remove directory {0}'.format(name))
|
||||||
|
- ret.update({'comment': comt, 'result': False,
|
||||||
|
+ comt = ('Removed file {0}'.format(name))
|
||||||
|
+ ret.update({'comment': '',
|
||||||
|
+ 'result': False,
|
||||||
|
'changes': {}})
|
||||||
|
self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
|
||||||
|
- with patch.object(os.path, 'isdir', mock_f):
|
||||||
|
- with patch.dict(filestate.__opts__, {'test': True}):
|
||||||
|
- comt = ('File {0} is not present'.format(name))
|
||||||
|
- ret.update({'comment': comt, 'result': True})
|
||||||
|
- self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
+ with patch.object(os.path, 'isfile', mock_f):
|
||||||
|
+ with patch.object(os.path, 'isdir', mock_t):
|
||||||
|
+ with patch.dict(filestate.__opts__, {'test': True}):
|
||||||
|
+ comt = \
|
||||||
|
+ 'Directory {0} is set for removal'.format(name)
|
||||||
|
+ ret.update({'comment': comt, 'result': None})
|
||||||
|
+ self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
+
|
||||||
|
+ with patch.dict(filestate.__opts__, {'test': False}):
|
||||||
|
+ with patch.object(shutil, 'rmtree', mock_tree):
|
||||||
|
+ comt = ('Removed directory {0}'.format(name))
|
||||||
|
+ ret.update({'comment': comt, 'result': True,
|
||||||
|
+ 'changes': {'removed': name}})
|
||||||
|
+ self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
+
|
||||||
|
+ comt = \
|
||||||
|
+ 'Failed to remove directory {0}'.format(name)
|
||||||
|
+ ret.update({'comment': comt, 'result': False,
|
||||||
|
+ 'changes': {}})
|
||||||
|
+ self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
+
|
||||||
|
+ with patch.object(os.path, 'isdir', mock_f):
|
||||||
|
+ with patch.dict(filestate.__opts__, {'test': True}):
|
||||||
|
+ comt = ('File {0} is not present'.format(name))
|
||||||
|
+ ret.update({'comment': comt, 'result': True})
|
||||||
|
+ self.assertDictEqual(filestate.absent(name), ret)
|
||||||
|
|
||||||
|
# 'exists' function tests: 1
|
||||||
|
|
||||||
|
diff --git a/tests/unit/states/jboss7_test.py b/tests/unit/states/jboss7_test.py
|
||||||
|
index c1cda69..704f3c4 100644
|
||||||
|
--- a/tests/unit/states/jboss7_test.py
|
||||||
|
+++ b/tests/unit/states/jboss7_test.py
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
-from salttesting import TestCase
|
||||||
|
-from salttesting.mock import MagicMock
|
||||||
|
+from salttesting import TestCase, skipIf
|
||||||
|
+from salttesting.mock import MagicMock, NO_MOCK, NO_MOCK_REASON
|
||||||
|
from salt.states import jboss7
|
||||||
|
from salt.exceptions import CommandExecutionError
|
||||||
|
import __builtin__
|
||||||
|
@@ -13,6 +13,7 @@ except NameError:
|
||||||
|
__builtin__.__salt__ = {}
|
||||||
|
|
||||||
|
|
||||||
|
+@skipIf(NO_MOCK, NO_MOCK_REASON)
|
||||||
|
class JBoss7StateTestCase(TestCase):
|
||||||
|
|
||||||
|
org_module_functions = {}
|
Loading…
Reference in new issue