forked from schreiber-lab/scicat_ingest
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removing the forward / before Datasets. If this is given in the endpo…
…int then this is treated by urllib.parse like a full path.
- Loading branch information
Showing
2 changed files
with
31 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
""" | ||
|
@@ -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(): | ||
|