本文整理汇总了Python中jenkinsapi.job.Job.get_build_ids方法的典型用法代码示例。如果您正苦于以下问题:Python Job.get_build_ids方法的具体用法?Python Job.get_build_ids怎么用?Python Job.get_build_ids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkinsapi.job.Job
的用法示例。
在下文中一共展示了Job.get_build_ids方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_build_ids [as 别名]
#.........这里部分代码省略.........
def test_special_urls(self):
self.assertEquals(self.j.baseurl, 'http://halob:8080/job/foo')
self.assertEquals(
self.j.get_delete_url(), 'http://halob:8080/job/foo/doDelete')
self.assertEquals(
self.j.get_rename_url(), 'http://halob:8080/job/foo/doRename')
def test_get_description(self):
self.assertEquals(self.j.get_description(), 'test job')
def test_get_build_triggerurl(self):
self.assertEquals(
self.j.get_build_triggerurl(), 'http://halob:8080/job/foo/build')
def test_wrong__mk_json_from_build_parameters(self):
with self.assertRaises(AssertionError) as ar:
self.j._mk_json_from_build_parameters(build_params='bad parameter')
self.assertEquals(
ar.exception.message, 'Build parameters must be a dict')
def test__mk_json_from_build_parameters(self):
params = {'param1': 'value1', 'param2': 'value2'}
ret = self.j.mk_json_from_build_parameters(build_params=params)
self.assertTrue(isinstance(ret, str))
self.assertEquals(ret,
'{"parameter": [{"name": "param2", "value": "value2"}, {"name": "param1", "value": "value1"}]}')
def test_wrong_mk_json_from_build_parameters(self):
with self.assertRaises(AssertionError) as ar:
self.j.mk_json_from_build_parameters(build_params='bad parameter')
self.assertEquals(
ar.exception.message, 'Build parameters must be a dict')
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_wrong_field__build_id_for_type(self):
with self.assertRaises(AssertionError):
self.j._buildid_for_type('wrong')
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_good_buildnumber(self):
ret = self.j.get_last_good_buildnumber()
self.assertTrue(ret, 3)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_failed_buildnumber(self):
with self.assertRaises(NoBuildData):
self.j.get_last_failed_buildnumber()
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_buildnumber(self):
ret = self.j.get_last_buildnumber()
self.assertEquals(ret, 4)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_completed_buildnumber(self):
ret = self.j.get_last_completed_buildnumber()
self.assertEquals(ret, 3)
def test_get_build_dict(self):
ret = self.j.get_build_dict()
self.assertTrue(isinstance(ret, dict))
self.assertEquals(len(ret), 4)
@mock.patch.object(Job, '_poll')
def test_nobuilds_get_build_dict(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
with self.assertRaises(NoBuildData):
j.get_build_dict()
def test_get_build_ids(self):
# We don't want to deal with listreverseiterator here
# So we convert result to a list
ret = list(self.j.get_build_ids())
self.assertTrue(isinstance(ret, list))
self.assertEquals(len(ret), 4)
@mock.patch.object(Job, '_poll')
def test_nobuilds_get_revision_dict(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
with self.assertRaises(NoBuildData):
j.get_revision_dict()
@mock.patch.object(Job, '_poll')
def test_nobuilds_get_last_build(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
with self.assertRaises(NoBuildData):
j.get_last_build()
示例2: TestJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_build_ids [as 别名]
#.........这里部分代码省略.........
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_stable_buildnumber(self):
ret = self.j.get_last_stable_buildnumber()
self.assertTrue(ret, 3)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_failed_buildnumber(self):
with self.assertRaises(NoBuildData):
self.j.get_last_failed_buildnumber()
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_buildnumber(self):
ret = self.j.get_last_buildnumber()
self.assertEquals(ret, 4)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def test_get_last_completed_buildnumber(self):
ret = self.j.get_last_completed_buildnumber()
self.assertEquals(ret, 3)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_get_build_dict(self):
ret = self.j.get_build_dict()
self.assertTrue(isinstance(ret, dict))
self.assertEquals(len(ret), 4)
@mock.patch.object(JenkinsBase, 'get_data', fake_get_data_tree_empty)
def test_nobuilds_get_build_dict(self):
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
with self.assertRaises(NoBuildData):
j.get_build_dict()
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_get_build_ids(self):
# We don't want to deal with listreverseiterator here
# So we convert result to a list
ret = list(self.j.get_build_ids())
self.assertTrue(isinstance(ret, list))
self.assertEquals(len(ret), 4)
@mock.patch.object(Job, '_poll')
def test_nobuilds_get_revision_dict(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
with self.assertRaises(NoBuildData):
j.get_revision_dict()
@mock.patch.object(Job, '_poll')
def test_nobuilds_get_last_build(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
with self.assertRaises(NoBuildData):
j.get_last_build()
@mock.patch.object(JenkinsBase, 'get_data')
def test__add_missing_builds_not_all_loaded(self, get_data):
url = 'http://halob:8080/job/foo/%s' % config.JENKINS_API
data = TestJob.URL_DATA[url].copy()
get_data.return_value = data
j = Job('http://halob:8080/job/foo/', 'foo', self.J)
# to test this function we change data to not have one build
# and set it to mark that firstBuild was not loaded
示例3: TestJobGetAllBuilds
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_build_ids [as 别名]
#.........这里部分代码省略.........
(JOB1_API_URL, 'allBuilds[number,url]'): JOB1_ALL_BUILDS_DATA,
JOB2_API_URL: JOB2_DATA,
JOB3_API_URL: JOB3_DATA,
# this one below should never be used
(JOB3_API_URL, 'allBuilds[number,url]'): JOB3_ALL_BUILDS_DATA,
}
def fakeGetData(self, url, params=None, tree=None):
TestJobGetAllBuilds.__get_data_call_count += 1
if params is None:
try:
return dict(TestJobGetAllBuilds.URL_DATA[url])
except KeyError:
raise Exception("Missing data for url: %s" % url)
else:
try:
return dict(TestJobGetAllBuilds.URL_DATA[(url, str(params))])
except KeyError:
raise Exception(
"Missing data for url: %s with parameters %s" %
(url, repr(params)))
def fakeGetDataTree(self, url, **args):
TestJobGetAllBuilds.__get_data_call_count += 1
try:
if args['tree']:
if 'builds' in args['tree']:
return {
'builds': TestJobGetAllBuilds.URL_DATA[url]['builds']}
elif 'allBuilds' in args['tree']:
return TestJobGetAllBuilds.URL_DATA[(url, args['tree'])]
elif 'lastBuild' in args['tree']:
return {
'lastBuild': TestJobGetAllBuilds.URL_DATA[url]['lastBuild']}
else:
return dict(TestJobGetAllBuilds.URL_DATA[url])
except KeyError:
raise Exception("Missing data for %s" % url)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def setUp(self):
TestJobGetAllBuilds.__get_data_call_count = 0
self.J = mock.MagicMock() # Jenkins object
self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_get_build_dict(self):
# The job data contains only one build, so we expect that the
# remaining jobs will be fetched automatically
ret = self.j.get_build_dict()
self.assertTrue(isinstance(ret, dict))
self.assertEqual(len(ret), 4)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_incomplete_builds_list_will_call_jenkins_twice(self):
# The job data contains only one build, so we expect that the
# remaining jobs will be fetched automatically, and to have two calls
# to the Jenkins API
TestJobGetAllBuilds.__get_data_call_count = 0
self.J.lazy = False
self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)
self.assertEqual(TestJobGetAllBuilds.__get_data_call_count, 2)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_lazy_builds_list_will_not_call_jenkins_twice(self):
# The job data contains only one build, so we expect that the
# remaining jobs will be fetched automatically, and to have two calls
# to the Jenkins API
TestJobGetAllBuilds.__get_data_call_count = 0
self.J.lazy = True
self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)
self.assertEqual(TestJobGetAllBuilds.__get_data_call_count, 1)
self.J.lazy = False
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_complete_builds_list_will_call_jenkins_once(self):
# The job data contains all builds, so we will not gather remaining
# builds
TestJobGetAllBuilds.__get_data_call_count = 0
self.j = Job('http://halob:8080/job/fullfoo/', 'fullfoo', self.J)
self.assertEqual(TestJobGetAllBuilds.__get_data_call_count, 1)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_nobuilds_get_build_dict(self):
j = Job(
'http://halob:8080/job/look_ma_no_builds/',
'look_ma_no_builds',
self.J)
ret = j.get_build_dict()
self.assertTrue(isinstance(ret, dict))
self.assertEqual(len(ret), 0)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetDataTree)
def test_get_build_ids(self):
# The job data contains only one build, so we expect that the
# remaining jobs will be fetched automatically
ret = list(self.j.get_build_ids())
self.assertTrue(isinstance(ret, list))
self.assertEqual(len(ret), 4)
示例4: TestJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_build_ids [as 别名]
#.........这里部分代码省略.........
def test_get_last_stable_buildnumber(self):
ret = self.j.get_last_stable_buildnumber()
self.assertTrue(ret, 3)
@mock.patch.object(JenkinsBase, "get_data", fakeGetData)
def test_get_last_failed_buildnumber(self):
with self.assertRaises(NoBuildData):
self.j.get_last_failed_buildnumber()
@mock.patch.object(JenkinsBase, "get_data", fakeGetData)
def test_get_last_buildnumber(self):
ret = self.j.get_last_buildnumber()
self.assertEquals(ret, 4)
@mock.patch.object(JenkinsBase, "get_data", fakeGetData)
def test_get_last_completed_buildnumber(self):
ret = self.j.get_last_completed_buildnumber()
self.assertEquals(ret, 3)
def test_get_build_dict(self):
ret = self.j.get_build_dict()
self.assertTrue(isinstance(ret, dict))
self.assertEquals(len(ret), 4)
@mock.patch.object(Job, "_poll")
def test_nobuilds_get_build_dict(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job("http://halob:8080/job/foo/", "foo", self.J)
with self.assertRaises(NoBuildData):
j.get_build_dict()
def test_get_build_ids(self):
# We don't want to deal with listreverseiterator here
# So we convert result to a list
ret = list(self.j.get_build_ids())
self.assertTrue(isinstance(ret, list))
self.assertEquals(len(ret), 4)
@mock.patch.object(Job, "_poll")
def test_nobuilds_get_revision_dict(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job("http://halob:8080/job/foo/", "foo", self.J)
with self.assertRaises(NoBuildData):
j.get_revision_dict()
@mock.patch.object(Job, "_poll")
def test_nobuilds_get_last_build(self, _poll):
# Bare minimum build dict, we only testing dissapearance of 'builds'
_poll.return_value = {"name": "foo"}
j = Job("http://halob:8080/job/foo/", "foo", self.J)
with self.assertRaises(NoBuildData):
j.get_last_build()
@mock.patch.object(JenkinsBase, "get_data")
def test__add_missing_builds_not_all_loaded(self, get_data):
url = "http://halob:8080/job/foo/%s" % config.JENKINS_API
data = TestJob.URL_DATA[url].copy()
get_data.return_value = data
j = Job("http://halob:8080/job/foo/", "foo", self.J)
# to test this function we change data to not have one build
# and set it to mark that firstBuild was not loaded