Exemplo n.º 1
0
 def testManageAfterCloneUsesMainFileIfTempFileNotPresent(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     transaction.savepoint(1) # Need a _p_oid
     self.subfolder.manage_clone(self.file, 'file')
     self.failUnless(self._exists('file.exe'))       # original
     self.failUnless(self._exists('file.1.exe.tmp'))  # copy
Exemplo n.º 2
0
 def testManageAfterCloneUsesTempPreviewAsSource(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     transaction.savepoint(1) # Need a _p_oid
     self.subfolder.manage_clone(self.image, 'image')
     self.failUnless(self._exists('image.jpg.tmp'))  # original
     self.failUnless(self._exists('image.1.jpg.tmp')) # copy
Exemplo n.º 3
0
 def afterSetUp(self):
     ExtFileTestCase.afterSetUp(self)
     self.folder.manage_addFolder('subfolder')
     self.subfolder = self.folder['subfolder']
     self.setPermissions(copymove_perms)
     self.addExtFile(id='image.gif', file=gifImage)
     transaction.savepoint(1) # need a _p_jar
Exemplo n.º 4
0
 def testAddImageAbort(self):
     # Aborting the transaction leaves the repository empty
     self.addExtImage(id='image', file=gifImage)
     transaction.savepoint(1)   # Wuhuu, force object rollback
     transaction.abort()
     self.failIf(hasattr(aq_base(self.folder), 'image'))
     self.failIf(self._exists('image.gif'))
     self.failIf(self._exists('image.gif.tmp'))
Exemplo n.º 5
0
 def testManageAfterCloneTriesToUndoIfTempFileNotPresent(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     os.rename(self._fsname('file.exe'), self._fsname('file.exe.undo'))
     transaction.savepoint(1) # Need a _p_oid
     self.subfolder.manage_clone(self.file, 'file')
     self.failUnless(self._exists('file.exe.tmp'))   # restored original
     self.failUnless(self._exists('file.1.exe.tmp'))  # copy
Exemplo n.º 6
0
 def testManageAfterCloneTriesToUndoIfTempPreviewNotPresent(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     self.image._finish()
     os.rename(self._fsname('image.jpg'), self._fsname('image.jpg.undo'))
     transaction.savepoint(1) # Need a _p_oid
     self.subfolder.manage_clone(self.image, 'image')
     self.failUnless(self._exists('image.jpg.tmp'))  # restored original
     self.failUnless(self._exists('image.1.jpg.tmp')) # copy
Exemplo n.º 7
0
 def testManageAfterCloneRegistersWithTM(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     self.file._v_begin_called = 0   # Clear
     TM.remove(self.file)            # Clear
     transaction.savepoint(1) # Need a _p_oid
     self.assertEqual(getattr(self.subfolder.file, '_v_begin_called', 0), 0)
     self.subfolder.manage_clone(self.file, 'file')
     self.assertEqual(getattr(self.subfolder.file, '_v_begin_called', 0), 1)
Exemplo n.º 8
0
 def testManageAfterCloneCreatesTempFile(self):
     self.addExtFile(id='file', file=notImage)
     self.file._finish()
     transaction.savepoint(1) # Need a _p_oid
     cb = self.folder.manage_copyObjects(['file'])
     self.subfolder.manage_pasteObjects(cb)
     self.failUnless(self._exists('file.exe'))       # original
     self.failUnless(self._exists('file.1.exe.tmp'))  # copy
     self.assertEqual(self.subfolder.file.filename, ['file.1.exe'])
Exemplo n.º 9
0
 def testManageAfterCloneCreatesTempPreview(self):
     self.addExtImage(id='image', file='')
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     self.image._finish()
     transaction.savepoint(1) # Need a _p_oid
     cb = self.folder.manage_copyObjects(['image'])
     self.subfolder.manage_pasteObjects(cb)
     self.failUnless(self._exists('image.jpg'))      # original
     self.failUnless(self._exists('image.1.jpg.tmp')) # copy
     self.assertEqual(self.subfolder.image.prev_filename, ['image.1.jpg'])
Exemplo n.º 10
0
 def testAddImageAbortWithPreview(self):
     # Aborting the transaction leaves the repository empty
     self.addExtImage(id='image', file=gifImage)
     self.image.manage_create_prev(maxx=10, maxy=10)
     transaction.savepoint(1)   # Wuhuu, force object rollback
     transaction.abort()
     self.failIf(hasattr(aq_base(self.folder), 'image'))
     self.failIf(self._exists('image.gif'))
     self.failIf(self._exists('image.gif.tmp'))
     self.failIf(self._exists('image.jpg'))
     self.failIf(self._exists('image.jpg.tmp'))
Exemplo n.º 11
0
 def afterSetUp(self):
     ExtFileTestCase.afterSetUp(self)
     self.folder.manage_addFolder('subfolder')
     self.subfolder = self.folder['subfolder']
     self.setPermissions(copymove_perms)
     self.addExtImage(id='image.gif', file=gifImage)
     # Add a preview image as well
     self.folder['image.gif'].manage_file_upload(file=jpegImage, is_preview=1,
                                                 create_prev=UPLOAD_RESIZE,
                                                 maxx=100, maxy=100, ratio=1)
     transaction.savepoint(1) # need a _p_jar
Exemplo n.º 12
0
 def testManageAfterCloneUsesTempPreviewIfOneFile(self):
     # XXX: Fishy. It seems this tests an impossible state
     self.addExtImage(id='image', file=jpegImage)
     self.image.manage_file_upload(file=jpegImage, is_preview=1)
     # Simulate main and preview being one file
     self.image.prev_filename = ['image.2.jpg']
     transaction.savepoint(1) # Need a _p_oid
     self.subfolder.manage_clone(self.image, 'image')
     self.failUnless(self._exists('image.jpg.tmp'))  # original
     self.failUnless(self._exists('image.1.jpg.tmp')) # original preview
     self.failUnless(self._exists('image.2.jpg.tmp')) # copy
     self.assertEqual(self.subfolder.image.prev_filename, ['image.2.jpg'])
     self.assertEqual(self.subfolder.image.filename, ['image.2.jpg'])
Exemplo n.º 13
0
 def afterSetUp(self):
     # A folder that does not verify pastes
     self.folder._setObject('folder', TestFolder('folder'))
     self.folder = getattr(self.folder, 'folder')
     # The subfolder we are going to copy/move to
     self.folder._setObject('subfolder', TestFolder('subfolder'))
     self.subfolder = self.folder['subfolder']
     # The document we are going to copy/move
     self.folder._setObject('mydoc', TestItem('mydoc'))
     # Set some permissions
     self.setPermissions(copymove_perms)
     # Need _p_jars
     transaction.savepoint(1)
     # Reset counters
     self.folder.mydoc.reset()