def test_basic_resource_from_dict(self): """Test basic to dict deserialization method Returns: None """ setup_data = get_image_dict() resource1 = BossResourceBasic(setup_data) resource2 = BossResourceBasic() resource2.from_dict(resource1.to_dict()) # Check Collection col = resource2.get_collection() assert col.name == setup_data['collection']['name'] assert col.description == setup_data['collection']['description'] # Check coord frame coord = resource2.get_coord_frame() assert coord.name == setup_data['coord_frame']['name'] assert coord.description == setup_data['coord_frame']['description'] assert coord.x_start == setup_data['coord_frame']['x_start'] assert coord.x_stop == setup_data['coord_frame']['x_stop'] assert coord.y_start == setup_data['coord_frame']['y_start'] assert coord.y_stop == setup_data['coord_frame']['y_stop'] assert coord.z_start == setup_data['coord_frame']['z_start'] assert coord.z_stop == setup_data['coord_frame']['z_stop'] assert coord.x_voxel_size == setup_data['coord_frame']['x_voxel_size'] assert coord.y_voxel_size == setup_data['coord_frame']['y_voxel_size'] assert coord.z_voxel_size == setup_data['coord_frame']['z_voxel_size'] assert coord.voxel_unit == setup_data['coord_frame']['voxel_unit'] # Check exp exp = resource2.get_experiment() assert exp.name == setup_data['experiment']['name'] assert exp.description == setup_data['experiment']['description'] assert exp.num_hierarchy_levels == setup_data['experiment']['num_hierarchy_levels'] assert exp.hierarchy_method == setup_data['experiment']['hierarchy_method'] assert exp.num_time_samples == setup_data['experiment']['num_time_samples'] assert exp.time_step == setup_data['experiment']['time_step'] assert exp.time_step_unit == setup_data['experiment']['time_step_unit'] # Check channel channel = resource2.get_channel() assert channel.is_image() is True assert channel.name == setup_data['channel']['name'] assert channel.description == setup_data['channel']['description'] assert channel.datatype == setup_data['channel']['datatype'] assert channel.base_resolution == setup_data['channel']['base_resolution'] assert channel.sources == setup_data['channel']['sources'] assert channel.related == setup_data['channel']['related'] assert channel.default_time_sample == setup_data['channel']['default_time_sample'] # check keys assert resource2.get_lookup_key() == setup_data['lookup_key'] assert resource2.get_boss_key() == setup_data['boss_key']
def test_factory(self): """Test the Cube factory in Cube""" data = get_image_dict() resource = BossResourceBasic(data) c = Cube.create_cube(resource, [30, 20, 13], [0, 15]) assert isinstance(c, ImageCube8) is True assert c.cube_size == [13, 20, 30] assert c.is_time_series is True assert c.time_range == [0, 15]
def setUpClass(cls): """Setup the redis client at the start of the test""" cls.data = get_image_dict() cls.resource = BossResourceBasic(cls.data) cls.config = configuration.BossConfig() cls.state_client = redis.StrictRedis(host=cls.config["aws"]["cache-state"], port=6379, db=1, decode_responses=False) cls.config_data = {"state_client": cls.state_client}
def setUpClass(cls): """Setup the redis client at the start of the test""" cls.data = get_image_dict() cls.resource = BossResourceBasic(cls.data) cls.config = configuration.BossConfig() cls.cache_client = redis.StrictRedis(host=cls.config["aws"]["cache"], port=6379, db=1, decode_responses=False) cls.config_data = {"cache_client": cls.cache_client, "read_timeout": 86400}
def test_basic_resource_get_lookup_key(self): """Test basic get lookup key interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) assert resource.get_lookup_key() == setup_data['lookup_key']
def test_basic_resource_get_bit_depth(self): """Test basic get bit depth interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) assert resource.get_bit_depth() == 8
def test_basic_resource_get_data_type(self): """Test basic get datatype interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) assert resource.get_data_type() == setup_data['channel']['datatype']
def test_basic_resource_numpy_data_type(self): """Test basic get bit depth interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) assert resource.get_numpy_data_type() == np.uint8
def setUpClass(cls): """Setup the redis client at the start of the test""" cls.data = get_image_dict() cls.resource = BossResourceBasic(cls.data) cls.state_client = redis.StrictRedis(host='localhost', port=6379, db=1, decode_responses=False) cls.config_data = {"state_client": cls.state_client}
def test_factory_no_time(self): """Test the Cube factory in Cube""" data = get_image_dict() data['channel']['datatype'] = 'uint16' resource = BossResourceBasic(data) c = Cube.create_cube(resource, [30, 20, 13]) assert isinstance(c, ImageCube16) is True assert c.cube_size == [13, 20, 30] assert c.is_time_series is False assert c.time_range == [0, 1]
def test_basic_resource_col(self): """Test basic get collection interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) col = resource.get_collection() assert col.name == setup_data['collection']['name'] assert col.description == setup_data['collection']['description']
def setUpClass(cls): """Setup the redis client at the start of the test""" cls.data = get_image_dict() cls.resource = BossResourceBasic(cls.data) cls.config = load_test_config_file() cls.state_client = redis.StrictRedis( host=cls.config["aws"]["cache-state"], port=6379, db=1, decode_responses=False) cls.config_data = {"state_client": cls.state_client}
def test_is_downsampled(self): """Test is downsampled method Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) self.assertFalse(resource.is_downsampled()) setup_data['channel']['downsample_status'] = "DOWNSAMPLED" resource = BossResourceBasic(setup_data) self.assertTrue(resource.is_downsampled())
def test_basic_resource_experiment(self): """Test basic get experiment interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) exp = resource.get_experiment() assert exp.name == setup_data['experiment']['name'] assert exp.description == setup_data['experiment']['description'] assert exp.num_hierarchy_levels == setup_data['experiment']['num_hierarchy_levels'] assert exp.hierarchy_method == setup_data['experiment']['hierarchy_method'] assert exp.num_time_samples == setup_data['experiment']['num_time_samples'] assert exp.time_step == setup_data['experiment']['time_step'] assert exp.time_step_unit == setup_data['experiment']['time_step_unit']
def test_basic_resource_to_dict(self): """Test basic to dict serialization method Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) data = resource.to_dict() assert data['channel'] == setup_data['channel'] assert data['collection'] == setup_data['collection'] assert data['experiment'] == setup_data['experiment'] assert data['lookup_key'] == '4&3&2' assert data['boss_key'] == 'col1&exp1&ch1'
def test_basic_resource_channel_no_time(self): """Test basic get channel interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) channel = resource.get_channel() assert channel.is_image() is True assert channel.name == setup_data['channel']['name'] assert channel.description == setup_data['channel']['description'] assert channel.datatype == setup_data['channel']['datatype'] assert channel.base_resolution == setup_data['channel']['base_resolution'] assert channel.sources == setup_data['channel']['sources'] assert channel.related == setup_data['channel']['related'] assert channel.default_time_sample == setup_data['channel']['default_time_sample'] assert channel.downsample_status == setup_data['channel']['downsample_status']
def test_basic_resource_channel_cloudvolume_uint16(self): """Test basic get channel interface Returns: None """ setup_data = get_image_dict(datatype="uint16", storage_type='cloudvol') resource = BossResourceBasic(setup_data) channel = resource.get_channel() assert channel.is_image() is True assert channel.is_cloudvolume() is True assert channel.name == setup_data['channel']['name'] assert channel.description == setup_data['channel']['description'] assert channel.datatype == setup_data['channel']['datatype'] assert channel.base_resolution == setup_data['channel']['base_resolution'] assert channel.sources == setup_data['channel']['sources'] assert channel.related == setup_data['channel']['related'] assert channel.default_time_sample == setup_data['channel']['default_time_sample'] assert channel.downsample_status == setup_data['channel']['downsample_status'] assert channel.storage_type == setup_data['channel']['storage_type'] assert channel.bucket == setup_data['channel']['bucket'] assert channel.cv_path == setup_data['channel']['cv_path']
def test_basic_resource_coord_frame(self): """Test basic get coordinate frame interface Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) coord = resource.get_coord_frame() assert coord.name == setup_data['coord_frame']['name'] assert coord.description == setup_data['coord_frame']['description'] assert coord.x_start == setup_data['coord_frame']['x_start'] assert coord.x_stop == setup_data['coord_frame']['x_stop'] assert coord.y_start == setup_data['coord_frame']['y_start'] assert coord.y_stop == setup_data['coord_frame']['y_stop'] assert coord.z_start == setup_data['coord_frame']['z_start'] assert coord.z_stop == setup_data['coord_frame']['z_stop'] assert coord.x_voxel_size == setup_data['coord_frame']['x_voxel_size'] assert coord.y_voxel_size == setup_data['coord_frame']['y_voxel_size'] assert coord.z_voxel_size == setup_data['coord_frame']['z_voxel_size'] assert coord.voxel_unit == setup_data['coord_frame']['voxel_unit']
def get_image8_dict(self): """Method to get the config dictionary for an image8 resource""" data = get_image_dict() return data