Ejemplo n.º 1
0
    def test_request_ids_service_invalid_channel_type(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/reserve/col1/exp1/channel1/10'
        col = 'col1'
        exp = 'exp1'
        channel = 'channel'

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

        # Create the request dict
        request_args = {
            "service": "reserve",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
        }

        with self.assertRaises(BossError):
            ret = BossRequest(drfrequest, request_args)
Ejemplo n.º 2
0
    def test_bounding_box_service_invalid_channel_type(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/boundingbox/col1/exp1/channel1/0/10'
        col = 'col1'
        exp = 'exp1'
        channel = 'channel1'

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

        # Create the request dict
        request_args = {
            "service": "boundingbox",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
            "resolution": 0,
            "id": 10

        }

        with self.assertRaises(BossError):
            ret = BossRequest(drfrequest, request_args)
Ejemplo n.º 3
0
    def test_request_ids_service(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/reserve/col1/exp1/layer1/10'
        col = 'col1'
        exp = 'exp1'
        channel = 'layer1'
        boss_key = 'col1&exp1&layer1'

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

        # Create the request dict
        request_args = {
            "service": "reserve",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
        }

        ret = BossRequest(drfrequest, request_args)
        self.assertEqual(ret.get_collection(), col)
        self.assertEqual(ret.get_experiment(), exp)
        self.assertEqual(ret.get_channel(), channel)
        self.assertEqual(ret.get_boss_key(), boss_key)
    def test_bounding_box_service_invalid_resolution(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/boundingbox/col1/exp1/layer1/25/10'
        col = 'col1'
        exp = 'exp1'
        channel = 'layer1'

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

        # Create the request dict
        request_args = {
            "service": "boundingbox",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
            "resolution": 25,
            "id": 10
        }

        with self.assertRaises(BossError):
            ret = BossRequest(drfrequest, request_args)
Ejemplo n.º 5
0
    def test_request_ids_service(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/reserve/col1/exp1/layer1/10'
        col = 'col1'
        exp = 'exp1'
        channel = 'layer1'
        boss_key = 'col1&exp1&layer1'

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

        # Create the request dict
        request_args = {
            "service": "reserve",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,

        }

        ret = BossRequest(drfrequest, request_args)
        self.assertEqual(ret.get_collection(), col)
        self.assertEqual(ret.get_experiment(), exp)
        self.assertEqual(ret.get_channel(), channel)
        self.assertEqual(ret.get_boss_key(), boss_key)
Ejemplo n.º 6
0
    def test_reserve_id_resolves(self):
        """
        Test that the reserve id url resolves

        Returns: None

        """
        match = resolve('/' + version + '/reserve/col1/exp1/channel1/10')
        self.assertEqual(match.func.__name__, Reserve.as_view().__name__)
Ejemplo n.º 7
0
    def test_reserve_id_resolves(self):
        """
        Test that the reserve id url resolves

        Returns: None

        """
        match = resolve('/' + version + '/reserve/col1/exp1/channel1/10')
        self.assertEqual(match.func.__name__, Reserve.as_view().__name__)
Ejemplo n.º 8
0
    def test_request_ids_service_invalid_channel_type(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/ids/col1/exp1/channel1/0/0:6/0:10/0:2/'
        col = 'col1'
        exp = 'exp1'
        channel = 'channel1'
        boss_key = 'col1&exp1&channel1'
        resolution = 0

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

        # Create the request dict
        request_args = {
            "service": "ids",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
            "resolution": resolution,
            "x_args": "0:6",
            "y_args": "0:10",
            "z_args": "0:2",
            "time_args": None

        }

        with self.assertRaises(BossError):
            ret = BossRequest(drfrequest, request_args)
Ejemplo n.º 9
0
    def test_request_ids_service_invalid_channel_type(self):
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        """
        Test initialization of cutout requests for the datamodel
        :return:
        """
        url = '/' + version + '/ids/col1/exp1/channel1/0/0:6/0:10/0:2/'
        col = 'col1'
        exp = 'exp1'
        channel = 'channel1'
        boss_key = 'col1&exp1&channel1'
        resolution = 0

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

        # Create the request dict
        request_args = {
            "service": "ids",
            "version": version,
            "collection_name": col,
            "experiment_name": exp,
            "channel_name": channel,
            "resolution": resolution,
            "x_args": "0:6",
            "y_args": "0:10",
            "z_args": "0:2",
            "time_args": None
        }

        with self.assertRaises(BossError):
            ret = BossRequest(drfrequest, request_args)
Ejemplo n.º 10
0
    def test_reserve_ids_view(self):
        """A test to reserve ids"""

        # Create request
        factory = APIRequestFactory()
        request = factory.get('/' + version + '/reserve/col1/exp1/layer1/10')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Reserve.as_view()(request, collection='col1', experiment='exp1', channel='layer1', num_ids='10')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['start_id'], 1)
        self.assertEqual(response.data['count'], '10')
Ejemplo n.º 11
0
    def test_reserve_ids_view(self):
        """A test to reserve ids"""

        # Create request
        factory = APIRequestFactory()
        request = factory.get('/' + version + '/reserve/col1/exp1/layer1/10')
        # log in user
        force_authenticate(request, user=self.user)

        # Make request
        response = Reserve.as_view()(request,
                                     collection='col1',
                                     experiment='exp1',
                                     channel='layer1',
                                     num_ids='10')
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['start_id'], 1)
        self.assertEqual(response.data['count'], '10')