本文整理汇总了Python中treeherder.client.TreeherderResultSetCollection类的典型用法代码示例。如果您正苦于以下问题:Python TreeherderResultSetCollection类的具体用法?Python TreeherderResultSetCollection怎么用?Python TreeherderResultSetCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TreeherderResultSetCollection类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_resultset_create
def test_resultset_create(sample_resultset, jm, initial_data):
"""
test posting data to the resultset endpoint via webtest.
extected result are:
- return code 200
- return message successful
- 1 resultset stored in the jobs schema
"""
trsc = TreeherderResultSetCollection()
for rs in sample_resultset:
rs = trsc.get_resultset(rs)
trsc.add(rs)
resp = test_utils.post_collection(jm.project, trsc)
assert resp.status_int == 200
assert resp.json['message'] == 'well-formed JSON stored'
stored_objs = jm.get_dhub().execute(
proc="jobs_test.selects.resultset_by_rev_hash",
placeholders=[sample_resultset[0]['revision_hash']]
)
assert len(stored_objs) == 1
assert stored_objs[0]['revision_hash'] == sample_resultset[0]['revision_hash']
jm.disconnect()
示例2: test_send_result_collection
def test_send_result_collection(self, mock_post):
"""Can add a treeherder collections to a TreeherderRequest."""
mock_post.return_value = self._expected_response_return_object()
trc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trc.add(trc.get_resultset(resultset))
client = TreeherderClient(
protocol='http',
host='host',
client_id='client-abc',
secret='secret123',
)
client.post_collection('project', trc)
path, resp = mock_post.call_args
self.assertEqual(mock_post.call_count, 1)
self.assertEqual(
trc.get_collection_data(),
resp['json']
)
示例3: test_resultset_sample_data
def test_resultset_sample_data(self):
"""Test all add methods for building result sets"""
trsc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trs = TreeherderResultSet()
trs.add_push_timestamp(resultset['push_timestamp'])
trs.add_revision_hash(resultset['revision_hash'])
trs.add_author(resultset['author'])
trs.add_type('push')
for revision in resultset['revisions']:
tr = TreeherderRevision()
tr.add_revision(revision['revision'])
tr.add_author(revision['author'])
tr.add_comment(revision['comment'])
tr.add_repository(revision['repository'])
trs.add_revision(tr)
self.compare_structs(trs.data, resultset)
trsc.add(trs)
# confirm we get the same thing if we initialize from
# a resultset dict
trs_struct = TreeherderResultSet(resultset)
self.compare_structs(trs_struct.data, resultset)
示例4: test_resultset_create
def test_resultset_create(jm, test_repository, sample_resultset,
mock_post_json):
"""
test posting data to the resultset endpoint via webtest.
extected result are:
- return code 200
- return message successful
- 1 resultset stored in the jobs schema
"""
assert Push.objects.count() == 0
# store the first two, so we submit all, but should properly not re-
# add the others.
jm.store_result_set_data(sample_resultset[:2])
assert Push.objects.count() == 2
trsc = TreeherderResultSetCollection()
exp_revision_hashes = set()
for rs in sample_resultset:
rs.update({'author': 'John Doe'})
result_set = trsc.get_resultset(rs)
trsc.add(result_set)
exp_revision_hashes.add(rs["revision"])
test_utils.post_collection(jm.project, trsc)
assert Push.objects.count() == len(sample_resultset)
assert set(Push.objects.values_list('revision', flat=True)) == set(
[rs['revision'] for rs in sample_resultset])
示例5: test_resultset_create
def test_resultset_create(sample_resultset, jm, initial_data, mock_post_json):
"""
test posting data to the resultset endpoint via webtest.
extected result are:
- return code 200
- return message successful
- 1 resultset stored in the jobs schema
"""
trsc = TreeherderResultSetCollection()
for rs in sample_resultset:
rs.update({'author': 'John Doe'})
result_set = trsc.get_resultset(rs)
trsc.add(result_set)
test_utils.post_collection(jm.project, trsc)
stored_objs = jm.get_dhub().execute(
proc="jobs_test.selects.resultset_by_rev_hash",
placeholders=[sample_resultset[0]['revision_hash']]
)
assert len(stored_objs) == 1
assert stored_objs[0]['revision_hash'] == sample_resultset[0]['revision_hash']
jm.disconnect()
示例6: test_resultset_create
def test_resultset_create(jm, test_repository, sample_resultset,
mock_post_json):
"""
test posting data to the resultset endpoint via webtest.
extected result are:
- return code 200
- return message successful
- 1 resultset stored in the jobs schema
"""
# store the first two, so we submit all, but should properly not re-
# add the others.
jm.store_result_set_data(sample_resultset[:2])
trsc = TreeherderResultSetCollection()
exp_revision_hashes = set()
for rs in sample_resultset:
rs.update({'author': 'John Doe'})
result_set = trsc.get_resultset(rs)
trsc.add(result_set)
exp_revision_hashes.add(rs["revision"])
resp = test_utils.post_collection(jm.project, trsc)
act_revision_hashes = {x["long_revision"] for x in resp.json["resultsets"]}
assert exp_revision_hashes == act_revision_hashes
stored_objs = jm.get_dhub().execute(
proc="jobs_test.selects.resultset_by_long_revision",
placeholders=[sample_resultset[0]['revision']]
)
assert len(stored_objs) == 1
assert stored_objs[0]['long_revision'] == sample_resultset[0]['revision']
示例7: test_resultset_collection
def test_resultset_collection(self):
"""Confirm the collection matches the sample data"""
trc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trs = TreeherderResultSet(resultset)
trc.add(trs)
self.assertTrue(len(self.resultset_data) == len(trc.data))
示例8: test_resultset_with_bad_key
def test_resultset_with_bad_key(sample_resultset, jm, initial_data):
trsc = TreeherderResultSetCollection()
for rs in sample_resultset:
rs = trsc.get_resultset(rs)
trsc.add(rs)
resp = test_utils.post_collection(
jm.project, trsc, status=403, consumer_key="horrible-key"
)
assert resp.status_int == 403
assert resp.json['detail'] == 'oauth_consumer_key does not match credentials for project {0}'.format(jm.project)
示例9: test_resultset_with_bad_secret
def test_resultset_with_bad_secret(sample_resultset, jm, initial_data):
trsc = TreeherderResultSetCollection()
for rs in sample_resultset:
rs = trsc.get_resultset(rs)
trsc.add(rs)
resp = test_utils.post_collection(
jm.project, trsc, status=403, consumer_secret="horrible secret"
)
assert resp.status_int == 403
assert resp.json['detail'] == "Client authentication failed for project {0}".format(jm.project)
示例10: test_send_result_collection
def test_send_result_collection(self, mock_post):
"""Can add a treeherder collections to a TreeherderRequest."""
mock_post.return_value = self._expected_response_return_object()
trc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trc.add(trc.get_resultset(resultset))
client = TreeherderClient(protocol="http", host="host")
auth = TreeherderAuth("key", "secret", "project")
client.post_collection("project", trc, auth=auth)
path, resp = mock_post.call_args
self.assertEqual(mock_post.call_count, 1)
self.assertEqual(trc.get_collection_data(), resp["json"])
示例11: test_send_result_collection
def test_send_result_collection(self):
"""Can add a treeherder collections to a TreeherderRequest."""
trc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trc.add(trc.get_resultset(resultset))
client = TreeherderClient(protocol="http", host="host", client_id="client-abc", secret="secret123")
def request_callback(request):
# Check that the expected content was POSTed.
posted_json = json.loads(request.body)
self.assertEqual(posted_json, trc.get_collection_data())
return (200, {}, '{"message": "well-formed JSON stored", "resultsets": [123, 456]}')
url = client._get_project_uri("project", trc.endpoint_base)
responses.add_callback(
responses.POST, url, match_querystring=True, callback=request_callback, content_type="application/json"
)
client.post_collection("project", trc)
示例12: test_resultset_sample_data
def test_resultset_sample_data(self):
"""Test all add methods for building result sets"""
trsc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trs = TreeherderResultSet()
trs.add_push_timestamp(resultset["push_timestamp"])
trs.add_revision(resultset["revision"])
trs.add_author(resultset["author"])
trs.add_type("push")
revisions = []
for revision in resultset["revisions"]:
tr = TreeherderRevision()
tr.add_revision(revision["revision"])
tr.add_author(revision["author"])
tr.add_comment(revision["comment"])
tr.add_repository(revision["repository"])
revisions.append(tr)
trs.add_revisions(revisions)
self.compare_structs(trs.data, resultset)
trsc.add(trs)
# confirm we get the same thing if we initialize from
# a resultset dict
trs_struct = TreeherderResultSet(resultset)
self.compare_structs(trs_struct.data, resultset)
示例13: test_send_result_collection
def test_send_result_collection(self, mock_send):
"""Can add a treeherder collections to a TreeherderRequest."""
trc = TreeherderResultSetCollection()
for resultset in self.resultset_data:
trc.add(trc.get_resultset(resultset))
req = TreeherderRequest(
protocol='http',
host='host',
project='project',
oauth_key='key',
oauth_secret='secret',
)
req.post(trc)
self.assertEqual(mock_send.call_count, 1)
self.assertEqual(
trc.to_json(),
mock_send.call_args_list[0][1]['data']
)