Beispiel #1
0
    def test_basic_resource_coord_frame(self):
        """Test basic get coordinate frame interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        coord = resource.get_coord_frame()

        assert coord.name == self.request_channel.coord_frame.name
        assert coord.description == self.request_channel.coord_frame.description
        assert coord.x_start == self.request_channel.coord_frame.x_start
        assert coord.x_stop == self.request_channel.coord_frame.x_stop
        assert coord.y_start == self.request_channel.coord_frame.y_start
        assert coord.y_stop == self.request_channel.coord_frame.y_stop
        assert coord.z_start == self.request_channel.coord_frame.z_start
        assert coord.z_stop == self.request_channel.coord_frame.z_stop
        assert coord.x_voxel_size == self.request_channel.coord_frame.x_voxel_size
        assert coord.y_voxel_size == self.request_channel.coord_frame.y_voxel_size
        assert coord.z_voxel_size == self.request_channel.coord_frame.z_voxel_size
        assert coord.voxel_unit == self.request_channel.coord_frame.voxel_unit
        assert coord.time_step == self.request_channel.coord_frame.time_step
        assert coord.time_step_unit == self.request_channel.coord_frame.time_step_unit
    def test_basic_resource_get_iso_level_isotropic(self):
        """Test get iso level isotropic

        Returns:
            None

        """
        url = '/' + version + '/cutout/col1/exp_iso/channel1/0/0:5/0:6/0:2/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        request_args = {
            "service": "cutout",
            "collection_name": "col1",
            "experiment_name": "exp_iso",
            "channel_name": "channel1",
            "resolution": 0,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        req = BossRequest(drfrequest, request_args)
        resource = BossResourceDjango(req)

        self.assertEqual(resource.get_isotropic_level(), 0)
    def test_basic_resource_get_downsampled_extent_dims_isotropic(self):
        """Test downsample extent isotropic

        Returns:
            None

        """
        url = '/' + version + '/cutout/col1/exp_iso/channel1/0/0:5/0:6/0:2/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        request_args = {
            "service": "cutout",
            "collection_name": "col1",
            "experiment_name": "exp_iso",
            "channel_name": "channel1",
            "resolution": 0,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        req = BossRequest(drfrequest, request_args)
        resource = BossResourceDjango(req)

        extent_dims = resource.get_downsampled_extent_dims()
        self.assertEqual(len(extent_dims), 8)
        self.assertEqual(extent_dims[0], [2000, 5000, 200])
        self.assertEqual(extent_dims[1], [1000, 2500, 100])
        self.assertEqual(extent_dims[3], [250, 625, 25])
    def test_django_resource_get_data_type(self):
        """Test basic get datatype interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)
        assert resource.get_data_type() == self.request_channel.channel.datatype
    def test_django_resource_get_boss_key(self):
        """Test basic get boss key interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        assert resource.get_boss_key() == self.request_channel.get_boss_key()
        assert resource.get_boss_key() == 'col1&exp1&channel1'
    def test_django_resource_get_lookup_key(self):
        """Test basic get lookup key interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        assert resource.get_lookup_key() == self.request_channel.get_lookup_key()
        assert isinstance(resource.get_lookup_key(), str)
    def test_django_resource_col(self):
        """Test basic get collection interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        col = resource.get_collection()

        assert col.name == self.request_channel.collection.name
        assert col.description == self.request_channel.collection.description
Beispiel #8
0
    def test_django_resource_to_dict_layer(self):
        """Test basic get datatype interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_layer)
        data = resource.to_dict()
        assert "channel_layer" in data
        assert "collection" in data
        assert "experiment" in data
        assert "lookup_key" in data
Beispiel #9
0
    def test_basic_resource_experiment(self):
        """Test basic get experiment interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        exp = resource.get_experiment()

        assert exp.name == self.request_channel.experiment.name
        assert exp.description == self.request_channel.experiment.description
        assert exp.num_hierarchy_levels == self.request_channel.experiment.num_hierarchy_levels
        assert exp.hierarchy_method == self.request_channel.experiment.hierarchy_method
Beispiel #10
0
    def test_django_resource_to_dict_annotation(self):
        """Test basic get to dict interface for annotations

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_annotation)
        data = resource.to_dict()
        assert "channel" in data
        assert "collection" in data
        assert "experiment" in data
        assert "lookup_key" in data
        assert "boss_key" in data
        assert "coord_frame" in data
Beispiel #11
0
    def test_django_resource_experiment(self):
        """Test basic get experiment interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        exp = resource.get_experiment()

        assert exp.name == self.request_channel.experiment.name
        assert exp.description == self.request_channel.experiment.description
        assert exp.num_hierarchy_levels == self.request_channel.experiment.num_hierarchy_levels
        assert exp.hierarchy_method == self.request_channel.experiment.hierarchy_method
        assert exp.time_step == self.request_channel.experiment.time_step
        assert exp.time_step_unit == self.request_channel.experiment.time_step_unit
Beispiel #12
0
    def test_basic_resource_channel(self):
        """Test basic get channel interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        assert resource.is_channel() == True

        assert not resource.get_layer()

        channel = resource.get_channel()

        assert channel.name == self.request_channel.channel_layer.name
        assert channel.description == self.request_channel.channel_layer.description
        assert channel.datatype == self.request_channel.channel_layer.datatype
