Skip to content
Snippets Groups Projects
Commit 7193c560 authored by Adam Laskowski's avatar Adam Laskowski
Browse files

BIS-713: Implementation of Python API

parent 81900bfc
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
......@@ -271,13 +271,14 @@ class ImagingDataSetPropertyConfig(AbstractImagingClass):
self.images = images if images is not None else []
@classmethod
def from_dict(cls, data):
def from_dict(cls, data: dict):
assert data is not None and any(data), "There is no property config found!"
config = ImagingDataSetConfig.from_dict(data.get('config'))
attr = data.get('images')
images = [ImagingDataSetImage.from_dict(image) for image in attr] if attr is not None else None
return cls(config, images)
def add_image(self, image):
def add_image(self, image: ImagingDataSetImage):
if self.images is None:
self.images = []
self.images += [image]
......@@ -368,9 +369,6 @@ class ImagingControl:
if chunk:
f.write(chunk)
def get_property_config(self, perm_id: str) -> ImagingDataSetPropertyConfig:
dataset = self._openbis.get_dataset(perm_id)
imaging_property = json.loads(dataset.props[IMAGING_CONFIG_PROP_NAME])
......
......@@ -102,12 +102,16 @@ class ImagingTestCase(unittest.TestCase):
json_config = json.dumps(config)
self.dataset_mock.props = {IMAGING_CONFIG_PROP_NAME: json_config}
def test_get_property_config(self):
self.imaging_control.get_property_config('some_perm_id')
def test_get_proper_config(self):
config = self.imaging_control.get_property_config('some_perm_id')
assert len(config.images) == 1
assert len(config.images[0].previews) == 1
def test_get_empty_config(self):
self.set_dataset_config(None)
self.assertRaises(AssertionError, self.imaging_control.get_property_config, 'some_perm_id')
#TODO expand tests
......
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