From d61b7f6469ee8d195e7634a05cd6a25bb9326dee Mon Sep 17 00:00:00 2001 From: Salim Fadhley Date: Sun, 23 Jun 2013 21:21:01 +0100 Subject: [PATCH] more invocation stuff, temporary commit as I move to a new computer --- README.rst | 2 +- jenkinsapi/invocation.py | 17 +++++++++++++++++ jenkinsapi_tests/systests/base.py | 2 +- jenkinsapi_tests/systests/job_configs.py | 4 ++++ jenkinsapi_tests/systests/test_invocation.py | 10 ++++++++-- 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index a635a7e..59c396e 100644 --- a/README.rst +++ b/README.rst @@ -36,7 +36,7 @@ First of all, thanks for using this project. The fact that you are checking this Known bugs ---------- - [ ] Currently incompatible with Jenkins > 1.518. Job deletion operations fail unless Cross-Site scripting protection is disabled. + [x] Currently incompatible with Jenkins > 1.518. Job deletion operations fail unless Cross-Site scripting protection is disabled. For other issues, please refer to the support URL below. diff --git a/jenkinsapi/invocation.py b/jenkinsapi/invocation.py index 6be65c7..d321aba 100644 --- a/jenkinsapi/invocation.py +++ b/jenkinsapi/invocation.py @@ -10,18 +10,33 @@ class Invocation(object): def __init__(self, job): self.job = job + self.initial_builds = None def __enter__(self): """ Start watching the job """ + self.job.poll() + self.initial_builds = set(self.job.get_build_dict().keys()) def __exit__(self, type, value, traceback): """ Finish watching the job - it will track which new queue items or builds have been created as a consequence of invoking the job. """ + self.job.poll() + newly_created_builds = set(self.job.get_build_dict().keys()) + + import ipdb + ipdb.set_trace() + + + def get_build_number(self): + """ + If this job is building or complete then provide it's build-number + """ + return 1 def block(self, until='completed'): """ @@ -38,11 +53,13 @@ class Invocation(object): """ Returns True if this item is on the queue """ + return True def is_running(self): """ Returns True if this item is executing now """ + return True def is_queued_or_running(self): return self.is_queued() or self.is_running() diff --git a/jenkinsapi_tests/systests/base.py b/jenkinsapi_tests/systests/base.py index 42edbd3..bae36d2 100644 --- a/jenkinsapi_tests/systests/base.py +++ b/jenkinsapi_tests/systests/base.py @@ -1,5 +1,5 @@ import unittest -from jenkinsapi.jenkinsapi_tests.systests.job_configs import EMPTY_JOB +from jenkinsapi_tests.systests.job_configs import EMPTY_JOB from jenkinsapi.jenkins import Jenkins diff --git a/jenkinsapi_tests/systests/job_configs.py b/jenkinsapi_tests/systests/job_configs.py index 9008cb9..7b6a4fb 100644 --- a/jenkinsapi_tests/systests/job_configs.py +++ b/jenkinsapi_tests/systests/job_configs.py @@ -1,3 +1,7 @@ +""" +A selection of job objects used in testing. +""" + EMPTY_JOB = '''\ diff --git a/jenkinsapi_tests/systests/test_invocation.py b/jenkinsapi_tests/systests/test_invocation.py index f79b9f6..21720a5 100644 --- a/jenkinsapi_tests/systests/test_invocation.py +++ b/jenkinsapi_tests/systests/test_invocation.py @@ -3,19 +3,25 @@ System tests for `jenkinsapi.jenkins` module. ''' import unittest from jenkinsapi.invocation import Invocation +from jenkinsapi_tests.systests.job_configs import LONG_RUNNING_JOB from jenkinsapi_tests.test_utils.random_strings import random_string -from jenkinsapi_tests.systests.base import BaseSystemTest, EMPTY_JOB_CONFIG +from jenkinsapi_tests.systests.base import BaseSystemTest class TestInvocation(BaseSystemTest): def test_invocation_object(self): job_name = 'create_%s' % random_string() - job = self.jenkins.create_job(job_name, EMPTY_JOB_CONFIG) + job = self.jenkins.create_job(job_name, LONG_RUNNING_JOB) ii = job.invoke() self.assertIsInstance(ii, Invocation) + self.assertTrue(ii.is_queued_or_running()) + self.assertEquals(ii.get_build_number(), 1) + def test_multiple_inocations(self): + pass + if __name__ == '__main__': -- 2.34.1