Beispiel #13
0
    def test_basic_resource_layer(self):
        """Test basic get layer interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_layer)

        assert resource.is_channel() == False

        assert not resource.get_channel()

        layer = resource.get_layer()
        assert layer.name == self.request_layer.channel_layer.name
        assert layer.description == self.request_layer.channel_layer.description
        assert layer.datatype == self.request_layer.channel_layer.datatype
        assert layer.base_resolution == self.request_layer.channel_layer.base_resolution
        assert layer.parent_channels == self.request_layer.channel_layer.linked_channel_layers
    def test_django_resource_channel_annotation(self):
        """Test basic get channel when an annotation interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_annotation)

        channel = resource.get_channel()
        assert channel.is_image() is False

        assert channel.name == self.request_annotation.channel.name
        assert channel.description == self.request_annotation.channel.description
        assert channel.datatype == self.request_annotation.channel.datatype
        assert channel.type == self.request_annotation.channel.type
        assert channel.base_resolution == self.request_annotation.channel.base_resolution
        assert channel.default_time_sample == self.request_annotation.channel.default_time_sample
        assert channel.related == []
        assert channel.sources == []
Beispiel #15
0
    def test_django_resource_channel_image_with_links(self):
        """Test basic get channel interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel_links)

        channel = resource.get_channel()
        assert channel.is_image() is False

        assert channel.name == self.request_channel_links.channel.name
        assert channel.description == self.request_channel_links.channel.description
        assert channel.datatype == self.request_channel_links.channel.datatype
        assert channel.type == self.request_channel_links.channel.type
        assert channel.base_resolution == self.request_channel_links.channel.base_resolution
        assert channel.default_time_sample == self.request_channel_links.channel.default_time_sample
        assert channel.related == ['channel2', 'channel3']
        assert channel.sources == ['channel1']
Beispiel #16
0
    def test_basic_resource_get_downsampled_voxel_dims_anisotropic_iso(self):
        """Test downsample voxel dims anisotropic with iso flag

        Returns:
            None

        """
        url = '/' + version + '/cutout/col1/exp_aniso/channel1/0/0:5/0:6/0:2/'

        # Create the request
        request = self.rf.get(url)
        force_authenticate(request, user=self.user)
        drfrequest = Cutout().initialize_request(request)
        drfrequest.version = version

        request_args = {
            "service": "cutout",
            "collection_name": "col1",
            "experiment_name": "exp_aniso",
            "channel_name": "channel1",
            "resolution": 0,
            "x_args": "0:5",
            "y_args": "0:6",
            "z_args": "0:2",
            "time_args": None
        }

        req = BossRequest(drfrequest, request_args)
        resource = BossResourceDjango(req)

        voxel_dims = resource.get_downsampled_voxel_dims(iso=True)
        self.assertEqual(len(voxel_dims), 8)
        self.assertEqual(voxel_dims[0], [4, 4, 35])
        self.assertEqual(voxel_dims[1], [8, 8, 35])
        self.assertEqual(voxel_dims[2], [16, 16, 35])
        self.assertEqual(voxel_dims[3], [32, 32, 35])
        self.assertEqual(voxel_dims[4], [64, 64, 70])
        self.assertEqual(voxel_dims[5], [128, 128, 140])
Beispiel #17
0
    def test_django_resource_channel_image_cloudvol(self):
        """Test basic get channel interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        channel = resource.get_channel()
        assert channel.is_image() is True
        assert channel.is_cloudvolume() is True
        assert channel.name == self.request_channel.channel.name
        assert channel.description == self.request_channel.channel.description
        assert channel.datatype == self.request_channel.channel.datatype
        assert channel.type == self.request_channel.channel.type
        assert channel.base_resolution == self.request_channel.channel.base_resolution
        assert channel.default_time_sample == self.request_channel.channel.default_time_sample
        assert channel.related == []
        assert channel.sources == []
        assert channel.storage_type == self.request_channel.storage_type
        assert channel.bucket == self.request_channel.bucket
        assert channel.cv_path == self.request_channel.cv_path
Beispiel #18
0
    def test_django_resource_coord_frame(self):
        """Test basic get coordinate frame interface

        Returns:
            None

        """
        resource = BossResourceDjango(self.request_channel)

        coord = resource.get_coord_frame()

        assert coord.name == self.request_channel.coord_frame.name
        assert coord.description == self.request_channel.coord_frame.description
        assert coord.x_start == self.request_channel.coord_frame.x_start
        assert coord.x_stop == self.request_channel.coord_frame.x_stop
        assert coord.y_start == self.request_channel.coord_frame.y_start
        assert coord.y_stop == self.request_channel.coord_frame.y_stop
        assert coord.z_start == self.request_channel.coord_frame.z_start
        assert coord.z_stop == self.request_channel.coord_frame.z_stop
        assert coord.x_voxel_size == self.request_channel.coord_frame.x_voxel_size
        assert coord.y_voxel_size == self.request_channel.coord_frame.y_voxel_size
        assert coord.z_voxel_size == self.request_channel.coord_frame.z_voxel_size
        assert coord.voxel_unit == self.request_channel.coord_frame.voxel_unit