def configurable_test_state(name, changes=True, result=True, comment=''):
 ret = {'name': name, 'changes': {}, 'result': False, 'comment': comment}
 change_data = {'testing': {'old': 'Unchanged', 'new': 'Something pretended to change'}}
 if (changes == 'Random'):
  if random.choice([True, False]):
   ret['changes'] = change_data
 elif (changes is True):
  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'"
  raise SaltInvocationError(err)
 if (result == 'Random'):
  ret['result'] = random.choice([True, False])
 elif (result is True):
  ret['result'] = True
 elif (result is False):
  ret['result'] = False
 else:
  raise SaltInvocationError("You have specified the state option 'Result' with invalid arguments. It must be either 'True', 'False', or 'Random'")
 if __opts__['test']:
  ret['result'] = (True if (changes is False) else None)
  ret['comment'] = ('This is a test' if (not comment) else comment)
 return ret

def configurable_test_state ( name , changes = True , result = True , comment = '' ) : ret = { 'name' : name , 'changes' : { } , 'result' : False , 'comment' : comment } change_data = { 'testing' : { 'old' : 'Unchanged' , 'new' : 'Something pretended to change' } } if ( changes == 'Random' ) : if random . choice ( [ True , False ] ) : ret [ 'changes' ] = change_data elif ( changes is True ) : 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'" raise SaltInvocationError ( err ) if ( result == 'Random' ) : ret [ 'result' ] = random . choice ( [ True , False ] ) elif ( result is True ) : ret [ 'result' ] = True elif ( result is False ) : ret [ 'result' ] = False else : raise SaltInvocationError ( "You have specified the state option 'Result' with invalid arguments. It must be either 'True', 'False', or 'Random'" ) if __opts__ [ 'test' ] : ret [ 'result' ] = ( True if ( changes is False ) else None ) ret [ 'comment' ] = ( 'This is a test' if ( not comment ) else comment ) return ret
a configurable test state which determines its output based on the inputs .