本文整理汇总了Python中jenkinsapi.job.Job.mk_json_from_build_parameters方法的典型用法代码示例。如果您正苦于以下问题:Python Job.mk_json_from_build_parameters方法的具体用法?Python Job.mk_json_from_build_parameters怎么用?Python Job.mk_json_from_build_parameters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkinsapi.job.Job
的用法示例。
在下文中一共展示了Job.mk_json_from_build_parameters方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_json_for_single_param
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
def test_get_json_for_single_param(self):
params = {"B": "one two three"}
expected = '{"parameter": {"name": "B", "value": "one two three"}, "statusCode": "303", "redirectTo": "."}'
self.assertJsonEqual(
Job.mk_json_from_build_parameters(params),
expected
)
示例2: test_get_json_for_many_params
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
def test_get_json_for_many_params(self):
params = {"B": "Honey", "A": "Boo", "C": 2}
expected = '{"parameter": [{"name": "A", "value": "Boo"}, {"name": "B", "value": "Honey"}, {"name": "C", "value": "2"}], "statusCode": "303", "redirectTo": "."}'
self.assertJsonEqual(
Job.mk_json_from_build_parameters(params),
expected
)
示例3: test_get_json_for_many_params
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
def test_get_json_for_many_params():
params = {"B": "Honey", "A": "Boo", "C": 2}
expected = ('{"parameter": [{"name": "A", "value": "Boo"}, '
'{"name": "B", "value": "Honey"}, '
'{"name": "C", "value": "2"}], '
'"statusCode": "303", "redirectTo": "."}')
json_equal(Job.mk_json_from_build_parameters(params), expected)
示例4: TestJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
class TestJob(unittest.TestCase):
JOB_DATA = {
"actions": [],
"description": "test job",
"displayName": "foo",
"displayNameOrNull": None,
"name": "foo",
"url": "http://halob:8080/job/foo/",
"buildable": True,
"builds": [
{"number": 3, "url": "http://halob:8080/job/foo/3/"},
{"number": 2, "url": "http://halob:8080/job/foo/2/"},
{"number": 1, "url": "http://halob:8080/job/foo/1/"}
],
"color": "blue",
"firstBuild": {"number": 1, "url": "http://halob:8080/job/foo/1/"},
"healthReport": [
{"description": "Build stability: No recent builds failed.", "iconUrl": "health-80plus.png", "score": 100}
],
"inQueue": False,
"keepDependencies": False,
"lastBuild": {"number": 4, "url": "http://halob:8080/job/foo/4/"}, # build running
"lastCompletedBuild": {"number": 3, "url": "http://halob:8080/job/foo/3/"},
"lastFailedBuild": None,
"lastStableBuild": {"number": 3, "url": "http://halob:8080/job/foo/3/"},
"lastSuccessfulBuild": {"number": 3, "url": "http://halob:8080/job/foo/3/"},
"lastUnstableBuild": None,
"lastUnsuccessfulBuild": None,
"nextBuildNumber": 4,
"property": [],
"queueItem": None,
"concurrentBuild": False,
"downstreamProjects": [],
"scm": {},
"upstreamProjects": []
}
URL_DATA = {'http://halob:8080/job/foo/%s' % config.JENKINS_API: JOB_DATA}
def fakeGetData(self, url, *args):
try:
return TestJob.URL_DATA[url]
except KeyError:
raise Exception("Missing data for %s" % url)
@mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
def setUp(self):
self.J = mock.MagicMock() # Jenkins object
self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)
def testRepr(self):
# Can we produce a repr string for this object
self.assertEquals(repr(self.j), '<jenkinsapi.job.Job foo>')
def testName(self):
with self.assertRaises(AttributeError):
self.j.id()
self.assertEquals(self.j.name, 'foo')
def testNextBuildNumber(self):
self.assertEquals(self.j.get_next_build_number(), 4)
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')
#.........这里部分代码省略.........
示例5: TestJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
#.........这里部分代码省略.........
def setUp(self):
self.J = mock.MagicMock() # Jenkins object
self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)
def testRepr(self):
# Can we produce a repr string for this object
self.assertEquals(repr(self.j), '<jenkinsapi.job.Job foo>')
def testName(self):
with self.assertRaises(AttributeError):
self.j.id()
self.assertEquals(self.j.name, 'foo')
def testNextBuildNumber(self):
self.assertEquals(self.j.get_next_build_number(), 4)
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/buildWithParameters')
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(
str(ar.exception), '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_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)
示例6: TestJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
#.........这里部分代码省略.........
raise Exception("Missing data for %s" % url)
@mock.patch.object(JenkinsBase, "get_data", fakeGetData)
def setUp(self):
self.J = mock.MagicMock() # Jenkins object
self.j = Job("http://halob:8080/job/foo/", "foo", self.J)
def testRepr(self):
# Can we produce a repr string for this object
self.assertEquals(repr(self.j), "<jenkinsapi.job.Job foo>")
def testName(self):
with self.assertRaises(AttributeError):
self.j.id()
self.assertEquals(self.j.name, "foo")
def testNextBuildNumber(self):
self.assertEquals(self.j.get_next_build_number(), 4)
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/buildWithParameters")
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(str(ar.exception), "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))
try:
self.assertItemsEqual(
ret, '{"parameter": [{"name": "param2", "value": "value2"}, {"name": "param1", "value": "value1"}]}'
)
except AttributeError:
self.assertCountEqual(
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(str(ar.exception), "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()
示例7: test_get_json_for_single_param
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import mk_json_from_build_parameters [as 别名]
def test_get_json_for_single_param():
params = {"B": "one two three"}
expected = ('{"parameter": {"name": "B", "value": "one two three"}, '
'"statusCode": "303", "redirectTo": "."}')
json_equal(Job.mk_json_from_build_parameters(params), expected)