Skip to content

Commit

Permalink
Update messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Aug 29, 2017
1 parent dc758e3 commit 7e88e74
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 43 deletions.
16 changes: 16 additions & 0 deletions pollbot/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,19 @@ async def heartbeat():
return True
return False
return heartbeat


def build_task_response(status, exists_message, missing_message, link):
if status:
# Exists
return {
"status": "exists",
"message": exists_message,
"link": link
}
else:
return {
"status": "missing",
"message": missing_message,
"link": link
}
19 changes: 8 additions & 11 deletions pollbot/tasks/archives.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import partial
from pollbot.utils import build_version_id, Channel, get_version_channel, get_version_from_filename
from . import get_session, heartbeat_factory
from . import get_session, heartbeat_factory, build_task_response


async def archives(product, version):
Expand All @@ -12,11 +12,10 @@ async def archives(product, version):
url = 'https://archive.mozilla.org/pub/{}/releases/{}/'.format(product, version)
async with session.get(url) as resp:
status = resp.status != 404
return {
"status": status and "exists" or "missing",
"message": "Checking archive.mozilla.org release publication",
"link": url
}
exists_message = "An archive for version {} exists at {}".format(version, url)
missing_message = ("No archive found for this version number at "
"https://archive.mozilla.org/pub/{}/releases/".format(product))
return build_task_response(status, exists_message, missing_message, url)


async def check_nightly_archives(url, product, version):
Expand All @@ -36,11 +35,9 @@ async def check_nightly_archives(url, product, version):
last_release = get_version_from_filename(files[0][1])
status = build_version_id(last_release) >= build_version_id(version)

