diff options
author | Salim Fadhley <sal@stodge.org> | 2015-01-13 22:06:09 +0000 |
---|---|---|
committer | Salim Fadhley <sal@stodge.org> | 2015-01-13 22:06:09 +0000 |
commit | d02c2cee5ce31ad35cfd3943ab260a1995b1f6bd (patch) | |
tree | 1451bb638fda3269720c3f0cbae30dabefc438d2 | |
parent | ab92e943be109a8f9f3f3bf149be849498ffd57f (diff) | |
parent | c15651ddb02a2fa4f6620e3c0bde204a93fe34b9 (diff) | |
download | python-jenkinsapi-d02c2cee5ce31ad35cfd3943ab260a1995b1f6bd.tar.gz python-jenkinsapi-d02c2cee5ce31ad35cfd3943ab260a1995b1f6bd.tar.bz2 python-jenkinsapi-d02c2cee5ce31ad35cfd3943ab260a1995b1f6bd.zip |
Merge branch 'master' into unstable
Conflicts:
jenkinsapi/job.py
-rw-r--r-- | jenkinsapi/job.py | 1 | ||||
-rw-r--r-- | jenkinsapi/queue.py | 2 | ||||
-rw-r--r-- | jenkinsapi/view.py | 27 | ||||
-rw-r--r-- | jenkinsapi_tests/systests/test_views.py | 13 | ||||
-rw-r--r-- | jenkinsapi_tests/systests/view_configs.py | 28 | ||||
-rw-r--r-- | jenkinsapi_tests/unittests/test_build.py | 4 |
6 files changed, 74 insertions, 1 deletions
diff --git a/jenkinsapi/job.py b/jenkinsapi/job.py index 0ecd54d..ff6122d 100644 --- a/jenkinsapi/job.py +++ b/jenkinsapi/job.py @@ -210,6 +210,7 @@ class Job(JenkinsBase, MutableJenkinsThing): redirect_url = response.headers['location'] if not redirect_url.startswith("%s/queue/item" % self.jenkins.baseurl): + if files: raise ValueError('Builds with file parameters are not ' 'supported by this jenkinsapi version. ' diff --git a/jenkinsapi/queue.py b/jenkinsapi/queue.py index 2e1ff23..0804927 100644 --- a/jenkinsapi/queue.py +++ b/jenkinsapi/queue.py @@ -41,7 +41,7 @@ class Queue(JenkinsBase): for item in self._data['items']: yield item['id'] - def iterivalues(self): + def itervalues(self): for item in self._data['items']: yield QueueItem(self.jenkins, **item) diff --git a/jenkinsapi/view.py b/jenkinsapi/view.py index e06361f..c262804 100644 --- a/jenkinsapi/view.py +++ b/jenkinsapi/view.py @@ -167,6 +167,33 @@ class View(JenkinsBase): def get_nested_view_dict(self): return dict(self._get_nested_views()) + def get_config_xml_url(self): + return '%s/config.xml' % self.baseurl + + def get_config(self): + """ + Return the config.xml from the view + """ + url = self.get_config_xml_url() + response = self.get_jenkins_obj().requester.get_and_confirm_status(url) + return response.text + + def update_config(self, config): + """ + Update the config.xml to the view + """ + url = self.get_config_xml_url() + try: + if isinstance(config, unicode): # pylint: disable=undefined-variable + config = str(config) + except NameError: + # Python3 already a str + pass + + response = self.get_jenkins_obj().requester.post_url( + url, params={}, data=config) + return response.text + @property def views(self): return self.get_jenkins_obj().get_jenkins_obj_from_url(self.baseurl).views diff --git a/jenkinsapi_tests/systests/test_views.py b/jenkinsapi_tests/systests/test_views.py index 6d91c6e..76e948c 100644 --- a/jenkinsapi_tests/systests/test_views.py +++ b/jenkinsapi_tests/systests/test_views.py @@ -12,6 +12,7 @@ from jenkinsapi.view import View from jenkinsapi.views import Views from jenkinsapi.api import get_view_from_url from jenkinsapi_tests.systests.base import BaseSystemTest +from jenkinsapi_tests.systests.view_configs import VIEW_WITH_FILTER_AND_REGEX from jenkinsapi_tests.test_utils.random_strings import random_string log = logging.getLogger(__name__) @@ -59,6 +60,18 @@ class TestViews(BaseSystemTest): del self.jenkins.views[view1_name] self.assertNotIn(view1_name, self.jenkins.views) + def test_update_view_config(self): + view_name = random_string() + new_view = self.jenkins.views.create(view_name) + self.assertIsInstance(new_view, View) + self.assertIn(view_name, self.jenkins.views) + config = self.jenkins.views[view_name].get_config().strip() + new_view_config = VIEW_WITH_FILTER_AND_REGEX % view_name + self.assertNotEquals(config, new_view_config) + self.jenkins.views[view_name].update_config(new_view_config) + config = self.jenkins.views[view_name].get_config().strip() + self.assertEquals(config, new_view_config) + def test_make_nested_views(self): job = self._create_job() top_view_name = random_string() diff --git a/jenkinsapi_tests/systests/view_configs.py b/jenkinsapi_tests/systests/view_configs.py new file mode 100644 index 0000000..66d2aab --- /dev/null +++ b/jenkinsapi_tests/systests/view_configs.py @@ -0,0 +1,28 @@ +""" +A selection of view objects used in testing. +""" + +VIEW_WITH_FILTER_AND_REGEX = """ +<?xml version="1.0" encoding="UTF-8"?> +<hudson.model.ListView> + <name>%s</name> + <filterExecutors>true</filterExecutors> + <filterQueue>true</filterQueue> + <properties class="hudson.model.View$PropertyList"/> + <jobNames> + <comparator class="hudson.util.CaseInsensitiveComparator"/> + </jobNames> + <jobFilters/> + <columns> + <hudson.views.StatusColumn/> + <hudson.views.WeatherColumn/> + <hudson.views.JobColumn/> + <hudson.views.LastSuccessColumn/> + <hudson.views.LastFailureColumn/> + <hudson.views.LastDurationColumn/> + <hudson.views.BuildButtonColumn/> + </columns> + <includeRegex>regex</includeRegex> + <recurse>false</recurse> +</hudson.model.ListView> +""".strip() diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py index d7cf728..549bd2e 100644 --- a/jenkinsapi_tests/unittests/test_build.py +++ b/jenkinsapi_tests/unittests/test_build.py @@ -92,6 +92,10 @@ class test_build(unittest.TestCase): """ with no scm, get_revision should return None """ self.assertEqual(self.b.get_revision(), None) + def test_get_revision_no_scm(self): + """ with no scm, get_revision should return None """ + self.assertEqual(self.b.get_revision(), None) + ## TEST DISABLED - DOES NOT WORK # def test_downstream(self): # expected = ['SingleJob','MultipleJobs'] |