Skip to content

Commit

Permalink
Removing the forward / before Datasets. If this is given in the endpo…
Browse files Browse the repository at this point in the history
…int then this is treated by urllib.parse like a full path.
  • Loading branch information
LAShemilt committed Apr 19, 2023
1 parent caffcb3 commit 21691ad
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
6 changes: 3 additions & 3 deletions pyscicat/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ def datasets_get_many(self, filter_fields: Optional[dict] = None) -> Optional[di
if not filter_fields:
filter_fields = {}
filter_fields = json.dumps(filter_fields)
endpoint = f'/Datasets/?filter={{"where":{filter_fields}}}'
endpoint = f'Datasets?filter={{"where":{filter_fields}}}'
return self._call_endpoint(
cmd="get", endpoint=endpoint, operation="datasets_get_many", allow_404=True
)
Expand Down Expand Up @@ -912,7 +912,7 @@ def datasets_origdatablocks_get_one(self, pid: str) -> Optional[dict]:
"""
return self._call_endpoint(
cmd="get",
endpoint=f"/Datasets/{quote_plus(pid)}/origdatablocks",
endpoint=f"Datasets/{quote_plus(pid)}/origdatablocks",
operation="datasets_origdatablocks_get_one",
allow_404=True,
)
Expand All @@ -937,7 +937,7 @@ def datasets_delete(self, pid: str) -> Optional[dict]:
"""
return self._call_endpoint(
cmd="delete",
endpoint=f"/Datasets/{quote_plus(pid)}",
endpoint=f"Datasets/{quote_plus(pid)}",
operation="datasets_delete",
allow_404=True,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from pyscicat.client import ScicatClient
from pyscicat.model import RawDataset
from pyscicat.model import RawDataset, Ownable
from datetime import datetime
import os
import requests


"""
Expand All @@ -18,51 +19,57 @@
SCICAT_PASSWORD - the password for your scicat user.
"""


sci_clie = ScicatClient(base_url=os.environ["BASE_URL"],
token=None,
username=os.environ["SCICAT_USER"],
password=os.environ["SCICAT_PASSWORD"])
def test_client():
sci_clie = ScicatClient(base_url=os.environ["BASE_URL"],
token=None,
username=os.environ["SCICAT_USER"],
password=os.environ["SCICAT_PASSWORD"])

assert type(sci_clie) == ScicatClient



def test_upload_dataset():
sci_clie = ScicatClient(base_url=os.environ["BASE_URL"],
token=None, username=os.environ["SCICAT_USER"],
password=os.environ["SCICAT_PASSWORD"])


ownable = Ownable(ownerGroup="ingestor", accessGroups=[])
payload = RawDataset(
datasetName="a guide book",
datasetName="a new guide book",
path="/foo/bar",
size=42,
packedSize=0,
owner=os.environ["SCICAT_USER"],
ownerGroup="Magrateheans",
contactEmail="[email protected]",
creationLocation="magrathea",
creationLocation="Magrathea",
creationTime=datetime.isoformat(datetime.now()),
instrumentId="earth",
proposalId="deepthought",
dataFormat="planet",
principalInvestigator="A. Mouse",
sourceFolder="/foo/bar",
scientificMetadata={"a": "field"},
scientificMetadata={"type": "string", "value": {"a": "field"}},
sampleId="gargleblaster",
accessGroups=[]
type="raw",
ownerEmail="[email protected]",
sourceFolderHost="s3.heartofgold.org",
endTime=datetime.isoformat(datetime.now()),
techniques=[],
numberOfFiles=0,
numberOfFilesArchived=0,
**ownable.dict()
)

sci_clie.upload_new_dataset(payload)


def test_get_dataset(subtests):
sci_clie = ScicatClient(base_url=os.environ["BASE_URL"],
token=None,
username=os.environ["SCICAT_USER"],
password=os.environ["SCICAT_PASSWORD"])
datasets = sci_clie.get_datasets({"ownerGroup": "Magratheans"})

datasets = sci_clie.get_datasets({"ownerGroup": "ingestor"})


for dataset in datasets:
with subtests.tests(dataset=dataset):
assert dataset["ownerGroup"] == "Magratheans"

assert dataset["ownerGroup"] == "ingestor"


def test_update_dataset():
Expand Down

0 comments on commit 21691ad

Please sign in to comment.