예제 #1
0
class TestDownload(unittest.TestCase):

    def setUp(self):
        self.oo = OCP()

    def test_get_cutout_type(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        numpy_download = self.oo.get_cutout('kasthuri11', 'image',
                                            1000, 1100,
                                            1000, 1100,
                                            1000, 1001,
                                            resolution=3)

        self.assertEqual(type(numpy_download), numpy.ndarray)

    def test_get_cutout(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        numpy_download = self.oo.get_cutout('kasthuri11', 'image',
                                            1000, 1100,
                                            1000, 1100,
                                            1000, 1001,
                                            resolution=3)

        # We know this pixel is 132
        self.assertEqual(numpy_download[0][0][0], 132)

    def test_get_volume_type(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        ramon_download = self.oo.get_volume('kasthuri11', 'image',
                                            1000, 1100,
                                            1000, 1100,
                                            1000, 1001,
                                            resolution=3)

        self.assertEqual(type(ramon_download), ndio.ramon.RAMONVolume)

    def test_get_volume(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        ramon_download = self.oo.get_volume('kasthuri11', 'image',
                                            1000, 1100,
                                            1000, 1100,
                                            1000, 1001,
                                            resolution=3)

        self.assertEqual(ramon_download.xyz_offset[0], 1000)
        self.assertEqual(ramon_download.resolution, 3)
        self.assertEqual(ramon_download.cutout[0][0][0], 132)

    def test_get_image_type(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        image_download = self.oo.get_image('kasthuri11', 'image',
                                           1000, 1100,
                                           1000, 1100,
                                           1000,
                                           resolution=3)

        self.assertEqual(type(image_download), numpy.ndarray)
        self.assertEqual(image_download.shape, (100, 100))
class TestDownload(unittest.TestCase):

    def setUp(self):
        self.oo = OCP()

    def test_export_import_png(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        image_download = self.oo.get_image('kasthuri11', 'image',
                                           1000, 1100,
                                           1000, 1100,
                                           1000,
                                           resolution=3)

        # if returns string, successful export
        self.assertEqual(
                ndpng.export_png("tests/trash/download.png", image_download),
                "tests/trash/download.png")

        # now confirm import works too
        self.assertEqual(ndpng.import_png("tests/trash/download.png")[0][0],
                         image_download[0][0])
        self.assertEqual(ndpng.import_png("tests/trash/download.png")[10][10],
                         image_download[10][10])

    def test_export_import_tiff(self):
        # kasthuri11/image/xy/3/1000,1100/1000,1100/1000/
        image_download = self.oo.get_image('kasthuri11', 'image',
                                           1000, 1100,
                                           1000, 1100,
                                           1000,
                                           resolution=3)

        # if returns string, successful export
        self.assertEqual(
                ndtiff.export_tiff("tests/trash/download-1.tiff", image_download),
                "tests/trash/download-1.tiff")

        # now confirm import works too
        self.assertEqual(ndtiff.import_tiff("tests/trash/download-1.tiff")[0][0],
                         image_download[0][0])
        self.assertEqual(ndtiff.import_tiff("tests/trash/download-1.tiff")[10][10],
                         image_download[10][10])