本文整理汇总了Python中jenkinsapi.job.Job.get_scm_branch方法的典型用法代码示例。如果您正苦于以下问题:Python Job.get_scm_branch方法的具体用法?Python Job.get_scm_branch怎么用?Python Job.get_scm_branch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jenkinsapi.job.Job
的用法示例。
在下文中一共展示了Job.get_scm_branch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestHgJob
# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_scm_branch [as 别名]
class TestHgJob(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,
# build running
"lastBuild": {"number": 4, "url": "http://halob:8080/job/foo/4/"},
"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, **kwargs):
try:
return TestHgJob.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 configtree_with_branch(self):
config_node = '''
<project>
<scm class="hudson.plugins.mercurial.MercurialSCM" plugin="[email protected]">
<source>http://cm5/hg/sandbox/v01.0/int</source>
<modules/>
<branch>testme</branch>
<clean>false</clean>
<browser class="hudson.plugins.mercurial.browser.HgWeb">
<url>http://cm5/hg/sandbox/v01.0/int/</url>
</browser>
</scm>
</project>
'''
return config_node
def configtree_with_default_branch(self):
config_node = '''
<project>
<scm class="hudson.plugins.mercurial.MercurialSCM" plugin="[email protected]">
<source>http://cm5/hg/sandbox/v01.0/int</source>
<modules/>
<clean>false</clean>
<browser class="hudson.plugins.mercurial.browser.HgWeb">
<url>http://cm5/hg/sandbox/v01.0/int/</url>
</browser>
</scm>
</project>
'''
return config_node
@mock.patch.object(Job, 'get_config', configtree_with_branch)
def test_hg_attributes(self):
expected_url = ['http://cm5/hg/sandbox/v01.0/int']
self.assertEquals(self.j.get_scm_type(), 'hg')
self.assertEquals(self.j.get_scm_url(), expected_url)
self.assertEquals(self.j.get_scm_branch(), ['testme'])
@mock.patch.object(Job, 'get_config', configtree_with_default_branch)
def test_hg_attributes_default_branch(self):
self.assertEquals(self.j.get_scm_branch(), ['default'])