Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémy HUBSCHER committed Sep 18, 2017
1 parent 3a738df commit 2582909
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pollbot/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def build_task_response(status, link, message, fail_message=None):
if isinstance(status, bool):
if not fail_message:
fail_message = message
status = Status.EXISTS if status else Status.MISSING
message = message if status else fail_message
status = Status.EXISTS if status else Status.MISSING

return {
"status": status.value,
Expand Down
5 changes: 3 additions & 2 deletions pollbot/tasks/product_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ async def product_details(product, version):

exists_message = "We found product-details information about version {}".format(
version)
missing_message = "We did not 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, url, exists_message, missing_message)


Expand Down
3 changes: 3 additions & 0 deletions tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,13 +465,16 @@ async def test_product_details_tasks_returns_true_if_present(self):

received = await product_details('firefox', '52.0')
assert received["status"] == Status.EXISTS.value
assert received["message"] == "We found product-details information about version 52.0"

async def test_product_details_tasks_returns_false_if_absent(self):
url = 'https://product-details.mozilla.org/1.0/firefox.json'
self.mocked.get(url, status=200, body=json.dumps({"releases": {"firefox-52.0": {}}}))

received = await product_details('firefox', '54.0')
assert received["status"] == Status.MISSING.value
assert received["message"] == (
"We did not found product-details information about version 54.0")

async def test_product_details_tasks_returns_error_if_error(self):
url = 'https://product-details.mozilla.org/1.0/firefox.json'
Expand Down

0 comments on commit 2582909

Please sign in to comment.