Skip to content

Instantly share code, notes, and snippets.

@camd
Created July 15, 2014 19:14
Show Gist options
  • Save camd/ed9480625c36f0c48e09 to your computer and use it in GitHub Desktop.
Save camd/ed9480625c36f0c48e09 to your computer and use it in GitHub Desktop.
log_parser mock test
def test_bug_suggestions_artifact(jm, initial_data, jobs_with_local_log,
sample_resultset, mock_send_request,
monkeypatch):
"""
check that at least 2 job_artifacts get inserted when running
a parse_log task
"""
def mock_get_bug_suggestions(search, status, base_uri):
return []
monkeypatch.setattr(utils, 'get_bugs_for_search_term', mock_get_bug_suggestions)
jm.store_result_set_data(sample_resultset)
jobs = jobs_with_local_log
for job in jobs:
# make this a failing job, so use error log processing
job['job']['result'] = "testfailed"
job['revision_hash'] = sample_resultset[0]['revision_hash']
jm.store_job_data(jobs)
jm.process_objects(1, raise_errors=True)
job_id = jm.get_jobs_dhub().execute(
proc="jobs_test.selects.row_by_guid",
placeholders=[jobs[0]['job']['job_guid']]
)[0]['id']
job_artifacts = jm.get_jobs_dhub().execute(
proc="jobs_test.selects.job_artifact",
placeholders=[job_id]
)
jm.disconnect()
# we must have at least 2 artifacts: one for the log viewer and another one
# for the job artifact panel
assert len(job_artifacts) >= 2
assert False, json.dumps(job_artifacts, indent=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment