Skip to content
Merged
13 changes: 9 additions & 4 deletions backend/code_coverage_backend/hgmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@

__hgmo: Dict[str, Tuple[int, float]] = {}

HGMO_REVISION_URL = "https://hg.mozilla.org/{repository}/json-rev/{revision}"
HGMO_REVISION_URL = (
"https://hg.mozilla.org/{repository}/json-automationrelevance/{revision}"
)
HGMO_PUSHES_URL = "https://hg.mozilla.org/{repository}/json-pushes"


Expand All @@ -29,9 +31,12 @@ def hgmo_revision_details(repository, changeset):
url = HGMO_REVISION_URL.format(repository=repository, revision=changeset)
resp = requests.get(url)
resp.raise_for_status()
data = resp.json()
assert "pushid" in data, "Missing pushid"
out = data["pushid"], data["date"][0]
if resp.json().get("changesets") is None:
out = -1, 1
else:
data = resp.json()["changesets"][-1]
assert "pushid" in data, "Missing pushid"
out = data["pushid"], data["date"][0]

# Store in cache
__hgmo[key] = out
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def mock_hgmo():

def _test_rev(request):
# The push id is in the first 3 characters of the revision requested
revision = request.path_url[17:]
revision = request.path_url[33:]
assert len(revision) == 32
resp = {"pushid": int(revision[:3]), "date": [time.time(), 0]}
return (200, headers, json.dumps(resp))
Expand Down Expand Up @@ -185,7 +185,7 @@ def _test_pushes(request):
with responses.RequestsMock(assert_all_requests_are_fired=False) as resps:
resps.add_callback(
responses.GET,
re.compile("https://hg.mozilla.org/(.+)/json-rev/(.+)"),
re.compile("https://hg.mozilla.org/(.+)/json-automationrelevance/(.+)"),
callback=_test_rev,
)
resps.add_callback(
Expand Down