From 8234754761f9ffb4f2278f937cd92fab920fb5db Mon Sep 17 00:00:00 2001 From: "Jay (OpenERP)" Date: Mon, 27 Sep 2010 22:38:56 +0530 Subject: [PATCH] [REF] Document_ftp bzr revid: jvo@tinyerp.com-20100927170856-cm4lt3ykxdrldmzs --- addons/document_ftp/__openerp__.py | 2 +- .../document_ftp/test/document_ftp_test.yml | 18 +++---- .../document_ftp/test/document_ftp_test2.yml | 2 +- .../document_ftp/test/document_ftp_test3.yml | 48 +++++++++---------- addons/document_ftp/test_easyftp.py | 7 ++- 5 files changed, 38 insertions(+), 39 deletions(-) diff --git a/addons/document_ftp/__openerp__.py b/addons/document_ftp/__openerp__.py index 09c1ca6a66b..798ecba72c3 100644 --- a/addons/document_ftp/__openerp__.py +++ b/addons/document_ftp/__openerp__.py @@ -27,7 +27,7 @@ 'description': """This is a support FTP Interface with document management system. With this module you would not only be able to access documents through OpenERP but you would also be able to connect with them through the file system using the - a FTP client. + FTP client. """, 'author': 'OpenERP SA', 'website': 'http://www.openerp.com', diff --git a/addons/document_ftp/test/document_ftp_test.yml b/addons/document_ftp/test/document_ftp_test.yml index f7c4abb0cdf..b3ff2a89250 100644 --- a/addons/document_ftp/test/document_ftp_test.yml +++ b/addons/document_ftp/test/document_ftp_test.yml @@ -1,7 +1,7 @@ - | - In order to test the document_ftp module in OpenERP, I will try different operation on the FTP interface, and check their impacts on OpenERP's documents and vice-versa. + In order to test the document_ftp module in OpenERP, I will try different operations on the FTP interface and check their impacts on OpenERP's documents and vice-versa. - - In order to test behaviour of resource Directory I will make one resource Directory "Labels" in OpenERP having type "Other Resources" and Directory mapped to object "Partner" + In order to test the behaviour of resource Directory, I will make one resource Directory "Labels" in OpenERP having type "Other Resources" and Directory mapped to object "Partner" - !record {model: 'document.directory', id: dir_label}: name : "Labels" @@ -25,20 +25,20 @@ storage_id : document.storage_default type : directory - - I am create a one Document name "Document" and select "File" as its Directory, + I am create one Document name "Document" and select "File" as its Directory, - - When I am creating the record then "Resource Title" is filled automatic with "Document". + When I am creating the record, "Resource Title" is filled automatic with "Document". - !record {model: 'ir.attachment', id: document_1}: name : "Document" parent_id : directory_file - - In order to connect FTP server and set "File" path. - I create one directory "New" in "File" directory from FTP and check its effect in OpenERP + In order to connect FTP server and set "File" path, + I create one directory "New" in "File" directory from FTP and check its effect in OpenERP. - Also Rename the directory name "New" to "New Directory". - - Remove directory "New Directory" and remove file "Document". + Remove directory "New Directory" and remove file "Document". - !python {model: ir.attachment}: | from ftplib import FTP @@ -64,10 +64,10 @@ In order to check directory created from FTP is working perfectly - Now I will test the same for Resource directory which is mapped with OpenERP object. - When you open this directory from FTP clients, it displays each records of mapped resource object as directory. + When you open this directory from FTP clients, it displays each record of mapped resource object as directory. - Now I test FTP client and Open the "Labels" Directory to check Resource Directory in FTP. - I can see that all Label of OpenERP are shown as children of "Labels" in FTP client as Directories + I can see that all Labels of OpenERP are shown as children of "Labels" in FTP client as Directories. - !python {model: ir.attachment}: | from ftplib import FTP diff --git a/addons/document_ftp/test/document_ftp_test2.yml b/addons/document_ftp/test/document_ftp_test2.yml index 5a4df87fbe4..32434962ba2 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -48,7 +48,7 @@ ftp = te.get_ftp_folder(cr, uid, self, 'Documents') assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcd' - - I append the string 'defgh' into "test.txt" + I append the string 'defgh' to "test.txt" - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te diff --git a/addons/document_ftp/test/document_ftp_test3.yml b/addons/document_ftp/test/document_ftp_test3.yml index 2161c1421da..dbdab370b97 100644 --- a/addons/document_ftp/test/document_ftp_test3.yml +++ b/addons/document_ftp/test/document_ftp_test3.yml @@ -5,10 +5,10 @@ from document_ftp import test_easyftp as te ftp = te.get_plain_ftp(timeout=1.0) - - I create in the server a folder called 'Äïêéìáóôéêüò ÖÜêåëëïò' + I create a folder called '������������ ��������' in the server. - !record {model: document.directory, id: dir_itests }: - name: 'Äïêéìáóôéêüò ÖÜêåëëïò' + name: '������������ ��������' parent_id: document.dir_root - And then I create another folder, under it, through FTP @@ -16,67 +16,67 @@ !python {model: ir.attachment}: | cr.commit() from document_ftp import test_easyftp as te - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò') - ftp.mkd("ÖÜêåëëïò áðü êÜôù") + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������') + ftp.mkd("�������� ��� ����") - I check that this folder exists at the server - - !assert {model: document.directory, id: , search: "[('name','=','ÖÜêåëëïò áðü êÜôù')]" }: + !assert {model: document.directory, id: , search: "[('name','=','�������� ��� ����')]" }: - parent_id != False - - I login with FTP and check that 'Äïêéìáóôéêüò ÖÜêåëëïò' is there + I login with FTP and check that '������������ ��������' is there - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�������� ��� ����') - - I create a file named 'ÄïêéìÞ' into that folder + I create a file named '������' into that folder - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù') - fdata = StringIO('êåßìåíï ìå utf-8') - ftp.storbinary('STOR ÄïêéìÞ.txt', fdata) + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�������� ��� ����') + fdata = StringIO('������� �� utf-8') + ftp.storbinary('STOR ������.txt', fdata) - - I remove the 'ÄïêéìÞ.txt' file + I remove the '������.txt' file - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/ÖÜêåëëïò áðü êÜôù') - ftp.delete('ÄïêéìÞ.txt') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�������� ��� ����') + ftp.delete('������.txt') - - I rename 'ÖÜêåëëïò áðü êÜôù' into 'Üëëïò' + I rename '�������� ��� ����' into '�����' - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò') - ftp.rename("ÖÜêåëëïò áðü êÜôù", "Üëëïò") + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������') + ftp.rename("�������� ��� ����", "�����") - - I place a file 'file Ö3' in 'Üëëïò' + I place a file 'file �3' in '�����' - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò') - fdata = StringIO('êé Üëëï êåßìåíï') - ftp.storbinary('STOR file Ö3.txt', fdata) + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�����') + fdata = StringIO('�� ���� �������') + ftp.storbinary('STOR file �3.txt', fdata) - I rename the file into file+range(1..200) (large filename) - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�����') vuvuzela = 'b'+''.join('z' * 200)+'!' - ftp.rename("file Ö3.txt", vuvuzela) + ftp.rename("file �3.txt", vuvuzela) - I delete the file with the large name - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te from cStringIO import StringIO - ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Äïêéìáóôéêüò ÖÜêåëëïò/Üëëïò') + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/������������ ��������/�����') vuvuzela = 'b'+''.join('z' * 200)+'!' ftp.delete(vuvuzela) diff --git a/addons/document_ftp/test_easyftp.py b/addons/document_ftp/test_easyftp.py index 8d75578718d..c5526371065 100644 --- a/addons/document_ftp/test_easyftp.py +++ b/addons/document_ftp/test_easyftp.py @@ -25,20 +25,19 @@ """ from ftplib import FTP -from tools.misc import detect_ip_addr from tools import config def get_plain_ftp(timeout=10.0): ftp = FTP() host = config.get('ftp_server_host', '127.0.0.1') - port = config.get('ftp_server_port','8021') - ftp.connect(host,port, timeout=timeout) + port = config.get('ftp_server_port', '8021') + ftp.connect(host, port, timeout=timeout) return ftp def get_ftp_login(cr, uid, ormobj): ftp = get_plain_ftp() user = ormobj.pool.get('res.users').read(cr, uid, uid) - ftp.login(user.get('login',''),user.get('password','')) + ftp.login(user.get('login',''), user.get('password','')) ftp.cwd("/" + cr.dbname) return ftp