本文整理汇总了Python中tests.test_utils.post_collection函数的典型用法代码示例。如果您正苦于以下问题:Python post_collection函数的具体用法?Python post_collection怎么用?Python post_collection使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了post_collection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_post_job_with_buildapi_artifact
def test_post_job_with_buildapi_artifact(test_repository, failure_classifications,
result_set_stored,
mock_post_json):
"""
test submitting a job with a buildapi artifact gets that stored (and
we update the job object)
"""
tjc = client.TreeherderJobCollection()
job_guid = 'd22c74d4aa6d2a1dcba96d95dccbd5fdca70cf33'
tj = client.TreeherderJob({
'project': test_repository.name,
'revision': result_set_stored[0]['revision'],
'job': {
'artifacts': [],
'job_guid': job_guid,
'state': 'completed',
}
})
tj.add_artifact("buildapi", "json",
json.dumps({"buildername": "Windows 8 64-bit cheezburger",
"request_id": 1234}))
tjc.add(tj)
post_collection(test_repository.name, tjc)
assert Job.objects.count() == 1
assert JobDetail.objects.count() == 1
buildbot_request_id_detail = JobDetail.objects.all()[0]
assert buildbot_request_id_detail.title == 'buildbot_request_id'
assert buildbot_request_id_detail.value == str(1234)
assert buildbot_request_id_detail.url is None
示例2: test_post_job_with_text_log_summary_and_bug_suggestions_artifact
def test_post_job_with_text_log_summary_and_bug_suggestions_artifact(
test_project,
monkeypatch,
result_set_stored,
mock_post_json,
mock_error_summary,
text_log_summary_dict,
):
"""
test submitting a job with a pre-parsed log and both artifacts
does not generate parse the log or generate any artifacts, just uses
the supplied ones.
"""
mock_parse = MagicMock(name="parse_line")
monkeypatch.setattr(StepParser, 'parse_line', mock_parse)
mock_get_error_summary = MagicMock(name="get_error_summary_artifacts")
monkeypatch.setattr(error_summary, 'get_error_summary_artifacts', mock_get_error_summary)
error_summary_blob = ["fee", "fie", "foe", "fum"]
job_guid = 'd22c74d4aa6d2a1dcba96d95dccbd5fdca70cf33'
tjc = client.TreeherderJobCollection()
tj = client.TreeherderJob({
'project': test_project,
'revision': result_set_stored[0]['revision'],
'job': {
'job_guid': job_guid,
'state': 'completed',
'log_references': [{
'url': 'http://ftp.mozilla.org/pub/mozilla.org/spidermonkey/...',
'name': 'buildbot_text',
'parse_status': 'parsed'
}],
'artifacts': [
{
"blob": json.dumps(text_log_summary_dict),
"type": "json",
"name": "text_log_summary",
"job_guid": job_guid
},
{
"blob": json.dumps(error_summary_blob),
"type": "json",
"name": "Bug suggestions",
"job_guid": job_guid
},
]
}
})
tjc.add(tj)
post_collection(test_project, tjc)
check_artifacts(test_project, job_guid, 'parsed', 2,
{'Bug suggestions', 'text_log_summary'}, error_summary_blob)
assert mock_parse.called is False
assert mock_get_error_summary.called is False
示例3: 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])
示例4: 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()
示例5: test_post_talos_artifact
def test_post_talos_artifact(test_project, test_repository, result_set_stored,
mock_post_json):
test_repository.save()
tjc = client.TreeherderJobCollection()
job_guid = 'd22c74d4aa6d2a1dcba96d95dccbd5fdca70cf33'
tj = client.TreeherderJob({
'project': test_repository.name,
'revision_hash': result_set_stored[0]['revision_hash'],
'job': {
'job_guid': job_guid,
'state': 'completed',
'project': test_repository.name,
'option_collection': {'opt': True},
'artifacts': [{
'blob': {'talos_data': SampleData.get_minimal_talos_perf_data()},
'type': 'json',
'name': 'talos_data',
'job_guid': job_guid
}]
}
})
tjc.add(tj)
post_collection(test_project, tjc)
# we'll just validate that we got the expected number of results for
# talos (we have validation elsewhere for the actual data adapters)
assert PerformanceSignature.objects.count() == 1
assert PerformanceDatum.objects.count() == 1
示例6: running_jobs_stored
def running_jobs_stored(
jm, running_jobs, result_set_stored):
"""
stores a list of buildapi running jobs into the objectstore
"""
running_jobs.update(result_set_stored[0])
tjc = TreeherderJobCollection(job_type='update')
tj = tjc.get_job(running_jobs)
tjc.add(tj)
test_utils.post_collection(jm.project, tjc)
示例7: completed_jobs_stored
def completed_jobs_stored(
jm, completed_jobs, result_set_stored, mock_send_request):
"""
stores a list of buildapi completed jobs into the objectstore
"""
completed_jobs['revision_hash'] = result_set_stored[0]['revision_hash']
tjc = TreeherderJobCollection()
tj = tjc.get_job(completed_jobs)
tjc.add(tj)
test_utils.post_collection(jm.project, tjc)
示例8: completed_jobs_stored
def completed_jobs_stored(
jm, completed_jobs, result_set_stored, mock_post_json):
"""
stores a list of buildapi completed jobs
"""
completed_jobs['revision'] = result_set_stored[0]['revision']
completed_jobs.update({'project': jm.project})
tjc = TreeherderJobCollection()
tj = tjc.get_job(completed_jobs)
tjc.add(tj)
test_utils.post_collection(jm.project, tjc)
示例9: running_jobs_stored
def running_jobs_stored(
jm, running_jobs, result_set_stored, mock_post_json):
"""
stores a list of buildapi running jobs
"""
running_jobs.update(result_set_stored[0])
running_jobs.update({'project': jm.project})
tjc = TreeherderJobCollection()
tj = tjc.get_job(running_jobs)
tjc.add(tj)
test_utils.post_collection(jm.project, tjc)
示例10: pending_jobs_stored
def pending_jobs_stored(
jm, pending_jobs, result_set_stored):
"""
stores a list of buildapi pending jobs into the jobs store
using BuildApiTreeHerderAdapter
"""
pending_jobs.update(result_set_stored[0])
tjc = TreeherderJobCollection(job_type='update')
tj = tjc.get_job(pending_jobs)
tjc.add(tj)
test_utils.post_collection(jm.project, tjc)
示例11: running_jobs_stored
def running_jobs_stored(
test_repository, failure_classifications, running_jobs,
result_set_stored, mock_post_json):
"""
stores a list of buildapi running jobs
"""
running_jobs.update(result_set_stored[0])
running_jobs.update({'project': test_repository.name})
tjc = TreeherderJobCollection()
tj = tjc.get_job(running_jobs)
tjc.add(tj)
test_utils.post_collection(test_repository.name, tjc)
示例12: completed_jobs_stored
def completed_jobs_stored(
test_repository, failure_classifications, completed_jobs,
result_set_stored, mock_post_json):
"""
stores a list of buildapi completed jobs
"""
completed_jobs['revision'] = result_set_stored[0]['revision']
completed_jobs.update({'project': test_repository.name})
tjc = TreeherderJobCollection()
tj = tjc.get_job(completed_jobs)
tjc.add(tj)
test_utils.post_collection(test_repository.name, tjc)
示例13: test_post_job_with_text_log_summary_artifact_pending
def test_post_job_with_text_log_summary_artifact_pending(
test_repository,
failure_classifications,
result_set_stored,
monkeypatch,
mock_post_json,
text_log_summary_dict,
):
"""
test submitting a job with a log set to pending, but with a text_log_summary.
This should detect the artifact, not parse, and just mark the log as parsed,
then generate bug suggestions.
"""
mock_parse = MagicMock(name="parse_line")
monkeypatch.setattr(StepParser, 'parse_line', mock_parse)
job_guid = 'd22c74d4aa6d2a1dcba96d95dccbd5fdca70cf33'
tjc = client.TreeherderJobCollection()
tj = client.TreeherderJob({
'project': test_repository.name,
'revision': result_set_stored[0]['revision'],
'job': {
'job_guid': job_guid,
'state': 'completed',
'log_references': [{
'url': 'http://ftp.mozilla.org/pub/mozilla.org/spidermonkey/...',
'name': 'buildbot_text',
'parse_status': 'pending'
}],
'artifacts': [{
"blob": json.dumps(text_log_summary_dict),
"type": "json",
"name": "text_log_summary",
"job_guid": job_guid
}]
}
})
tjc.add(tj)
post_collection(test_repository.name, tjc)
# should have 4 error summary lines (aka bug suggestions)
assert len(get_error_summary(Job.objects.get(guid=job_guid))) == 4
# ensure the parsing didn't happen
assert mock_parse.called is False
示例14: test_objectstore_create
def test_objectstore_create(job_sample, jm):
"""
test posting data to the objectstore via webtest.
extected result are:
- return code 200
- return message successful
- 1 job stored in the objectstore
"""
tjc = TreeherderJobCollection()
tj = tjc.get_job(job_sample)
tjc.add(tj)
resp = test_utils.post_collection(jm.project, tjc)
assert resp.status_int == 200
assert resp.json['message'] == 'well-formed JSON stored'
stored_objs = jm.get_os_dhub().execute(
proc="objectstore_test.selects.row_by_guid",
placeholders=[job_sample["job"]["job_guid"]]
)
assert len(stored_objs) == 1
assert stored_objs[0]['job_guid'] == job_sample["job"]["job_guid"]
jm.disconnect()
示例15: 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()