python-jenkins/tests/jobs/test_set_next_build_number.py
Darragh Bailey 34cca0c4d9 Migration to using requests
Convert to the requests library to allow for more sophisticated response
handling to be added.

Want to allow for applications to override the response handling in
certain cases where the default is incorrect. Handling of urlopen
responses results in version specific handling to ensure correct
behaviour across multiple versions of python.

Changing to use the requests package, provides a higher level interface
and removes some of the version specific handling for exceptions.

Change-Id: I5369a0d35be4bf8b3b197a51e60aba21b5742cc7
Depends-On: Iabd70aa457ceb4dbc147d7cbaeec913148cb3b56
2018-02-12 11:16:54 +00:00

20 lines
600 B
Python

from mock import patch
import jenkins
from tests.jobs.base import JenkinsJobsTestBase
class JenkinsSetNextBuildNumberTest(JenkinsJobsTestBase):
@patch.object(jenkins.Jenkins, 'jenkins_open')
def test_simple(self, jenkins_mock):
self.j.set_next_build_number('TestJob', 1234)
self.assertEqual(
jenkins_mock.call_args[0][0].url,
self.make_url('job/TestJob/nextbuildnumber/submit'))
self.assertEqual(
jenkins_mock.call_args[0][0].data,
b'nextBuildNumber=1234')
self._check_requests(jenkins_mock.call_args_list)