Fix for issue #33
This commit is contained in:
Родитель
7a2b8441a9
Коммит
b62f6d834b
|
@ -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())})
|
||||
|
|
Загрузка…
Ссылка в новой задаче