当前位置: 首页>>代码示例>>Python>>正文


Python Job.get_scm_url方法代码示例

本文整理汇总了Python中jenkinsapi.job.Job.get_scm_url方法的典型用法代码示例。如果您正苦于以下问题:Python Job.get_scm_url方法的具体用法?Python Job.get_scm_url怎么用?Python Job.get_scm_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jenkinsapi.job.Job的用法示例。


在下文中一共展示了Job.get_scm_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestHgJob

# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_scm_url [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'])
开发者ID:jerrysf,项目名称:jenkinsapi,代码行数:96,代码来源:test_job_scm_hg.py


注:本文中的jenkinsapi.job.Job.get_scm_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。