# coding: utf-8 from utils.test_config import * from utils.string_utils import * from helix_web_services_client.models import JobCommand api = api_as_jdoe() rand = random_string() job_command = JobCommand() job_command['Job'] = 'new' job_command['User'] = 'jdoe' job_command['Description'] = "test-job-%s" % rand job_command['Status'] = 'open' # print "job dict: %s" % job_command create_results = api.server_jobs_post('localhost', job_command) job_id = create_results.results[0]['job'] # print "job_id %s\n" % job_id all_jobs = api.server_jobs_get('localhost') assert any(b['Job'] == job_id for b in all_jobs), "did not find new job" saved_job = api.server_jobs_job_get('localhost', job_id) assert saved_job['Description'].strip() == job_command['Description'].strip() to_update = JobCommand() to_update['Description'] = "Update %s" % rand api.server_jobs_job_patch('localhost', job_id, to_update) updated = api.server_jobs_job_get('localhost', job_id) assert updated['Description'].strip() == to_update['Description'].strip(), "did not update description" api.server_jobs_job_delete('localhost', job_id) all_jobs2 = api.server_jobs_get('localhost') assert any(b['Job'] == job_id for b in all_jobs2) == False, "did not delete new job"