From 313897186c307afec4b5211f7db9df42c5f83844 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Wed, 30 Nov 2011 13:02:44 +0100 Subject: [IMP] document_ftp: improve/sanitize transaction management during tests Now that spurious commits were removed in document module, the test would not run properly anymore. We do need special care with transactions when we test the FTP layer because operations on the virtual FS are done in their own transaction, and immediately committed. In order for test code and FTP operations to be able to see each other, the transactions need to be synchronized. The current test transaction needs to be rolled back or committed after reach FTP operation so it can "see" the latest changes in the database. Similarly, we must force a commit of the test transaction whenever we want the FTP layer to be able to see its effects. bzr revid: odo@openerp.com-20111130120244-3m15sxdx1x5x1q1x --- addons/document_ftp/test/document_ftp_test2.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'addons/document_ftp/test/document_ftp_test2.yml') diff --git a/addons/document_ftp/test/document_ftp_test2.yml b/addons/document_ftp/test/document_ftp_test2.yml index 33ce1416ec8..eb86a99407d 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -100,11 +100,11 @@ fdata = StringIO('abcd') ftp.storbinary('STOR test2.txt', fdata) ftp.close() - cr.commit() - I look for the "test2.txt" file at the server - !python {model: ir.attachment }: | + cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor) ids = self.search(cr, uid, [('name', '=', 'test2.txt')]) assert ids, "No test2.txt file found." - @@ -116,11 +116,11 @@ ftp = te.get_ftp_folder(cr, uid, self, 'Documents') ftp.delete('test2.txt') ftp.close() - cr.commit() - I check at the server that test2.txt is deleted - !python {model: ir.attachment }: | + cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor) ids = self.search(cr, uid, [('name', '=', 'test2.txt')]) assert not ids, "test2.txt file can still be found." - @@ -133,7 +133,7 @@ fdata = StringIO('abcd') ftp.storbinary('STOR test2.txt', fdata) ftp.close() - cr.commit() + cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor) - I delete the test2.txt from the server (RPC). - -- cgit v1.2.3