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 test_update_proccer_job(): with default_recipient_patch: with send_mail_patch as mock: job = update_proccer_job(session, ok_result) assert job assert update_proccer_job(session, ok_result) is job assert mock.call_count == 1, mock.call_count msg, recipient = mock.call_args[0] assert_eq(msg['Subject'], '[foo@snafu/bar] ok')
def test_update_proccer_job_new_error(): result = deepcopy(ok_result) result['result']['ok'] = False with default_recipient_patch: with send_mail_patch as mock: update_proccer_job(session, result) assert mock.call_count == 1, mock.call_count msg, recipient = mock.call_args[0] assert_eq(msg['Subject'], '[foo@snafu/bar] error')
def check_memlimit(memory_bytes): job_name = 'jobname' command = 'python ./src/proccer/t/test_agent/allocate_memory.py %s' job_desc = { 'command': command % memory_bytes } r = fork_and_wait(job_name, job_desc) assert_eq(r['result']['ok'], memory_bytes < default_memory_limit) assert r['rusage']['ru_maxrss'] < default_memory_limit