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


Python Fingerprint.valid方法代码示例

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


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

示例1: test_valid_with_requests_HTTPError_Not404

# 需要导入模块: from jenkinsapi.fingerprint import Fingerprint [as 别名]
# 或者: from jenkinsapi.fingerprint.Fingerprint import valid [as 别名]
 def test_valid_with_requests_HTTPError_Not404(self, _poll, _basepoll):
     resp_obj = requests.models.Response()
     resp_obj.status_code = 401
     _poll.side_effect = requests.exceptions.HTTPError(response=resp_obj)
     J = Jenkins(self.baseurl, username="foouser", password="foopassword")
     fp = Fingerprint(self.baseurl, self.dummy_md5, J)
     self.assertFalse(fp.valid())
开发者ID:Batirchik,项目名称:jenkinsapi,代码行数:9,代码来源:test_fingerprint.py

示例2: test_invalid_for_401

# 需要导入模块: from jenkinsapi.fingerprint import Fingerprint [as 别名]
# 或者: from jenkinsapi.fingerprint.Fingerprint import valid [as 别名]
def test_invalid_for_401(jenkins, dummy_md5, monkeypatch):
    class FakeResponse(object):
        status_code = 401
        text = '{}'

    class FakeHTTPError(HTTPError):
        def __init__(self):
            self.response = FakeResponse()

    def fake_poll(cls, tree=None):   # pylint: disable=unused-argument
        raise FakeHTTPError()

    monkeypatch.setattr(JenkinsBase, '_poll', fake_poll)

    def fake_get_url(
            url,  # pylint: disable=unused-argument
            params=None,  # pylint: disable=unused-argument
            headers=None,  # pylint: disable=unused-argument
            allow_redirects=True,  # pylint: disable=unused-argument
            stream=False):  # pylint: disable=unused-argument

        return FakeResponse()

    monkeypatch.setattr(Requester, 'get_url', fake_get_url)

    fingerprint = Fingerprint('http://foo:8080', dummy_md5, jenkins)
    assert fingerprint.valid() is not True
开发者ID:PaleoWoods,项目名称:jenkinsapi,代码行数:29,代码来源:test_fingerprint.py

示例3: TestFingerprint

# 需要导入模块: from jenkinsapi.fingerprint import Fingerprint [as 别名]
# 或者: from jenkinsapi.fingerprint.Fingerprint import valid [as 别名]
class TestFingerprint(unittest.TestCase):
    def setUp(self):
        self.baseurl = "http://localhost:8080"
        m = hashlib.md5()
        m.update("some dummy string")
        self.dummy_md5 = m.hexdigest()

    @mock.patch.object(Jenkins, "_poll")
    @mock.patch.object(JenkinsBase, "_poll")
    def test_object_creation(self, _poll, _basepoll):
        J = Jenkins(self.baseurl, username="foouser", password="foopassword")
        self.fp_instance = Fingerprint(self.baseurl, self.dummy_md5, J)
        self.assertTrue(isinstance(self.fp_instance, Fingerprint))
        self.assertEquals(str(self.fp_instance), self.dummy_md5)
        self.assertTrue(self.fp_instance.valid())

    @mock.patch.object(Jenkins, "_poll")
    @mock.patch.object(JenkinsBase, "_poll")
    def test_valid_with_requests_HTTPError_404(self, _poll, _basepoll):
        resp_obj = requests.models.Response()
        resp_obj.status_code = 404
        _poll.side_effect = requests.exceptions.HTTPError(response=resp_obj)
        J = Jenkins(self.baseurl, username="foouser", password="foopassword")
        fp = Fingerprint(self.baseurl, self.dummy_md5, J)
        self.assertTrue(fp.valid())

    @mock.patch.object(Jenkins, "_poll")
    @mock.patch.object(JenkinsBase, "_poll")
    def test_valid_with_requests_HTTPError_Not404(self, _poll, _basepoll):
        resp_obj = requests.models.Response()
        resp_obj.status_code = 401
        _poll.side_effect = requests.exceptions.HTTPError(response=resp_obj)
        J = Jenkins(self.baseurl, username="foouser", password="foopassword")
        fp = Fingerprint(self.baseurl, self.dummy_md5, J)
        self.assertFalse(fp.valid())
开发者ID:Batirchik,项目名称:jenkinsapi,代码行数:37,代码来源:test_fingerprint.py

示例4: test_object_creation

# 需要导入模块: from jenkinsapi.fingerprint import Fingerprint [as 别名]
# 或者: from jenkinsapi.fingerprint.Fingerprint import valid [as 别名]
def test_object_creation(jenkins, dummy_md5, monkeypatch):
    def fake_poll(cls, tree=None):   # pylint: disable=unused-argument
        return {}

    monkeypatch.setattr(JenkinsBase, '_poll', fake_poll)
    fp_instance = Fingerprint('http://foo:8080', dummy_md5, jenkins)

    assert isinstance(fp_instance, Fingerprint)
    assert str(fp_instance) == dummy_md5
    assert fp_instance.valid()
开发者ID:PaleoWoods,项目名称:jenkinsapi,代码行数:12,代码来源:test_fingerprint.py


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