本文整理汇总了Python中jenkinsapi.fingerprint.Fingerprint类的典型用法代码示例。如果您正苦于以下问题:Python Fingerprint类的具体用法?Python Fingerprint怎么用?Python Fingerprint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fingerprint类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_valid_with_requests_HTTPError_Not404
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())
示例2: _verify_download
def _verify_download(self, fspath):
"""
Verify that a downloaded object has a valid fingerprint.
"""
local_md5 = self._md5sum(fspath)
fp = Fingerprint(self.build.job.jenkins.baseurl, local_md5, self.build.job.jenkins)
return fp.validate_for_build(os.path.basename(fspath), self.build.job.name, self.build.buildno)
示例3: test_invalid_for_401
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
示例4: test_object_creation
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()
示例5: _verify_download
def _verify_download(self, fspath, strict_validation):
"""
Verify that a downloaded object has a valid fingerprint.
"""
local_md5 = self._md5sum(fspath)
baseurl = self.build.job.jenkins.baseurl
fp = Fingerprint(baseurl, local_md5, self.build.job.jenkins)
valid = fp.validate_for_build(os.path.basename(fspath), self.build.job.name, self.build.buildno)
if not valid or (fp.unknown and strict_validation): # strict = 404 as invalid
raise ArtifactBroken("Artifact %s seems to be broken, check %s" % (local_md5, baseurl))
return True
示例6: TestFingerprint
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())
示例7: validate_fingerprint_for_build
def validate_fingerprint_for_build(self, digest, filename, job, build):
obj_fingerprint = Fingerprint(self.baseurl, digest, jenkins_obj=self)
return obj_fingerprint.validate_for_build(filename, job, build)
示例8: get_artifact_data
def get_artifact_data(self, id):
obj_fingerprint = Fingerprint(self.baseurl, id, jenkins_obj=self)
obj_fingerprint.validate()
return obj_fingerprint.get_info()
示例9: validate_fingerprint
def validate_fingerprint(self, id):
obj_fingerprint = Fingerprint(self.baseurl, id, jenkins_obj=self)
obj_fingerprint.validate()
log.info("Jenkins says %s is valid" % id)
示例10: test_object_creation
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())