Exemple #1
0
    def test_full_token_image_time_resolves(self):
        """
        Test to make sure the tiles URL with all datamodel params resolves
        :return:
        """
        view_tiles = resolve('/' + version + '/image/col1/exp1/ds1/xy/2/0:5/0:6/1/1')
        self.assertEqual(view_tiles.func.__name__, CutoutTile.as_view().__name__)

        view_tiles = resolve('/' + version + '/image/col1/exp1/ds1/xz/2/0:5/1/1:6/2')
        self.assertEqual(view_tiles.func.__name__, CutoutTile.as_view().__name__)

        view_tiles = resolve('/' + version + '/image/col1/exp1/ds1/yz/2/5/1:6/1:6/3/')
        self.assertEqual(view_tiles.func.__name__, CutoutTile.as_view().__name__)
Exemple #2
0
    def test_png_uint8_xz(self):
        """ Test a png xz slice"""
        # Post data to the database
        factory = APIRequestFactory()

        # Get an image file
        request = factory.get('/' + version +
                              '/image/col1/exp1/channel1/xz/0/0:128/2/0:16/',
                              Accept='image/png')
        force_authenticate(request, user=self.user)
        # Make request
        response = CutoutTile.as_view()(request,
                                        collection='col1',
                                        experiment='exp1',
                                        dataset='channel1',
                                        orientation='xz',
                                        resolution='0',
                                        x_args='0:128',
                                        y_args='2',
                                        z_args='0:16')
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Check data is correct (this is pre-renderer)
        test_img = np.array(response.data, dtype="uint8")

        np.testing.assert_equal(test_img,
                                np.squeeze(self.test_data_8[0:16, 2, 0:128]))
    def test_no_cache_read(self):
        """Test no-cache option when reading an image"""
        factory = APIRequestFactory()

        # Get an image file
        request = factory.get(
            '/' + version +
            '/image/col1/exp1/channel1/xy/0/400:700/300:800/3/?no-cache=true',
            Accept='image/png')
        force_authenticate(request, user=self.user)

        time.sleep(10)

        # Make request
        response = CutoutTile.as_view()(request,
                                        collection='col1',
                                        experiment='exp1',
                                        channel='channel1',
                                        orientation='xy',
                                        resolution='0',
                                        x_args='400:700',
                                        y_args='300:800',
                                        z_args='3')
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Check data is correct (this is pre-renderer)
        test_img = np.array(response.data, dtype="uint8")

        np.testing.assert_equal(test_img, self.test_data_8[3, 300:800,
                                                           400:700])
Exemple #4
0
    def test_png_uint8_xz(self):
        """ Test a png xz slice"""
        # Post data to the database
        factory = APIRequestFactory()

        # Get an image file
        request = factory.get('/' + version + '/image/col1/exp1/channel1/xz/0/0:128/2/0:16/',
                              Accept='image/png')
        force_authenticate(request, user=self.user)
        # Make request
        response = CutoutTile.as_view()(request, collection='col1', experiment='exp1', channel='channel1',
                                        orientation='xz', resolution='0', x_args='0:128', y_args='2', z_args='0:16')
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Check data is correct (this is pre-renderer)
        test_img = np.array(response.data, dtype="uint8")

        np.testing.assert_equal(test_img, np.squeeze(self.test_data_8[0:16, 2, 0:128]))
    def test_no_cache_read(self):
        """Test no-cache option when reading an image"""
        factory = APIRequestFactory()

        # Get an image file
        request = factory.get('/' + version + '/image/col1/exp1/channel1/xy/0/400:700/300:800/3/?no-cache=true',
                              Accept='image/png')
        force_authenticate(request, user=self.user)

        time.sleep(10)

        # Make request
        response = CutoutTile.as_view()(request, collection='col1', experiment='exp1', channel='channel1',
                                        orientation='xy', resolution='0', x_args='400:700', y_args='300:800',
                                        z_args='3')
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        # Check data is correct (this is pre-renderer)
        test_img = np.array(response.data, dtype="uint8")

        np.testing.assert_equal(test_img, self.test_data_8[3, 300:800, 400:700])