Skip to content

Commit

Permalink
tests adapted
Browse files Browse the repository at this point in the history
  • Loading branch information
burnout87 committed Nov 19, 2024
1 parent af89236 commit 7a286d3
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions tests/test_server_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1714,24 +1714,18 @@ def test_arg_file(dispatcher_live_fixture, dispatcher_test_conf, public_download
file_hash = make_hash_file(p_file_path)
dpars = urlencode(dict(file_list=file_hash,
_is_mmoda_url=True,
return_archive=False,
token=encoded_token))
return_archive=False))
local_download_url = f"{os.path.join(products_host_port, 'download_file')}?{dpars}"

assert arg_download_url == local_download_url

if public_download_request:
url_parts = urlparse(arg_download_url)
url_args = parse_qs(url_parts.query)
del url_args['token']
new_url_parts = url_parts._replace(query=urlencode(url_args, doseq=True))
arg_download_url = urlunparse(new_url_parts)
c = requests.get(arg_download_url)
assert c.status_code == 403
jdata = c.json()
assert jdata['exit_status']['message'] == "User cannot access the file"
else:
# arg_download_url += f'&token={encoded_token}'
arg_download_url += f'&token={encoded_token}'
c = requests.get(arg_download_url)
assert c.status_code == 200
with open(p_file_path) as p_file:
Expand Down Expand Up @@ -1793,8 +1787,7 @@ def test_arg_file_external_product_url(dispatcher_live_fixture_with_external_pro
file_hash = make_hash_file(p_file_path)
dpars = urlencode(dict(file_list=file_hash,
_is_mmoda_url=True,
return_archive=False,
token=encoded_token))
return_archive=False))
local_download_url = f"{os.path.join(dispatcher_test_conf_with_external_products_url['products_url'], 'dispatch-data/download_file')}?{dpars}"

assert jdata['products']['analysis_parameters']['dummy_file'] == local_download_url
Expand Down Expand Up @@ -1854,8 +1847,7 @@ def test_arg_file_default_product_url(dispatcher_live_fixture_with_default_route
file_hash = make_hash_file(p_file_path)
dpars = urlencode(dict(file_list=file_hash,
_is_mmoda_url=True,
return_archive=False,
token=encoded_token))
return_archive=False))
local_download_url = f"{os.path.join(dispatcher_test_conf_with_default_route_products_url['products_url'], 'dispatch-data/download_file')}?{dpars}"

assert jdata['products']['analysis_parameters']['dummy_file'] == local_download_url
Expand Down

0 comments on commit 7a286d3

Please sign in to comment.