Exemplo n.º 1
0
class TestWebGatewayCacheTempFile(object):
    @pytest.fixture(autouse=True)
    def setUp(self, request):
        def fin():
            os.system('rm -fr test_cache')

        request.addfinalizer(fin)
        self.tmpfile = WebGatewayTempFile(tdir='test_cache')

    def testFilenameSize(self):
        """
        Make sure slashes, dashes, underscores and other chars don't mess
        things up.
        Also check for filename size limits.
        """
        fname = '1/2_3!"\'#$%&()=@€£‰¶÷[]≠§±+*~^\,.;:'

        try:
            fpath, rpath, fobj = self.tmpfile.new(fname, key='specialchars')
        except:
            raise
            pytest.fail('WebGatewayTempFile.new not handling special'
                        ' characters properly')
        # ext2/3/4 limit is 255 bytes, most others are equal to or larger
        fname = "a" * 384
        try:
            fpath, rpath, fobj = self.tmpfile.new(fname, key='longname')
            fobj.close()
            # is it keeping extensions properly?
            fpath, rpath, fobj = self.tmpfile.new("1" + fname + '.tif',
                                                  key='longname')
            fobj.close()
            assert fpath[-5:] == 'a.tif'
            fpath, rpath, fobj = self.tmpfile.new("2" + fname + '.ome.tiff',
                                                  key='longname')
            fobj.close()
            assert fpath[-10:] == 'a.ome.tiff'
            fpath, rpath, fobj = self.tmpfile.new("3" + fname + 'ome.tiff',
                                                  key='longname')
            fobj.close()
            assert fpath[-6:] == 'a.tiff'
            fpath, rpath, fobj = self.tmpfile.new("4" + fname +
                                                  'somethingverylong.zip',
                                                  key='longname')
            fobj.close()
            assert fpath[-5:] == 'a.zip'
            fpath, rpath, fobj = self.tmpfile.new("5" + fname +
                                                  '.tif.somethingverylong',
                                                  key='longname')
            fobj.close()
            assert fpath[-5:] == 'aaaaa'
        except:
            pytest.fail('WebGatewayTempFile.new not handling long file names'
                        ' properly')
class TestWebGatewayCacheTempFile(object):
    @pytest.fixture(autouse=True)
    def setUp(self, request):

        def fin():
            os.system('rm -fr test_cache')
        request.addfinalizer(fin)
        self.tmpfile = WebGatewayTempFile(tdir='test_cache')

    def testFilenameSize(self):
        """
        Make sure slashes, dashes, underscores and other chars don't mess
        things up.
        Also check for filename size limits.
        """
        fname = '1/2_3!"\'#$%&()=@€£‰¶÷[]≠§±+*~^\,.;:'

        try:
            fpath, rpath, fobj = self.tmpfile.new(fname, key='specialchars')
        except:
            raise
            pytest.fail('WebGatewayTempFile.new not handling special'
                        ' characters properly')
        # ext2/3/4 limit is 255 bytes, most others are equal to or larger
        fname = "a"*384
        try:
            fpath, rpath, fobj = self.tmpfile.new(fname, key='longname')
            fobj.close()
            # is it keeping extensions properly?
            fpath, rpath, fobj = self.tmpfile.new(
                "1" + fname + '.tif', key='longname')
            fobj.close()
            assert fpath[-5:] == 'a.tif'
            fpath, rpath, fobj = self.tmpfile.new(
                "2" + fname + '.ome.tiff', key='longname')
            fobj.close()
            assert fpath[-10:] == 'a.ome.tiff'
            fpath, rpath, fobj = self.tmpfile.new(
                "3" + fname + 'ome.tiff', key='longname')
            fobj.close()
            assert fpath[-6:] == 'a.tiff'
            fpath, rpath, fobj = self.tmpfile.new(
                "4" + fname + 'somethingverylong.zip', key='longname')
            fobj.close()
            assert fpath[-5:] == 'a.zip'
            fpath, rpath, fobj = self.tmpfile.new(
                "5" + fname + '.tif.somethingverylong', key='longname')
            fobj.close()
            assert fpath[-5:] == 'aaaaa'
        except:
            pytest.fail('WebGatewayTempFile.new not handling long file names'
                        ' properly')
Exemplo n.º 3
0
class WebGatewayCacheTempFileTest(unittest.TestCase):
    def setUp (self):
        self.tmpfile = WebGatewayTempFile(tdir='test_cache')

    def tearDown (self):
        os.system('rm -fr test_cache')

    def testFilenameSize (self):
        """
        Make sure slashes, dashes, underscores and other chars don't mess things up.
        Also check for filename size limits.
        """
        fname='1/2_3!"\'#$%&()=@€£‰¶÷[]≠§±+*~^\,.;:'

        try:
            fpath, rpath, fobj = self.tmpfile.new(fname, key='specialchars')
        except:
            self.fail('WebGatewayTempFile.new not handling special characters properly')
        # ext2/3/4 limit is 255 bytes, most others are equal to or larger
        fname = "a"*384
        try:
            fpath, rpath, fobj = self.tmpfile.new(fname, key='longname')
            fobj.close()
            # is it keeping extensions properly?
            fpath, rpath, fobj = self.tmpfile.new("1" + fname + '.tif', key='longname')
            fobj.close()
            self.assertEqual(fpath[-5:], 'a.tif')
            fpath, rpath, fobj = self.tmpfile.new("2" + fname + '.ome.tiff', key='longname')
            fobj.close()
            self.assertEqual(fpath[-10:], 'a.ome.tiff')
            fpath, rpath, fobj = self.tmpfile.new("3" + fname + 'ome.tiff', key='longname')
            fobj.close()
            self.assertEqual(fpath[-6:], 'a.tiff')
            fpath, rpath, fobj = self.tmpfile.new("4" + fname + 'somethingverylong.zip', key='longname')
            fobj.close()
            self.assertEqual(fpath[-5:], 'a.zip')
            fpath, rpath, fobj = self.tmpfile.new("5" + fname + '.tif.somethingverylong', key='longname')
            fobj.close()
            self.assertEqual(fpath[-5:], 'aaaaa')
        except:
            self.fail('WebGatewayTempFile.new not handling long file names properly')
Exemplo n.º 4
0
 def setUp (self):
     self.tmpfile = WebGatewayTempFile(tdir='test_cache')
Exemplo n.º 5
0
    def setUp(self, request):
        def fin():
            os.system('rm -fr test_cache')

        request.addfinalizer(fin)
        self.tmpfile = WebGatewayTempFile(tdir='test_cache')
Exemplo n.º 6
0
 def setUp (self, request):
     def fin ():
         os.system('rm -fr test_cache')
     request.addfinalizer(fin)
     self.tmpfile = WebGatewayTempFile(tdir='test_cache')