Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Commit

Permalink
shipit_uplift: Add tests for some coverage functions and the extensio…
Browse files Browse the repository at this point in the history
…ns API endpoint (#871)
  • Loading branch information
gabriel-v authored and marco-c committed Feb 28, 2018
1 parent 4c0a12f commit 036c473
Show file tree
Hide file tree
Showing 6 changed files with 3,186 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/shipit_uplift/shipit_uplift/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,14 @@ def get_pushes_changesets(push_id, push_id_end):


def get_changeset_data(changeset):
if changeset not in changeset_cache:
if changeset[:12] not in changeset_cache:
r = requests.get('https://hg.mozilla.org/mozilla-central/json-rev/%s' % changeset)
rev = r.json()
push_id = int(rev['pushid'])

get_pushes(push_id)

return changeset_cache[changeset]
return changeset_cache[changeset[:12]]


def get_coverage_build(changeset):
Expand Down
24 changes: 24 additions & 0 deletions src/shipit_uplift/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,27 @@ def header_bot(app):
'''
from shipit_uplift.config import SCOPES_BOT
return hawk_header(SCOPES_BOT)


@pytest.fixture(scope='session')
def coverage_changeset_by_file():
with open(os.path.join(FIXTURES_DIR, 'coverage_changeset_by_file.json')) as f:
changeset_by_file_info = json.load(f)

for entry in changeset_by_file_info:
entry['data'] = {int(key): value for key, value in entry['data'].items()}

return changeset_by_file_info


@pytest.fixture(scope='session')
def coverage_builds():
paths = glob.glob(os.path.join(FIXTURES_DIR, 'coverage_build_*.json'))
builds = {'info': {}, 'summary': {}}
for path in sorted(paths):
with open(path) as f:
build_data = json.load(f)
builds['info'].update(build_data['info'])
builds['summary'].update(build_data['summary'])

return builds
34 changes: 34 additions & 0 deletions src/shipit_uplift/tests/fixtures/coverage_build_33333.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"info": {
"8a389e3576db8de5050999777d82aead0a8c62a9": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"diffs": [],
"git_build_changeset": "0d9139ed76e220465d06de7c4f6c2658115387a4",
"overall_cur": "59.62965",
"overall_prev": "59.62246"
},
"6d6882f5e95d7a46da4f48d903766114a4a9cc06": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"diffs": [],
"git_build_changeset": "0d9139ed76e220465d06de7c4f6c2658115387a4",
"overall_cur": "59.62965",
"overall_prev": "59.62246"
}
},
"summary": {
"8a389e3576db8de5050999777d82aead0a8c62a9": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"commit_added": 0,
"commit_covered": 0,
"overall_cur": "59.62965",
"overall_prev": "59.62246"
},
"6d6882f5e95d7a46da4f48d903766114a4a9cc06": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"commit_added": 0,
"commit_covered": 0,
"overall_cur": "59.62965",
"overall_prev": "59.62246"
}
}
}
62 changes: 62 additions & 0 deletions src/shipit_uplift/tests/fixtures/coverage_build_33334.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"info": {
"53d64a077a8ef3a34697c7aa3b0776d3e8d11539": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"diffs": [
{
"changes": [
{"coverage": "?", "line": 975},
{"coverage": "?", "line": 976},
{"coverage": "Y", "line": 978},
{"coverage": "?", "line": 979},
{"coverage": "?", "line": 980},
{"coverage": "?", "line": 981},
{"coverage": "Y", "line": 982},
{"coverage": "Y", "line": 983}
],
"name": "layout/base/ServoRestyleManager.cpp"
}
],
"git_build_changeset": "0d9139ed76e220465d06de7c4f6c2658115387a4",
"overall_cur": "59.62965",
"overall_prev": "59.62246"
},
"30d915de546242961f2f3ce4e1cfbee5ec9e54bb": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"diffs": [],
"git_build_changeset": "0d9139ed76e220465d06de7c4f6c2658115387a4",
"overall_cur": "59.62965",
"overall_prev": "59.62246"
},
"3800f2c5af262050c8bddfd999efffb46afcb081": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"diffs": [],
"git_build_changeset": "0d9139ed76e220465d06de7c4f6c2658115387a4",
"overall_cur": "59.62965",
"overall_prev": "59.62246"
}
},
"summary": {
"53d64a077a8ef3a34697c7aa3b0776d3e8d11539": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"commit_added": 3,
"commit_covered": 3,
"overall_cur": "59.62965",
"overall_prev": "59.62246"
},
"30d915de546242961f2f3ce4e1cfbee5ec9e54bb": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"commit_added": 0,
"commit_covered": 0,
"overall_cur": "59.62965",
"overall_prev": "59.62246"
},
"3800f2c5af262050c8bddfd999efffb46afcb081": {
"build_changeset": "474d58c9137360c0fa1c85cdd11e3313b33b7cad",
"commit_added": 0,
"commit_covered": 0,
"overall_cur": "59.62965",
"overall_prev": "59.62246"
}
}
}
Loading

0 comments on commit 036c473

Please sign in to comment.