예제 #1
0
def test_artifact_create_text_log_summary(webapp, test_project, eleven_jobs_stored,
                                          mock_post_json, mock_error_summary,
                                          sample_data):
    """
    test submitting a text_log_summary artifact which auto-generates bug suggestions
    """
    with JobsModel(test_project) as jobs_model:
        job = jobs_model.get_job_list(0, 1)[0]
    tls = sample_data.text_log_summary

    tac = client.TreeherderArtifactCollection()
    ta = client.TreeherderArtifact({
        'type': 'json',
        'name': 'text_log_summary',
        'blob': json.dumps(tls['blob']),
        'job_guid': job['job_guid']
    })
    tac.add(ta)

    cli = client.TreeherderClient(protocol='http', host='localhost')
    cli.post_collection(test_project,  tac)

    with ArtifactsModel(test_project) as artifacts_model:
        artifacts = artifacts_model.get_job_artifact_list(0, 10, conditions={
            'job_id': {('=', job["id"])}
        })

    artifact_names = {x['name'] for x in artifacts}
    act_bs_obj = [x['blob'] for x in artifacts if x['name'] == 'Bug suggestions'][0]

    assert set(artifact_names) == {'Bug suggestions', 'text_log_summary'}
    assert mock_error_summary == act_bs_obj
예제 #2
0
def test_artifact_create_text_log_summary(webapp, test_project, test_job,
                                          mock_post_json, sample_data):
    """
    test submitting a text_log_summary artifact creates some text log summary objects
    """
    tls = sample_data.text_log_summary

    # assert that we had no text log objects before this operation
    assert not TextLogStep.objects.filter(job=test_job).exists()

    tac = client.TreeherderArtifactCollection()
    ta = client.TreeherderArtifact({
        'type': 'json',
        'name': 'text_log_summary',
        'blob': json.dumps(tls['blob']),
        'job_guid': test_job.guid
    })
    tac.add(ta)

    cli = client.TreeherderClient(server_url='http://localhost')
    cli.post_collection(test_project, tac)

    # assert we generated some objects
    assert TextLogStep.objects.filter(job=test_job).count() > 0
    assert TextLogError.objects.filter(step__job=test_job).count() > 0
예제 #3
0
def do_post_collection(project, collection):
    # assume if there were no exceptions we're ok
    cli = client.TreeherderClient(protocol='http', host='localhost')
    credentials = OAuthCredentials.get_credentials(project)
    auth = TreeherderAuth(credentials['consumer_key'],
                          credentials['consumer_secret'], project)

    cli.post_collection(project, collection, auth=auth)
예제 #4
0
def test_artifact_create_text_log_summary_and_bug_suggestions(
        webapp, test_project, eleven_jobs_stored, mock_post_json,
        mock_error_summary, sample_data):
    """
    test submitting text_log_summary and Bug suggestions artifacts

    This should NOT generate a Bug suggestions artifact, just post the one
    submitted.
    """

    with JobsModel(test_project) as jobs_model:
        job = jobs_model.get_job_list(0, 1)[0]
    tls = sample_data.text_log_summary
    bs_blob = ["flim", "flam"]

    tac = client.TreeherderArtifactCollection()
    tac.add(
        client.TreeherderArtifact({
            'type': 'json',
            'name': 'text_log_summary',
            'blob': json.dumps(tls['blob']),
            'job_guid': job['job_guid']
        }))
    tac.add(
        client.TreeherderArtifact({
            'type': 'json',
            'name': 'Bug suggestions',
            'blob': bs_blob,
            'job_guid': job['job_guid']
        }))

    credentials = OAuthCredentials.get_credentials(test_project)
    auth = TreeherderAuth(credentials['consumer_key'],
                          credentials['consumer_secret'], test_project)
    cli = client.TreeherderClient(protocol='http', host='localhost', auth=auth)
    cli.post_collection(test_project, tac)

    with ArtifactsModel(test_project) as artifacts_model:
        artifacts = artifacts_model.get_job_artifact_list(
            0, 10, conditions={'job_id': {('=', job["id"])}})

    assert len(artifacts) == 2
    artifact_names = {x['name'] for x in artifacts}
    act_bs_obj = [
        x['blob'] for x in artifacts if x['name'] == 'Bug suggestions'
    ][0]

    assert set(artifact_names) == {'Bug suggestions', 'text_log_summary'}
    assert bs_blob == act_bs_obj