示例#1
0
 def test_json_events_logger(self):
     events_logger = logger.get_events_logger(json_output=True)
     events = [{'key': 'value1'}, {'key': 'value2'}]
     with utils.mock_stdout() as output:
         events_logger(events)
     self.assertEqual('{0}\n{1}\n'.format(json.dumps(events[0]),
                                          json.dumps(events[1])),
                      output.getvalue())
示例#2
0
 def run(level=None, message=None, error=None, user_cause=None,
         verbose_flag=''):
     params = {}
     if level is not None:
         params['level'] = level
     if message is not None:
         params['message'] = message
     if error is not None:
         params['error'] = error
     if user_cause is not None:
         params['user_cause'] = user_cause
     params_path = os.path.join(utils.get_cwd(), 'parameters.json')
     with open(params_path, 'w') as f:
         f.write(json.dumps(params))
     with test_utils.mock_stdout() as output:
         cli_runner.run_cli('cfy local execute -w logging_workflow '
                            '-p {0} {1}'.format(params_path,
                                                verbose_flag))
     return output.getvalue()