parent
0c45ef71ff
commit
2f0da3e62b
@ -1,322 +0,0 @@
|
||||
From cc437e7826eb2cc436844286f14b5eda87d333d0 Mon Sep 17 00:00:00 2001
|
||||
From: Pedro Algarvio <pedro@algarvio.me>
|
||||
Date: Wed, 29 May 2013 23:42:45 +0100
|
||||
Subject: [PATCH] Switched to a fixed and more complete `OrderedDict` recipe.
|
||||
Fixes #4912.
|
||||
|
||||
---
|
||||
salt/utils/odict.py | 272 ++++++++++++++++++++++++++++++++++++++++++++--------
|
||||
1 file changed, 230 insertions(+), 42 deletions(-)
|
||||
|
||||
diff --git a/salt/utils/odict.py b/salt/utils/odict.py
|
||||
index 9dd8959..ba2c8b3 100644
|
||||
--- a/salt/utils/odict.py
|
||||
+++ b/salt/utils/odict.py
|
||||
@@ -21,74 +21,262 @@
|
||||
try:
|
||||
from ordereddict import OrderedDict
|
||||
except ImportError:
|
||||
- from collections import MutableMapping
|
||||
+ ## {{{ http://code.activestate.com/recipes/576693/ (r9)
|
||||
+ # Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
|
||||
+ # Passes Python2.7's test suite and incorporates all the latest updates.
|
||||
|
||||
- class OrderedDict(dict, MutableMapping):
|
||||
- # This implementation is fully based on:
|
||||
- # http://code.activestate.com/recipes/576669/
|
||||
+ try:
|
||||
+ from thread import get_ident as _get_ident
|
||||
+ except ImportError:
|
||||
+ from dummy_thread import get_ident as _get_ident
|
||||
+
|
||||
+ try:
|
||||
+ from _abcoll import KeysView, ValuesView, ItemsView
|
||||
+ except ImportError:
|
||||
+ pass
|
||||
+
|
||||
+ class OrderedDict(dict):
|
||||
+ 'Dictionary that remembers insertion order'
|
||||
+ # An inherited dict maps keys to values.
|
||||
+ # The inherited dict provides __getitem__, __len__, __contains__, and get.
|
||||
+ # The remaining methods are order-aware.
|
||||
+ # Big-O running times for all methods are the same as for regular dictionaries.
|
||||
+
|
||||
+ # The internal self.__map dictionary maps keys to links in a doubly linked list.
|
||||
+ # The circular doubly linked list starts and ends with a sentinel element.
|
||||
+ # The sentinel element never gets deleted (this simplifies the algorithm).
|
||||
+ # Each link is stored as a list of length three: [PREV, NEXT, KEY].
|
||||
|
||||
- # Methods with direct access to underlying attributes
|
||||
def __init__(self, *args, **kwds):
|
||||
- super(OrderedDict, self).__init__()
|
||||
- if len(args) > 1:
|
||||
- raise TypeError(
|
||||
- 'expected at 1 argument, got %d', len(args)
|
||||
- )
|
||||
- if not hasattr(self, '_keys'):
|
||||
- self._keys = []
|
||||
- self.update(*args, **kwds)
|
||||
+ '''Initialize an ordered dictionary. Signature is the same as for
|
||||
+ regular dictionaries, but keyword arguments are not recommended
|
||||
+ because their insertion order is arbitrary.
|
||||
|
||||
- def clear(self):
|
||||
- del self._keys[:]
|
||||
- dict.clear(self)
|
||||
+ '''
|
||||
+ if len(args) > 1:
|
||||
+ raise TypeError('expected at most 1 arguments, got %d' % len(args))
|
||||
+ try:
|
||||
+ self.__root
|
||||
+ except AttributeError:
|
||||
+ self.__root = root = [] # sentinel node
|
||||
+ root[:] = [root, root, None]
|
||||
+ self.__map = {}
|
||||
+ self.__update(*args, **kwds)
|
||||
|
||||
- def __setitem__(self, key, value):
|
||||
+ def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
|
||||
+ 'od.__setitem__(i, y) <==> od[i]=y'
|
||||
+ # Setting a new item creates a new link which goes at the end of the linked
|
||||
+ # list, and the inherited dictionary is updated with the new key/value pair.
|
||||
if key not in self:
|
||||
- self._keys.append(key)
|
||||
- dict.__setitem__(self, key, value)
|
||||
+ root = self.__root
|
||||
+ last = root[0]
|
||||
+ last[1] = root[0] = self.__map[key] = [last, root, key]
|
||||
+ dict_setitem(self, key, value)
|
||||
|
||||
- def __delitem__(self, key):
|
||||
- dict.__delitem__(self, key)
|
||||
- self._keys.remove(key)
|
||||
+ def __delitem__(self, key, dict_delitem=dict.__delitem__):
|
||||
+ 'od.__delitem__(y) <==> del od[y]'
|
||||
+ # Deleting an existing item uses self.__map to find the link which is
|
||||
+ # then removed by updating the links in the predecessor and successor nodes.
|
||||
+ dict_delitem(self, key)
|
||||
+ link_prev, link_next, key = self.__map.pop(key)
|
||||
+ link_prev[1] = link_next
|
||||
+ link_next[0] = link_prev
|
||||
|
||||
def __iter__(self):
|
||||
- return iter(self._keys)
|
||||
+ 'od.__iter__() <==> iter(od)'
|
||||
+ root = self.__root
|
||||
+ curr = root[1]
|
||||
+ while curr is not root:
|
||||
+ yield curr[2]
|
||||
+ curr = curr[1]
|
||||
|
||||
def __reversed__(self):
|
||||
- return reversed(self._keys)
|
||||
+ 'od.__reversed__() <==> reversed(od)'
|
||||
+ root = self.__root
|
||||
+ curr = root[0]
|
||||
+ while curr is not root:
|
||||
+ yield curr[2]
|
||||
+ curr = curr[0]
|
||||
+
|
||||
+ def clear(self):
|
||||
+ 'od.clear() -> None. Remove all items from od.'
|
||||
+ try:
|
||||
+ for node in self.__map.itervalues():
|
||||
+ del node[:]
|
||||
+ root = self.__root
|
||||
+ root[:] = [root, root, None]
|
||||
+ self.__map.clear()
|
||||
+ except AttributeError:
|
||||
+ pass
|
||||
+ dict.clear(self)
|
||||
|
||||
- def popitem(self):
|
||||
+ def popitem(self, last=True):
|
||||
+ '''od.popitem() -> (k, v), return and remove a (key, value) pair.
|
||||
+ Pairs are returned in LIFO order if last is true or FIFO order if false.
|
||||
+
|
||||
+ '''
|
||||
if not self:
|
||||
- raise KeyError
|
||||
- key = self._keys.pop()
|
||||
+ raise KeyError('dictionary is empty')
|
||||
+ root = self.__root
|
||||
+ if last:
|
||||
+ link = root[0]
|
||||
+ link_prev = link[0]
|
||||
+ link_prev[1] = root
|
||||
+ root[0] = link_prev
|
||||
+ else:
|
||||
+ link = root[1]
|
||||
+ link_next = link[1]
|
||||
+ root[1] = link_next
|
||||
+ link_next[0] = root
|
||||
+ key = link[2]
|
||||
+ del self.__map[key]
|
||||
value = dict.pop(self, key)
|
||||
return key, value
|
||||
|
||||
- def __reduce__(self):
|
||||
- items = [[k, self[k]] for k in self]
|
||||
- inst_dict = vars(self).copy()
|
||||
- inst_dict.pop('_keys', None)
|
||||
- return (self.__class__, (items,), inst_dict)
|
||||
+ # -- the following methods do not depend on the internal structure --
|
||||
+
|
||||
+ def keys(self):
|
||||
+ 'od.keys() -> list of keys in od'
|
||||
+ return list(self)
|
||||
+
|
||||
+ def values(self):
|
||||
+ 'od.values() -> list of values in od'
|
||||
+ return [self[key] for key in self]
|
||||
+
|
||||
+ def items(self):
|
||||
+ 'od.items() -> list of (key, value) pairs in od'
|
||||
+ return [(key, self[key]) for key in self]
|
||||
+
|
||||
+ def iterkeys(self):
|
||||
+ 'od.iterkeys() -> an iterator over the keys in od'
|
||||
+ return iter(self)
|
||||
+
|
||||
+ def itervalues(self):
|
||||
+ 'od.itervalues -> an iterator over the values in od'
|
||||
+ for k in self:
|
||||
+ yield self[k]
|
||||
|
||||
- # Methods with indirect access via the above methods
|
||||
+ def iteritems(self):
|
||||
+ 'od.iteritems -> an iterator over the (key, value) items in od'
|
||||
+ for k in self:
|
||||
+ yield (k, self[k])
|
||||
|
||||
- setdefault = MutableMapping.setdefault
|
||||
- update = MutableMapping.update
|
||||
- pop = MutableMapping.pop
|
||||
- keys = MutableMapping.keys
|
||||
- values = MutableMapping.values
|
||||
- items = MutableMapping.items
|
||||
+ def update(*args, **kwds):
|
||||
+ '''od.update(E, **F) -> None. Update od from dict/iterable E and F.
|
||||
|
||||
- def __repr__(self):
|
||||
- pairs = ', '.join(map('%r: %r'.__mod__, self.items()))
|
||||
- return '%s({%s})' % (self.__class__.__name__, pairs)
|
||||
+ If E is a dict instance, does: for k in E: od[k] = E[k]
|
||||
+ If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
|
||||
+ Or if E is an iterable of items, does: for k, v in E: od[k] = v
|
||||
+ In either case, this is followed by: for k, v in F.items(): od[k] = v
|
||||
+
|
||||
+ '''
|
||||
+ if len(args) > 2:
|
||||
+ raise TypeError('update() takes at most 2 positional '
|
||||
+ 'arguments (%d given)' % (len(args),))
|
||||
+ elif not args:
|
||||
+ raise TypeError('update() takes at least 1 argument (0 given)')
|
||||
+ self = args[0]
|
||||
+ # Make progressively weaker assumptions about "other"
|
||||
+ other = ()
|
||||
+ if len(args) == 2:
|
||||
+ other = args[1]
|
||||
+ if isinstance(other, dict):
|
||||
+ for key in other:
|
||||
+ self[key] = other[key]
|
||||
+ elif hasattr(other, 'keys'):
|
||||
+ for key in other.keys():
|
||||
+ self[key] = other[key]
|
||||
+ else:
|
||||
+ for key, value in other:
|
||||
+ self[key] = value
|
||||
+ for key, value in kwds.items():
|
||||
+ self[key] = value
|
||||
+
|
||||
+ __update = update # let subclasses override update without breaking __init__
|
||||
+
|
||||
+ __marker = object()
|
||||
+
|
||||
+ def pop(self, key, default=__marker):
|
||||
+ '''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
||||
+ If key is not found, d is returned if given, otherwise KeyError is raised.
|
||||
+
|
||||
+ '''
|
||||
+ if key in self:
|
||||
+ result = self[key]
|
||||
+ del self[key]
|
||||
+ return result
|
||||
+ if default is self.__marker:
|
||||
+ raise KeyError(key)
|
||||
+ return default
|
||||
+
|
||||
+ def setdefault(self, key, default=None):
|
||||
+ 'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
|
||||
+ if key in self:
|
||||
+ return self[key]
|
||||
+ self[key] = default
|
||||
+ return default
|
||||
+
|
||||
+ def __repr__(self, _repr_running={}):
|
||||
+ 'od.__repr__() <==> repr(od)'
|
||||
+ call_key = id(self), _get_ident()
|
||||
+ if call_key in _repr_running:
|
||||
+ return '...'
|
||||
+ _repr_running[call_key] = 1
|
||||
+ try:
|
||||
+ if not self:
|
||||
+ return '%s()' % (self.__class__.__name__,)
|
||||
+ return '%s(%r)' % (self.__class__.__name__, self.items())
|
||||
+ finally:
|
||||
+ del _repr_running[call_key]
|
||||
+
|
||||
+ def __reduce__(self):
|
||||
+ 'Return state information for pickling'
|
||||
+ items = [[k, self[k]] for k in self]
|
||||
+ inst_dict = vars(self).copy()
|
||||
+ for k in vars(OrderedDict()):
|
||||
+ inst_dict.pop(k, None)
|
||||
+ if inst_dict:
|
||||
+ return (self.__class__, (items,), inst_dict)
|
||||
+ return self.__class__, (items,)
|
||||
|
||||
def copy(self):
|
||||
+ 'od.copy() -> a shallow copy of od'
|
||||
return self.__class__(self)
|
||||
|
||||
@classmethod
|
||||
def fromkeys(cls, iterable, value=None):
|
||||
+ '''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
|
||||
+ and values equal to v (which defaults to None).
|
||||
+
|
||||
+ '''
|
||||
d = cls()
|
||||
for key in iterable:
|
||||
d[key] = value
|
||||
return d
|
||||
+
|
||||
+ def __eq__(self, other):
|
||||
+ '''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
|
||||
+ while comparison to a regular mapping is order-insensitive.
|
||||
+
|
||||
+ '''
|
||||
+ if isinstance(other, OrderedDict):
|
||||
+ return len(self)==len(other) and self.items() == other.items()
|
||||
+ return dict.__eq__(self, other)
|
||||
+
|
||||
+ def __ne__(self, other):
|
||||
+ return not self == other
|
||||
+
|
||||
+ # -- the following methods are only used in Python 2.7 --
|
||||
+
|
||||
+ def viewkeys(self):
|
||||
+ "od.viewkeys() -> a set-like object providing a view on od's keys"
|
||||
+ return KeysView(self)
|
||||
+
|
||||
+ def viewvalues(self):
|
||||
+ "od.viewvalues() -> an object providing a view on od's values"
|
||||
+ return ValuesView(self)
|
||||
+
|
||||
+ def viewitems(self):
|
||||
+ "od.viewitems() -> a set-like object providing a view on od's items"
|
||||
+ return ItemsView(self)
|
||||
+ ## end of http://code.activestate.com/recipes/576693/ }}}
|
||||
--
|
||||
1.8.1.6
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,13 +0,0 @@
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 6feb5d0..6b08e12 100755
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -513,7 +513,7 @@ FREEZER_INCLUDES = [
|
||||
'email.mime.*',
|
||||
]
|
||||
|
||||
-if hasattr(zmq, 'pyzmq_version_info'):
|
||||
+if HAS_ZMQ and hasattr(zmq, 'pyzmq_version_info'):
|
||||
if HAS_ZMQ and zmq.pyzmq_version_info() >= (0, 14):
|
||||
# We're freezing, and when freezing ZMQ needs to be installed, so this
|
||||
# works fine
|
@ -1,39 +0,0 @@
|
||||
/var/log/salt/master {
|
||||
weekly
|
||||
missingok
|
||||
rotate 5
|
||||
compress
|
||||
notifempty
|
||||
}
|
||||
|
||||
/var/log/salt/minion {
|
||||
weekly
|
||||
missingok
|
||||
rotate 5
|
||||
compress
|
||||
notifempty
|
||||
}
|
||||
|
||||
/var/log/salt/key {
|
||||
weekly
|
||||
missingok
|
||||
rotate 5
|
||||
compress
|
||||
notifempty
|
||||
}
|
||||
|
||||
/var/log/salt/cloud {
|
||||
weekly
|
||||
missingok
|
||||
rotate 5
|
||||
compress
|
||||
notifempty
|
||||
}
|
||||
|
||||
/var/log/salt/ssh {
|
||||
weekly
|
||||
missingok
|
||||
rotate 5
|
||||
compress
|
||||
notifempty
|
||||
}
|
@ -1,346 +0,0 @@
|
||||
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/modules/win_network_test.py b/tests/unit/modules/win_network_test.py
|
||||
index 620c4f4..e5fda8c 100644
|
||||
--- a/tests/unit/modules/win_network_test.py
|
||||
+++ b/tests/unit/modules/win_network_test.py
|
||||
@@ -213,22 +213,6 @@ class WinNetworkTestCase(TestCase):
|
||||
MagicMock(return_value=True)):
|
||||
self.assertTrue(win_network.in_subnet('10.1.1.0/16'))
|
||||
|
||||
- # 'ip_addrs' function tests: 1
|
||||
-
|
||||
- def test_ip_addrs(self):
|
||||
- '''
|
||||
- Test if it returns a list of IPv4 addresses assigned to the host.
|
||||
- '''
|
||||
- self.assertTrue(win_network.ip_addrs())
|
||||
-
|
||||
- # 'ip_addrs6' function tests: 1
|
||||
-
|
||||
- def test_ip_addrs6(self):
|
||||
- '''
|
||||
- Test if it returns a list of IPv6 addresses assigned to the host.
|
||||
- '''
|
||||
- self.assertTrue(win_network.ip_addrs6())
|
||||
-
|
||||
|
||||
if __name__ == '__main__':
|
||||
from integration import run_tests
|
||||
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/pyobjects_test.py b/tests/unit/pyobjects_test.py
|
||||
index c70761e..ef2adf1 100644
|
||||
--- a/tests/unit/pyobjects_test.py
|
||||
+++ b/tests/unit/pyobjects_test.py
|
||||
@@ -5,7 +5,7 @@ import shutil
|
||||
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 @@ with Pkg.installed("pkg"):
|
||||
'''
|
||||
|
||||
|
||||
+@skipIf(True, 'Spurious failures')
|
||||
class StateTests(TestCase):
|
||||
def setUp(self):
|
||||
Registry.empty()
|
||||
@@ -196,6 +197,7 @@ class StateTests(TestCase):
|
||||
)
|
||||
|
||||
|
||||
+@skipIf(True, 'Spurious failures')
|
||||
class RendererMixin(object):
|
||||
'''
|
||||
This is a mixin that adds a ``.render()`` method to render a template
|
||||
@@ -254,6 +256,7 @@ class RendererMixin(object):
|
||||
state.opts['renderer'])
|
||||
|
||||
|
||||
+@skipIf(True, 'Spurious failures')
|
||||
class RendererTests(RendererMixin, StateTests):
|
||||
def test_basic(self):
|
||||
ret = self.render(basic_template)
|
||||
@@ -346,6 +349,7 @@ class RendererTests(RendererMixin, StateTests):
|
||||
]))
|
||||
|
||||
|
||||
+@skipIf(True, 'Spurious failures')
|
||||
class MapTests(RendererMixin, TestCase):
|
||||
def test_map(self):
|
||||
def samba_with_grains(grains):
|
||||
@@ -374,6 +378,7 @@ class MapTests(RendererMixin, TestCase):
|
||||
assert_ret(ret, 'samba', 'samba', 'smb')
|
||||
|
||||
|
||||
+@skipIf(True, 'Spurious failures')
|
||||
class SaltObjectTests(TestCase):
|
||||
def test_salt_object(self):
|
||||
def attr_fail():
|
||||
diff --git a/tests/unit/states/archive_test.py b/tests/unit/states/archive_test.py
|
||||
index 588ec1a..fe12be9 100644
|
||||
--- a/tests/unit/states/archive_test.py
|
||||
+++ b/tests/unit/states/archive_test.py
|
||||
@@ -72,15 +72,9 @@ class ArchiveTest(TestCase):
|
||||
'file.file_exists': mock_false,
|
||||
'file.makedirs': mock_true,
|
||||
'cmd.run_all': mock_run}):
|
||||
- if HAS_PWD:
|
||||
- running_as = pwd.getpwuid(os.getuid()).pw_name
|
||||
- else:
|
||||
- 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 --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 = {}
|
@ -1,10 +1,12 @@
|
||||
[Unit]
|
||||
Description=The Salt API
|
||||
After=syslog.target network.target
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Type=notify
|
||||
LimitNOFILE=8192
|
||||
ExecStart=/usr/bin/salt-api
|
||||
TimeoutStopSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -0,0 +1,23 @@
|
||||
/var/log/salt/master {
|
||||
weekly
|
||||
missingok
|
||||
rotate 7
|
||||
compress
|
||||
notifempty
|
||||
}
|
||||
|
||||
/var/log/salt/minion {
|
||||
weekly
|
||||
missingok
|
||||
rotate 7
|
||||
compress
|
||||
notifempty
|
||||
}
|
||||
|
||||
/var/log/salt/key {
|
||||
weekly
|
||||
missingok
|
||||
rotate 7
|
||||
compress
|
||||
notifempty
|
||||
}
|
Loading…
Reference in new issue