Skip to content
Snippets Groups Projects
Commit 00029f1b authored by Duncan Meacher's avatar Duncan Meacher
Browse files

Merge branch 'support-float-or-int' into 'master'

Support arbitrary float or int in URLs

Closes #20

See merge request !61
parents 120cbb79 ebf50ac1
No related branches found
No related tags found
1 merge request!61Support arbitrary float or int in URLs
Pipeline #521403 passed with warnings
......@@ -212,12 +212,9 @@ def find_url(ext, site, tag, filename):
))
@blueprint.route('<ext>/<site>/<tag>/<int:start>,<int:end>') # for --ping
@blueprint.route('<ext>/<site>/<tag>/<int:start>,<int:end>.json')
@blueprint.route('<ext>/<site>/<tag>/<int:start>,<int:end>/<urltype>.json')
@blueprint.route('<ext>/<site>/<tag>/<float:start>,<float:end>') # for --ping
@blueprint.route('<ext>/<site>/<tag>/<float:start>,<float:end>.json')
@blueprint.route('<ext>/<site>/<tag>/<float:start>,<float:end>/<urltype>.json')
@blueprint.route('<ext>/<site>/<tag>/<start>,<end>') # for --ping
@blueprint.route('<ext>/<site>/<tag>/<start>,<end>.json')
@blueprint.route('<ext>/<site>/<tag>/<start>,<end>/<urltype>.json')
@handle_errors_as_json
@authentication.validate
def find_urls(ext, site, tag, start, end, urltype=None):
......@@ -269,7 +266,7 @@ def _find_urls(ext, site, tag, start, end, urltype=None, match=None,
cache = get_dataset_cache(ext, site, tag)
# parse file paths
search = segment(start, end)
search = segment(float(start), float(end))
lfns = defaultdict(list)
maxgps = -1e9 # something absurdly old
for (path, cdur), seglist in cache.items():
......
......@@ -132,6 +132,29 @@ def test_find_urls_filter_preference(client):
]
@mock.patch.object(api_utils, "_DEFAULT_GSIFTP_HOST", new="testhost")
@pytest.mark.parametrize(("start", "end"), [
(1000000003.5, 1000000012.5),
(1000000003, 1000000012.5),
(1000000003.5, 1000000013),
])
def test_find_urls_noninteger(client, start, end):
"""Test the `find_urls` view with non-integer GPS times.
"""
resp = client.get(
f"/services/data/v1/gwf/L/L1_TEST_1/{start},{end}.json",
)
assert resp.status_code == 200
assert sorted(resp.json) == [
"file://localhost/test/path/L-L1_TEST_1-1000000000-4.gwf",
"file://localhost/test/path/L-L1_TEST_1-1000000004-4.gwf",
"file://localhost/test/path2/L-L1_TEST_1-1000000012-4.gwf",
"gsiftp://testhost:15000/test/path/L-L1_TEST_1-1000000000-4.gwf",
"gsiftp://testhost:15000/test/path/L-L1_TEST_1-1000000004-4.gwf",
"gsiftp://testhost:15000/test/path2/L-L1_TEST_1-1000000012-4.gwf",
]
@mock.patch.object(api_utils, "_DEFAULT_GSIFTP_HOST", new="testhost")
def test_find_latest(client):
"""Test the `find_latest` view
......
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