This commit is contained in:
Victor Ng 2018-03-07 12:38:51 -05:00
Родитель 7a2b8441a9
Коммит b62f6d834b
2 изменённых файлов: 16 добавлений и 0 удалений

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

@ -31,6 +31,9 @@ def recommendations(request, client_id):
branch = request.GET.get('branch', '')
if branch.endswith('-taar'):
branch = branch.replace("-taar", "")
if branch not in VALID_BRANCHES:
# Force branch to be a control branch if an invalid request
# comes in.

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

@ -131,6 +131,12 @@ def test_linear_branch(dummy_cache, client, static_recommendation_manager):
expected = b'{"results": ["linear-addon-1", "linear-addon-2", "linear-addon-N"]}'
assert response.content == expected
response = client.get(url + "?branch=linear-taar")
assert response.status_code == 200
assert response['Content-Type'] == 'application/json'
expected = b'{"results": ["linear-addon-1", "linear-addon-2", "linear-addon-N"]}'
assert response.content == expected
def test_ensemble_branch(dummy_cache, client, static_recommendation_manager):
url = reverse('recommendations', kwargs={'client_id': str(uuid.uuid4())})
@ -140,6 +146,13 @@ def test_ensemble_branch(dummy_cache, client, static_recommendation_manager):
expected = b'{"results": ["ensemble-addon-1", "ensemble-addon-2", "ensemble-addon-N"]}'
assert response.content == expected
url = reverse('recommendations', kwargs={'client_id': str(uuid.uuid4())})
response = client.get(url + "?branch=ensemble-taar")
assert response.status_code == 200
assert response['Content-Type'] == 'application/json'
expected = b'{"results": ["ensemble-addon-1", "ensemble-addon-2", "ensemble-addon-N"]}'
assert response.content == expected
def test_control_branch(dummy_cache, client, static_recommendation_manager):
url = reverse('recommendations', kwargs={'client_id': str(uuid.uuid4())})