def test_report(): with patch('requests.post') as mock: report({}) assert mock.called args, kwargs = mock.call_args assert_eq(args, ('http://proccer-test/api/1.0/report',)) assert_eq(kwargs['data'], '{}')
def run_processes(): opts, args = run_processes_opts.parse_args() log = configure_logging(opts) from proccer import agent conf = agent.load_configuration(opts.configuration) for name in args: try: log.debug('[%s] starting', name) result = agent.run_process(conf, name) if result: agent.log_for(result) agent.report(result) agent.raise_for(result) log.debug('[%s] done', name) except agent.ProcessError, e: log.error('[%s] %s', name, e.args[0]) sys.exit(1)
def test_report_no_api(): with patch('proccer.agent.API_URL', ''): with patch('requests.post') as mock: report({}) assert not mock.called