Skip to content
Snippets Groups Projects
Commit 1e106c79 authored by Jayesh's avatar Jayesh :cat2:
Browse files

Missing tests for origin legacy routes

Origin legacy routes corresponds to two URLs.
Tests for the second(missing) set.
parent 5d56274d
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ def redirect_to_new_route(request, new_route):
# Send all the url_args and the request_args as query params
# eg /origin/<url:url-val>/log?path=test
# will be send as /log?url=<url-val>&path=test
args = {**request_path.kwargs, **{k: v for k, v in request.GET.items()}}
args = {**request_path.kwargs, **request.GET.dict()}
return redirect(reverse(new_route, query_params=args), permanent=True,)
......
......@@ -827,15 +827,23 @@ def test_origin_view_redirects(client, browse_context, new_origin):
@given(new_origin())
@pytest.mark.parametrize("browse_context", ["log", "branches", "releases"])
def test_origin_view_legacy_redirects(client, browse_context, new_origin):
params = {"origin_url": new_origin.url, "timestamp": "2021-01-23T22:24:10Z"}
url = reverse(
f"browse-origin-{browse_context}-legacy", url_args=params, query_params=params
)
# Each legacy route corresponds to two URL patterns, testing both
url_args = [
{"origin_url": new_origin.url},
{"origin_url": new_origin.url, "timestamp": "2021-01-23T22:24:10Z"},
]
params = {"extra-param1": "extra-param1", "extra-param2": "extra-param2"}
for each_arg in url_args:
url = reverse(
f"browse-origin-{browse_context}-legacy",
url_args=each_arg,
query_params=params,
)
resp = check_html_get_response(client, url, status_code=301)
assert resp["location"] == reverse(
f"browse-snapshot-{browse_context}", query_params=params
)
resp = check_html_get_response(client, url, status_code=301)
assert resp["location"] == reverse(
f"browse-snapshot-{browse_context}", query_params={**each_arg, **params}
)
def _origin_content_view_test_helper(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment