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


Python Job.get_last_good_buildnumber方法代码示例

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


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

示例1: TestJob

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

示例2: TestJob

# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_last_good_buildnumber [as 别名]

#.........这里部分代码省略.........

    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)
    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)
开发者ID:Khan,项目名称:jenkinsapi,代码行数:70,代码来源:test_job.py

示例3: TestJob

# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_last_good_buildnumber [as 别名]
class TestJob(unittest.TestCase):
    JOB_DATA = {'actions': [None, {}],
                'buildable': True,
                'builds': [{'number': 106,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/106/'},
                           {'number': 105,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/105/'},
                           {'number': 104,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/104/'},
                           {'number': 103,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/103/'},
                           {'number': 102,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/102/'},
                           {'number': 101,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/101/'},
                           {'number': 100,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/100/'},
                           {'number': 99,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/99/'},
                           {'number': 98,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/98/'},
                           {'number': 97,
                            'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/97/'}],
                'color': 'red',
                'concurrentBuild': False,
                'description': '',
                'displayName': 'ecd-webgoat',
                'displayNameOrNull': None,
                'downstreamProjects': [],
                'firstBuild': {'number': 97,
                               'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/97/'},
                'healthReport': [{'description': 'Build stability: 1 out of the last 5 builds failed.',
                                  'iconUrl': 'health-60to79.png',
                                  'score': 80}],
                'inQueue': False,
                'keepDependencies': False,
                'lastBuild': {'number': 106,
                              'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/106/'},
                'lastCompletedBuild': {'number': 106,
                                       'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/106/'},
                'lastFailedBuild': {'number': 106,
                                    'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/106/'},
                'lastStableBuild': {'number': 105,
                                    'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/105/'},
                'lastSuccessfulBuild': {'number': 105,
                                        'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/105/'},
                'lastUnstableBuild': None,
                'lastUnsuccessfulBuild': {'number': 106,
                                          'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/106/'},
                'modules': [{'color': 'blue',
                             'displayName': 'webgoat',
                             'name': 'com.googlecode:webgoat',
                             'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/com.googlecode$webgoat/'}],
                'name': 'ecd-webgoat',
                'nextBuildNumber': 107,
                'property': [{}],
                'queueItem': None,
                'scm': {},
                'upstreamProjects': [],
                'url': 'http://dlsysadm-ap72:18080/jenkins/job/ecd-webgoat/'
                }

    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)
        
#     def fake_add_missing_builds(self, data):
#         return data

    @mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
    #@mock.patch.object(Job, '_add_missing_builds', fake_add_missing_builds)
    def setUp(self):

        self.J = mock.MagicMock()  # Jenkins object
        self.j = Job('http://halob:8080/job/foo/', 'foo', self.J)

    @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_has_params(self):
        self.assertFalse(self.j.has_params())
开发者ID:117111302,项目名称:jenkinsapi,代码行数:91,代码来源:test_job_maven.py

示例4: TestJob

# 需要导入模块: from jenkinsapi.job import Job [as 别名]
# 或者: from jenkinsapi.job.Job import get_last_good_buildnumber [as 别名]

#.........这里部分代码省略.........
        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()
        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)
    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"}
开发者ID:baijum,项目名称:jenkinsapi,代码行数:70,代码来源:test_job.py


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