Skip to content

Commit

Permalink
Revert bfef91b (Bug 1080760 - Tests for bug suggestion artifact changes)
Browse files Browse the repository at this point in the history
Since we're about to revert the functionality it tests.
  • Loading branch information
Ed Morley committed May 3, 2015
1 parent 765ecbe commit 0530a8b
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 331 deletions.
4 changes: 2 additions & 2 deletions tests/log_parser/test_utils.py
Expand Up @@ -3,8 +3,8 @@
# file, you can obtain one at http://mozilla.org/MPL/2.0/.

import pytest
from treeherder.model.bug_suggestions import (get_error_search_term,
get_crash_signature)
from treeherder.log_parser.utils import (get_error_search_term,
get_crash_signature)


PIPE_DELIMITED_LINE_TEST_CASES = (
Expand Down
262 changes: 0 additions & 262 deletions tests/sample_data/artifacts/text_log_summary.json

This file was deleted.

4 changes: 0 additions & 4 deletions tests/sampledata.py
Expand Up @@ -57,10 +57,6 @@ def __init__(self):
os.path.dirname(__file__))) as f:
self.job_artifact = f.readlines()

with open("{0}/sample_data/artifacts/text_log_summary.json".format(
os.path.dirname(__file__))) as f:
self.text_log_summary = json.load(f)

self.job_data = []
self.resultset_data = []

Expand Down
64 changes: 1 addition & 63 deletions tests/webapp/api/test_artifact_api.py
Expand Up @@ -2,25 +2,19 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, you can obtain one at http://mozilla.org/MPL/2.0/.

import json
import pytest

from django.core.urlresolvers import reverse

from treeherder import client

from treeherder.etl.oauth_utils import OAuthCredentials
from treeherder.model.derived import ArtifactsModel


xfail = pytest.mark.xfail


# we don't have/need an artifact list endpoint.

def test_artifact_detail(webapp, test_project, eleven_jobs_processed, sample_artifacts, jm):
"""
test retrieving a single artifact from the artifact-detail
test retrieving a single job from the jobs-detail
endpoint.
"""
job = jm.get_job_list(0, 1)[0]
Expand Down Expand Up @@ -75,59 +69,3 @@ def test_artifact_detail_bad_project(webapp, jm):
assert resp.json == {"detail": "No project with name foo"}

jm.disconnect()


def test_artifact_create_text_log_summary(webapp, eleven_jobs_processed,
mock_send_request, monkeypatch,
sample_data, jm):
"""
test creating a text_log_summary artifact which auto-generates bug suggestions
"""
bs_obj = ["foo", "bar"]

from treeherder.model import bug_suggestions

def _get_bug_suggestions(params):
return bs_obj

monkeypatch.setattr(bug_suggestions, "get_bug_suggestions", _get_bug_suggestions)

credentials = OAuthCredentials.get_credentials(jm.project)

job = jm.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)

req = client.TreeherderRequest(
protocol='http',
host='localhost',
project=jm.project,
oauth_key=credentials['consumer_key'],
oauth_secret=credentials['consumer_secret']
)

# Post the request to treeherder
resp = req.post(tac)
assert resp.status_int == 200
assert resp.body == '{"message": "Artifacts stored successfully"}'

with ArtifactsModel(jm.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 bs_obj == act_bs_obj

jm.disconnect()

0 comments on commit 0530a8b

Please sign in to comment.