def DISABLED_testManageHTTPUploadRegistersPreviewWithTMIfAutogen(self): self.addExtImage(id='image', file='') self.image.manage_file_upload(file=jpegImage, is_preview=1) self.image._v_begin_called = 0 # Clear TM.remove(self.image) # Clear self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0) self.image.manage_http_upload(url=self.app.GifImage.absolute_url()) self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
def testCreatePrevRegistersWithTM(self): self.addExtImage(id='image', file=jpegImage) self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1) self.image._v_begin_called = 0 # Clear TM.remove(self.image) # Clear self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0) self.image.manage_create_prev(maxx=10, maxy=10) self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
def testUndoRegistersWithTM(self): self.addExtFile(id='file', file=notImage) os.rename(self._fsname('file.exe.tmp'), self._fsname('file.exe.undo')) self.file._v_begin_called = 0 # Clear TM.remove(self.file) # Clear self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0) self.file._undo() self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1) self.failUnless(self._exists('file.exe.tmp'))
def testUndoRegistersWithTM(self): self.addExtFile(id='file', file=notImage) os.rename(self._fsname('file.exe.tmp'), self._fsname('file.exe.undo')) self.file._v_begin_called = 0 # Clear TM.remove(self.file) # Clear self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0) self.file._undo(self.file.filename) self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1) self.failUnless(self._exists('file.exe.tmp'))
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)
def DISABLED_testPUTRegistersPreviewWithTMIfAutogen(self): self.addExtImage(id='image', file='') self.image.manage_file_upload(file=jpegImage, is_preview=1) self.image._v_begin_called = 0 # Clear TM.remove(self.image) # Clear request = self.app.REQUEST request['BODYFILE'] = open(jpegImage, 'rb') self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0) self.image.PUT(request, request.RESPONSE) self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1)
def testUndoRegistersPreviewWithTM(self): self.addExtImage(id='image', file='') self.image.manage_file_upload(file=jpegImage, is_preview=1) os.rename(self._fsname('image.jpg.tmp'), self._fsname('image.jpg.undo')) self.image._v_begin_called = 0 # Clear TM.remove(self.image) # Clear self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0) self.image._undo() self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1) self.failUnless(self._exists('image.jpg.tmp'))
def testUndoRegistersPreviewWithTM(self): self.addExtImage(id='image', file='') self.image.manage_file_upload(file=jpegImage, is_preview=1) os.rename(self._fsname('image.jpg.tmp'), self._fsname('image.jpg.undo')) self.image._v_begin_called = 0 # Clear TM.remove(self.image) # Clear self.assertEqual(getattr(self.image, '_v_begin_called', 0), 0) self.image._undo(self.image.prev_filename) self.assertEqual(getattr(self.image, '_v_begin_called', 0), 1) self.failUnless(self._exists('image.jpg.tmp'))
def testGetUfnRegistersWithTM(self): self.addExtFile(id='file', file=notImage) self.file._finish() self.file._v_begin_called = 0 # Clear TM.remove(self.file) # Clear self.file._delete(self.file.filename) # _get_ufn will attempt to undo self.assertEqual(getattr(self.file, '_v_begin_called', 0), 0) self.failUnless(self._exists('file.exe.undo')) self.file._get_ufn(self.file.filename) self.assertEqual(getattr(self.file, '_v_begin_called', 0), 1) self.failUnless(self._exists('file.exe.tmp')) self.failIf(self._exists('file.exe.undo'))
def _abort(self): """ Deletes the temporary file """ self._v_abort_called = 1 # for tests TM.remove(self) # for tests if self.filename: tmp_fn = self._temp_fsname(self.filename) if _debug: logger.info('aborting %s' % tmp_fn) if isfile(tmp_fn): if _debug: logger.info('isfile %s' % tmp_fn) try: os.remove(tmp_fn) except OSError: logger.error('_abort', exc_info=True)
def _abort(self): """ Deletes the temporary file """ self._v_abort_called = 1 # for tests TM.remove(self) # for tests if self.filename: tmp_fn = self._temp_fsname(self.filename) if _debug: LOG(_SUBSYS, INFO, "aborting %s" % tmp_fn) if isfile(tmp_fn): if _debug: LOG(_SUBSYS, INFO, "isfile %s" % tmp_fn) try: os.remove(tmp_fn) except OSError: pass
def _finish(self): """ Commits the temporary file """ self._v_finish_called = 1 # for tests TM.remove(self) # for tests if self.filename: tmp_fn = self._temp_fsname(self.filename) if _debug: LOG(_SUBSYS, INFO, "finishing %s" % tmp_fn) if isfile(tmp_fn): if _debug: LOG(_SUBSYS, INFO, "isfile %s" % tmp_fn) fn = self._fsname(self.filename) try: os.remove(fn) except OSError: pass os.rename(tmp_fn, fn)
def testUploadFileIntoExistingInSeparateTransactions(self): # Create a file 'fred' self.addExtFile(id='fred', file=notImage) self.failUnless(TM.contains(self.file)) self.failUnless(self._exists('fred.exe.tmp')) transaction.commit() self.failIf(TM.contains(self.file)) self.failUnless(self._exists('fred.exe')) self.failIf(self._exists('fred.exe.tmp')) # Upload new file into 'fred' self.file.manage_file_upload(file=gifImage) self.failUnless(TM.contains(self.file)) self.failUnless(self._exists('fred.exe')) self.failUnless(self._exists('fred.exe.tmp')) transaction.commit() self.failIf(TM.contains(self.file)) self.failUnless(self._exists('fred.exe')) self.failIf(self._exists('fred.exe.tmp'))
def _finish(self): """ Commits the temporary file """ self._v_finish_called = 1 # for tests TM.remove(self) # for tests if self.filename: tmp_fn = self._temp_fsname(self.filename) if _debug: logger.info('finishing %s' % tmp_fn) if isfile(tmp_fn): if _debug: logger.info('isfile %s' % tmp_fn) fn = self._fsname(self.filename) if isfile(fn): try: os.remove(fn) except OSError: logger.error('_finish', exc_info=True) try: os.rename(tmp_fn, fn) except OSError: logger.error('_finish', exc_info=True)
def _register(self): if _debug: logger.info('registering %s' % TM.contains(self)) TM.register(self) if _debug: logger.info('registered %s' % TM.contains(self))
def _register(self): if _debug: LOG(_SUBSYS, INFO, "registering %s" % TM.contains(self)) TM.register(self) if _debug: LOG(_SUBSYS, INFO, "registered %s" % TM.contains(self))