mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Add repack_state_returns to TestCase
This allows for a state return dict to be repacked so that the top level keys are the IDs, making it much easier to analyze and craft asserts against the results.
This commit is contained in:
parent
982e693ef6
commit
ceb3f4d91f
1 changed files with 13 additions and 0 deletions
|
@ -268,6 +268,19 @@ class TestCase(_TestCase):
|
|||
)
|
||||
# return _TestCase.assertNotAlmostEquals(self, *args, **kwargs)
|
||||
|
||||
def repack_state_returns(self, state_ret):
|
||||
'''
|
||||
Accepts a state return dict and returns it back with the top level key
|
||||
names rewritten such that the ID declaration is the key instead of the
|
||||
State's unique tag. For example: 'foo' instead of
|
||||
'file_|-foo_|-/etc/foo.conf|-managed'
|
||||
|
||||
This makes it easier to work with state returns when crafting asserts
|
||||
after running states.
|
||||
'''
|
||||
assert isinstance(state_ret, dict), state_ret
|
||||
return {x.split('_|-')[1]: y for x, y in six.iteritems(state_ret)}
|
||||
|
||||
def failUnlessEqual(self, *args, **kwargs):
|
||||
raise DeprecationWarning(
|
||||
'The {0}() function is deprecated. Please start using {1}() '
|
||||
|
|
Loading…
Add table
Reference in a new issue