From fdd85ad5b0c4d529bdb93fb06de34dc76b84319a Mon Sep 17 00:00:00 2001 From: Salim Fadhley Date: Sat, 2 Aug 2014 16:57:38 +0100 Subject: [PATCH] Fix way more bugs. --- jenkinsapi/job.py | 9 ++++----- jenkinsapi_tests/systests/test_executors.py | 6 +++--- jenkinsapi_tests/systests/test_jenkins_matrix.py | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index c298e70..8724216 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -166,12 +166,8 @@ class Job(JenkinsBase, MutableJenkinsThing): file_params) return json.dumps(to_json_structure) - def invoke(self, securitytoken=None, block=False, skip_if_running=False, invoke_pre_check_delay=3, - invoke_block_delay=15, build_params=None, cause=None, files=None): - assert isinstance(invoke_pre_check_delay, (int, float)) - assert isinstance(invoke_block_delay, (int, float)) + def invoke(self, securitytoken=None, block=False, build_params=None, cause=None, files=None): assert isinstance(block, bool) - assert isinstance(skip_if_running, bool) # Either copy the params dict or make a new one. build_params = build_params and dict( @@ -204,6 +200,9 @@ class Job(JenkinsBase, MutableJenkinsThing): queue_url = response.headers['location'] qi = QueueItem(queue_url, self.jenkins) + + if block: + qi.block_until_complete(delay=10) return qi def _buildid_for_type(self, buildtype): diff --git a/jenkinsapi_tests/systests/test_executors.py b/jenkinsapi_tests/systests/test_executors.py index 4631070..f66a945 100644 --- a/jenkinsapi_tests/systests/test_executors.py +++ b/jenkinsapi_tests/systests/test_executors.py @@ -33,8 +33,8 @@ class TestNodes(BaseSystemTest): self.jenkins.create_node(node_name) job_name = 'create_%s' % random_string() job = self.jenkins.create_job(job_name, LONG_RUNNING_JOB) - ii = job.invoke(invoke_pre_check_delay=2) - ii.block(until='not_queued') + qq = job.invoke(invoke_pre_check_delay=2) + qq.block_until_building() if job.is_running() is False: time.sleep(1) @@ -44,7 +44,7 @@ class TestNodes(BaseSystemTest): if execs.is_idle() is False: all_idle = False self.assertNotEqual(execs.get_progress(), -1) - self.assertEqual(execs.get_current_executable(), ii.get_build_number()) + self.assertEqual(execs.get_current_executable(), qq.get_build_number()) self.assertEqual(execs.likely_stuck(), False) self.assertEqual(all_idle, True, "Executor should have been triggered.") diff --git a/jenkinsapi_tests/systests/test_jenkins_matrix.py b/jenkinsapi_tests/systests/test_jenkins_matrix.py index 54849cc..ce1c4e5 100644 --- a/jenkinsapi_tests/systests/test_jenkins_matrix.py +++ b/jenkinsapi_tests/systests/test_jenkins_matrix.py @@ -19,7 +19,8 @@ class TestMatrixJob(BaseSystemTest): def test_invoke_matrix_job(self): job_name = 'create_%s' % random_string() job = self.jenkins.create_job(job_name, MATRIX_JOB) - job.invoke(block=True) + queueItem = job.invoke() + queueItem.block_until_complete() build = job.get_last_build() -- 2.34.1