def test_basic_resource_from_json_annotation(self): """Test basic to json deserialization method Returns: None """ setup_data = get_anno_dict() resource1 = BossResourceBasic(setup_data) resource2 = BossResourceBasic() resource2.from_json(resource1.to_json()) # 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 False 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_basic_resource_to_json(self): """Test basic to json serialization method Returns: None """ setup_data = get_image_dict() resource = BossResourceBasic(setup_data) data = resource.to_json() data = json.loads(data) assert data['channel'] == setup_data['channel'] assert data['collection'] == setup_data['collection'] assert data['experiment'] == setup_data['experiment'] assert data['coord_frame'] == setup_data['coord_frame'] assert data['lookup_key'] == '4&3&2' assert data['boss_key'] == 'col1&exp1&ch1'