Added another test for client_id+addon_id lookup

Tests now differentiate between failure to find a client_id and
a failure to find an addon for a found client_id.
This commit is contained in:
Victor Ng 2019-04-29 13:40:04 -04:00
Родитель 3f8e588f29
Коммит ff4ff1371b
2 изменённых файлов: 23 добавлений и 5 удалений

Просмотреть файл

@ -86,7 +86,11 @@ def configure_plugin(app): # noqa: C901
if client_meta is None:
# no valid client metadata was found for the given
# clientId
return False
result = {"results": False, 'error': 'No client found'}
response = app.response_class(
response=json.dumps(result), status=200, mimetype="application/json"
)
return response
result = {"results": addon_id in client_meta.get("installed_addons", [])}
response = app.response_class(

Просмотреть файл

@ -284,7 +284,7 @@ def test_overlapping_mixed_and_promoted_and_taar_adodns(
assert res.json == expected
def test_client_has_no_addon(client, profile_enabled_rm):
def test_client_addon_lookup_no_client(client, profile_enabled_rm):
"""
test that we can see if a client has an addon installed
"""
@ -296,9 +296,8 @@ def test_client_has_no_addon(client, profile_enabled_rm):
)
res = client.get(url, follow_redirects=True)
# The result should order the GUIDs in descending order of weight
expected = {"results": False}
assert res.json == expected
assert res.json['results'] == False
def test_client_has_addon(client, profile_enabled_rm):
@ -314,6 +313,21 @@ def test_client_has_addon(client, profile_enabled_rm):
)
res = client.get(url, follow_redirects=True)
# The result should order the GUIDs in descending order of weight
expected = {"results": True}
assert res.json == expected
def test_client_has_no_addon(client, profile_enabled_rm):
"""
test that we can see if a client has an addon installed
"""
hashed_client_id = hasher(uuid.uuid4())
addon_id = "addon_984932434"
url = url_for(
"client_has_addon", hashed_client_id=hashed_client_id, addon_id=addon_id
)
res = client.get(url, follow_redirects=True)
assert res.json['results'] == False