mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
states.test.configurable_test_state: refactor change_data
Also adjust continued string indentation.
This commit is contained in:
parent
f06ff1af1f
commit
c2d0679c4b
1 changed files with 10 additions and 14 deletions
|
@ -201,33 +201,29 @@ def configurable_test_state(name, changes=True, result=True, comment=''):
|
|||
'result': False,
|
||||
'comment': comment
|
||||
}
|
||||
change_data = {
|
||||
'testing': {
|
||||
'old': 'Unchanged',
|
||||
'new': 'Something pretended to change'
|
||||
}
|
||||
}
|
||||
|
||||
if changes == 'Random':
|
||||
if random.choice([True, False]):
|
||||
# Following the docs as written here
|
||||
# http://docs.saltstack.com/ref/states/writing.html#return-data
|
||||
ret['changes'] = {
|
||||
'testing': {
|
||||
'old': 'Unchanged',
|
||||
'new': 'Something pretended to change'
|
||||
}
|
||||
}
|
||||
ret['changes'] = change_data
|
||||
elif changes is True:
|
||||
# If changes is True we place our dummy change dictionary into it.
|
||||
# Following the docs as written here
|
||||
# http://docs.saltstack.com/ref/states/writing.html#return-data
|
||||
ret['changes'] = {
|
||||
'testing': {
|
||||
'old': 'Unchanged',
|
||||
'new': 'Something pretended to change'
|
||||
}
|
||||
}
|
||||
ret['changes'] = change_data
|
||||
elif changes is False:
|
||||
ret['changes'] = {}
|
||||
else:
|
||||
err = ('You have specified the state option \'Changes\' with'
|
||||
' invalid arguments. It must be either '
|
||||
' \'True\', \'False\', or \'Random\'')
|
||||
' invalid arguments. It must be either '
|
||||
' \'True\', \'False\', or \'Random\'')
|
||||
raise SaltInvocationError(err)
|
||||
|
||||
if result == 'Random':
|
||||
|
|
Loading…
Add table
Reference in a new issue