def test_message_for_status_fail(mock_chronos_job_config): actual = check_chronos_jobs.message_for_status( status=pysensu_yelp.Status.CRITICAL, chronos_job_config=mock_chronos_job_config, ) assert "Last run of job myservice.myinstance failed.\n" in actual # Assert that there are helpful action items in the output assert "paasta logs -s myservice -i myinstance -c mycluster\n" in actual assert "paasta status -s myservice -i myinstance -c mycluster -vv\n" in actual assert "paasta rerun -s myservice -i myinstance -c mycluster -d {datetime}\n" in actual
def test_message_for_status_fail(): actual = check_chronos_jobs.message_for_status( status=pysensu_yelp.Status.CRITICAL, service='myservice', instance='myinstance', cluster='mycluster', ) assert "Last run of job myservice.myinstance failed.\n" in actual # Assert that there are helpful action items in the output assert "paasta logs -s myservice -i myinstance -c mycluster\n" in actual assert "paasta status -s myservice -i myinstance -c mycluster -vv\n" in actual assert "paasta rerun -s myservice -i myinstance -c mycluster -d {datetime}\n" in actual
def test_message_for_status_fail(): expected_output = ( "Last run of job myservice.myinstance failed.\n" "You can view the logs for the job with:\n" "paasta logs -s myservice -i myinstance -c mycluster .\n" "If your job didn't manage to start up, you can view the stdout and stderr of your job using:\n" "paasta status -s myservice -i myinstance -c mycluster -vv .\n" "If you need to rerun your job for the datetime it was started, you can do so with:\n" "paasta rerun -s myservice -i myinstance -c mycluster -d {datetime} .\n" "See the docs on paasta rerun here:\n" "https://paasta.readthedocs.io/en/latest/workflow.html#re-running-failed-jobs for more details." ) assert check_chronos_jobs.message_for_status( status=pysensu_yelp.Status.CRITICAL, service='myservice', instance='myinstance', cluster='mycluster', ) == expected_output
def test_message_for_status_unknown(): assert check_chronos_jobs.message_for_status(pysensu_yelp.Status.UNKNOWN, 'service', 'instance', 'full_job_id') == \ 'Last run of job service%sinstance Unknown' % utils.SPACER
def test_message_for_status_success(): assert check_chronos_jobs.message_for_status(pysensu_yelp.Status.OK, 'service', 'instance', 'full_job_id') == \ 'Last run of job service%sinstance Succeded' % utils.SPACER
def test_message_for_status_fail(): assert check_chronos_jobs.message_for_status( pysensu_yelp.Status.CRITICAL, 'service', 'instance', 'full_job_id') == \ 'Last run of job service%sinstance Failed - job id full_job_id' % utils.SPACER
def test_message_for_status_unknown(mock_chronos_job_config): assert check_chronos_jobs.message_for_status( pysensu_yelp.Status.UNKNOWN, mock_chronos_job_config, ) == 'Last run of job myservice%smyinstance Unknown' % utils.SPACER
def test_message_for_status_success(mock_chronos_job_config): assert check_chronos_jobs.message_for_status( pysensu_yelp.Status.OK, mock_chronos_job_config, ) == 'Last run of job myservice%smyinstance Succeeded' % utils.SPACER