Skip to content

Commit

Permalink
ref: support latest development API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Apr 16, 2024
1 parent d18cd41 commit 8671b29
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
56 changes: 27 additions & 29 deletions tests/test_dcserv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import dclab
from dclab.rtdc_dataset.fmt_http import HTTPBasin
from dcoraid.api import dataset
from dcoraid.api import dataset, errors

from helper import get_api, make_dataset_dict

Expand Down Expand Up @@ -44,7 +44,7 @@ def test_access_private_data():
res_id = data2["resources"][0]["id"]

# Wait until all background jobs are successful
for ii in range(120):
for _ in range(120):
# metadata
res_dict = api.get("resource_show", id=res_id)
if "dc:experiment:event count" in res_dict:
Expand All @@ -66,10 +66,9 @@ def test_access_private_data():
avail = api.get("dcserv", id=res_id, query="valid")
assert avail is True

# Can we get the feature list (version 1)?
features = api.get("dcserv", id=res_id, query="feature_list&version=1")
assert "deform" in features
assert len(features) >= 36
# Version 1 of the API is not supported anymore
with pytest.raises(errors.APIConflictError, match="not supported anymore"):
api.get("dcserv", id=res_id, query="feature_list&version=1")

# Feature list for version 2 should be empty
features2 = api.get("dcserv", id=res_id, query="feature_list&version=2")
Expand Down Expand Up @@ -100,26 +99,25 @@ def test_access_private_data():
def test_access_public_data_features():
api = get_api()

# deformation
res = api.get("dcserv",
id="fb719fb2-bd9f-817a-7d70-f4002af916f0",
query="feature",
feature="deform")
deform = np.asarray(res)
assert np.allclose(deform[0],
0.009741938672959805,
atol=0,
rtol=1e-10
)

# volume (ancillary feature from condensed part)
res2 = api.get("dcserv",
id="fb719fb2-bd9f-817a-7d70-f4002af916f0",
query="feature",
feature="volume")
volume = np.asarray(res2)
assert np.allclose(volume[0],
112.7559351790568,
atol=0,
rtol=1e-10
)
# Since the migration to version 2 of the API, the "feature" query is
# no longer functional.
with pytest.raises(errors.APIConflictError,
match="Invalid query parameter"):
api.get("dcserv",
id="fb719fb2-bd9f-817a-7d70-f4002af916f0",
query="feature",
feature="deform")

with dclab.new_dataset("fb719fb2-bd9f-817a-7d70-f4002af916f0",
host=api.server) as ds:
assert np.allclose(ds["deform"][0],
0.009741938672959805,
atol=0,
rtol=1e-10
)

assert np.allclose(ds["volume"][0],
112.7559351790568,
atol=0,
rtol=1e-10
)
2 changes: 1 addition & 1 deletion tests/test_schemas_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def test_package_revise_upload_not_allowed_active_dataset():
assert not req.ok
assert not req.json()["success"]
error = req.json()["error"]
assert "resources to non-draft datasets not allowed" in error["message"]
assert "Changing 'resources' not allowed for non-draft" in error["message"]
pkg_data = api.get("package_show", id=data["id"])
assert len(pkg_data["resources"]) == 1

Expand Down

0 comments on commit 8671b29

Please sign in to comment.