return {
"status": status and "exists" or "missing",
"message": "Checking archive.mozilla.org nightly publication",
"link": url
}
exists_message = "The archive exists at {}".format(url)
missing_message = "No archive exists at {}".format(url)
return build_task_response(status, exists_message, missing_message, url)
else:
return {
"status": "missing",
Expand Down
29 changes: 12 additions & 17 deletions pollbot/tasks/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pollbot.exceptions import TaskError
from pollbot.utils import build_version_id, Channel, get_version_channel, get_version_from_filename
from . import get_session, heartbeat_factory
from . import get_session, heartbeat_factory, build_task_response


async def get_releases(product):
Expand Down Expand Up @@ -36,11 +36,9 @@ async def release_notes(product, version):
with get_session() as session:
async with session.get(url) as resp:
status = resp.status != 404
return {
"status": status and "exists" or "missing",
"message": "Checking bedrock for release note publication",
"link": url
}
exists_message = "Release notes were found for version {}".format(version)
missing_message = "No release notes were published for version {}".format(version)
return build_task_response(status, exists_message, missing_message, url)


async def security_advisories(product, version):
Expand All @@ -51,7 +49,8 @@ async def security_advisories(product, version):
if channel in (Channel.BETA, Channel.NIGHTLY):
return {
"status": "missing",
"message": "No security advisories for {} releases".format(channel.value.lower()),
"message": "Security advisories are never published for {} releases".format(
channel.value.lower()),
"link": url
}

Expand All @@ -70,11 +69,9 @@ async def security_advisories(product, version):
else:
last_release = d("html").attr('data-latest-firefox')
status = build_version_id(last_release) >= build_version_id(version)
return {
"status": status and "exists" or "missing",
"message": "Checking bedrock for security advisories publication",
"link": url
}
message = ("Security advisories for release were "
"published up to version {}".format(last_release))
return build_task_response(status, message, message, url)


async def download_links(product, version):
Expand Down Expand Up @@ -115,11 +112,9 @@ async def download_links(product, version):
last_release = d("html").attr('data-latest-firefox')

status = build_version_id(last_release) >= build_version_id(version)
return {
"status": status and "exists" or "missing",
"message": "Checking bedrock for download links publication",
"link": url
}
message = ("The download links for release have been published for version {}".format(
last_release))
return build_task_response(status, message, message, url)


heartbeat = heartbeat_factory('https://www.mozilla.org/en-US/firefox/all/')
15 changes: 8 additions & 7 deletions pollbot/tasks/product_details.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pollbot.exceptions import TaskError
from pollbot.utils import Channel, get_version_channel, build_version_id
from . import get_session, heartbeat_factory
from . import get_session, heartbeat_factory, build_task_response


async def ongoing_versions(product):
Expand Down Expand Up @@ -33,15 +33,16 @@ async def product_details(product, version):
url = 'https://product-details.mozilla.org/1.0/{}.json'.format(product)
async with session.get(url) as resp:
if resp.status != 200:
msg = 'Product Details info not available ({})'.format(resp.status)
msg = 'We were unable to contact product-details (HTTP {})'.format(resp.status)
raise TaskError(msg)
body = await resp.json()
status = '{}-{}'.format(product, version) in body['releases']
return {
"status": status and "exists" or "missing",
"message": "Checking product-details for the release version",
"link": url
}

exists_message = "We found product-details information about version {}".format(
version)
missing_message = "We did not found product-details information about version".format(
version)
return build_task_response(status, exists_message, missing_message, url)


heartbeat = heartbeat_factory('https://product-details.mozilla.org/1.0/firefox.json')
2 changes: 1 addition & 1 deletion tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ async def test_product_details_tasks_returns_error_if_error(self):

with pytest.raises(TaskError) as excinfo:
await product_details('firefox', '54.0')
assert str(excinfo.value) == 'Product Details info not available (404)'
assert str(excinfo.value) == 'We were unable to contact product-details (HTTP 404)'

async def test_failing_heartbeat(self):
# Archive
Expand Down
17 changes: 10 additions & 7 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ async def test_get_checks_response_validates_product_name(cli):
async def test_release_archive_date(cli):
await check_response(cli, "/v1/firefox/57.0a1/archive-date", body={
"status": "exists",
"message": "Checking archive.mozilla.org nightly publication",
"message": "The archive exists at "
"https://archive.mozilla.org/pub/firefox/nightly/latest-date/",
"link": "https://archive.mozilla.org/pub/firefox/nightly/latest-date/"
})

Expand All @@ -246,7 +247,8 @@ async def test_release_archive_date_with_wrong_version_number(cli):
async def test_release_archive_date_l10n(cli):
await check_response(cli, "/v1/firefox/57.0a1/archive-date-l10n", body={
"status": "exists",
"message": "Checking archive.mozilla.org nightly publication",
"message": "The archive exists at "
"https://archive.mozilla.org/pub/firefox/nightly/latest-date-l10n/",
"link": "https://archive.mozilla.org/pub/firefox/nightly/latest-date-l10n/"
})

Expand All @@ -262,39 +264,40 @@ async def test_release_archive_date_l10n_with_wrong_version_number(cli):
async def test_release_archive(cli):
await check_response(cli, "/v1/firefox/54.0/archive", body={
"status": "exists",
"message": "Checking archive.mozilla.org release publication",
"message": "An archive for version 54.0 exists at "
"https://archive.mozilla.org/pub/firefox/releases/54.0/",
"link": "https://archive.mozilla.org/pub/firefox/releases/54.0/"
})


async def test_release_bedrock_release_notes(cli):
await check_response(cli, "/v1/firefox/54.0/bedrock/release-notes", body={
"status": "exists",
"message": "Checking bedrock for release note publication",
"message": "Release notes were found for version 54.0",
"link": "https://www.mozilla.org/en-US/firefox/54.0/releasenotes/"
})


async def test_release_bedrock_security_advisories(cli):
await check_response(cli, "/v1/firefox/54.0/bedrock/security-advisories", body={
"status": "exists",
"message": "Checking bedrock for security advisories publication",
"message": "Security advisories for release were published up to version 55.0.3",
"link": "https://www.mozilla.org/en-US/security/known-vulnerabilities/firefox/"
})


async def test_release_bedrock_download_links(cli):
await check_response(cli, "/v1/firefox/54.0/bedrock/download-links", body={
"status": "exists",
"message": "Checking bedrock for download links publication",
"message": "The download links for release have been published for version 55.0.3",
"link": "https://www.mozilla.org/en-US/firefox/all/"
})


async def test_release_product_details(cli):
await check_response(cli, "/v1/firefox/54.0/product-details", body={
"status": "exists",
"message": "Checking product-details for the release version",
"message": "We found product-details information about version 54.0",
"link": "https://product-details.mozilla.org/1.0/firefox.json"
})

Expand Down

0 comments on commit 7e88e74

Please sign in to comment.