From 4d99b09045d55fc56bab863c7cbfbfe8145b25c0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 29 Jun 2010 17:00:49 +0300 Subject: Document, FTP: text skeleton of trivial yaml tests. bzr revid: p_christ@hol.gr-20100629140049-dowvybyjh6bncyrb --- addons/document_ftp/test/document_ftp_test2.yml | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 addons/document_ftp/test/document_ftp_test2.yml (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 new file mode 100644 index 00000000000..4f77fdbb723 --- /dev/null +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -0,0 +1,62 @@ +- + In order to test the document_ftp functionality +- + I open the 8021 port and see for ftp presence there +- + I read the list of databases at port 8021 and confirm our db is + there +- + I try to locate the default "Documents" folder in the db. +- + I create a "test.txt" file at the server (directly). The file + should have the "abcd" content +- + I look for the "test.txt" file at the server +- + I check that the content of "test.txt" is "abcd" +- + I try to cd into an non-existing folder 'Not-This' +- + I create a "test2.txt" file through FTP. +- + I look for the "test2.txt" file at the server +- + I look for the "test2.txt" file through FTP. +- + I delete the "test2.txt" file using FTP. +- + I check at the server that test2.txt is deleted +- + I create a test2.txt file again. +- + I delete the test2.txt from the server (RPC). +- + I check through FTP that test2.txt does not appear. +- + I create a "test-name.txt" file +- + I rename the "test-name.txt" file through ftp. +- + I check that test-name.txt has been renamed. +- + I create a new folder 'Test-Folder2' through FTP +- + I create a file 'test3.txt' at the 'Test-Folder2' +- + I try to retrieve test3.txt +- + I create a new folder, 'Test-Folder3', through FTP + I try to move test3.txt to 'Test-Folder3' +- + I remove the 'Test-Folder3' +- + I check that test3.txt is removed. +- + I create 1000 files through FTP +- + I list the 1000 files, check speed +- + I read the 1000 files, check speed +- + I move the 1000 files to 'Test-Folder2' +- \ No newline at end of file -- cgit v1.2.3 From 0c0a6dcd7fbdcd10bba0eabd7ccc91775d6a7b3b Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 29 Jun 2010 17:01:34 +0300 Subject: Document FTP: one more test case, skeleton. bzr revid: p_christ@hol.gr-20100629140134-38zbsp7pvw1svgfv --- addons/document_ftp/test/document_ftp_test2.yml | 4 ++++ 1 file changed, 4 insertions(+) (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 4f77fdbb723..1b871ec14bd 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -14,6 +14,10 @@ I look for the "test.txt" file at the server - I check that the content of "test.txt" is "abcd" +- + I append the string 'defgh' into "test.txt" +- + I check that the content of "text.txt" is 'abcdefgh' - I try to cd into an non-existing folder 'Not-This' - -- cgit v1.2.3 From 35c932d76a63bed6210943efdbd1b7b162ca828d Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 2 Jul 2010 01:42:49 +0300 Subject: Document FTP: write Yaml tests, have special helper module. bzr revid: p_christ@hol.gr-20100701224249-fmble80t8nlg2azq --- addons/document_ftp/test/document_ftp_test2.yml | 151 +++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 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 1b871ec14bd..e0b3b72b320 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -2,65 +2,212 @@ In order to test the document_ftp functionality - I open the 8021 port and see for ftp presence there +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_plain_ftp() + assert ftp.sock and (ftp.lastresp == '220'), ftp.lastresp - I read the list of databases at port 8021 and confirm our db is there +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_login(cr, uid, self) + assert cr.dbname in ftp.nlst("/") - I try to locate the default "Documents" folder in the db. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_login(cr, uid, self) + ftp.cwd('/Documents') - I create a "test.txt" file at the server (directly). The file should have the "abcd" content +- + !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('abcd') + ftp.storbinary('STOR test.txt', fdata) - I look for the "test.txt" file at the server +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert ftp.nlst("test.txt") == ['test.txt'] - I check that the content of "test.txt" is "abcd" +- + !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') + assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcd' - I append the string 'defgh' into "test.txt" - - I check that the content of "text.txt" is 'abcdefgh' + !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('defgh') + ftp.storbinary('APPE test.txt', fdata) +- + I check that the content of "text.txt" is 'abcddefgh' +- + !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') + assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcddefgh' - I try to cd into an non-existing folder 'Not-This' +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_login(cr, uid, self) + try: + ftp.cwd('/Not-This') + assert False, "We should't be able to change here" + except OSError, err: + assert err.errno == 2, err.errno - I create a "test2.txt" file through FTP. +- + !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('abcd') + ftp.storbinary('STOR test2.txt', fdata) - I look for the "test2.txt" file at the server - - I look for the "test2.txt" file through FTP. + !python {model: ir.attachment }: | + ids = self.search(cr, uid, [('name', '=', 'test2.txt')]) + assert ids - I delete the "test2.txt" file using FTP. +- + !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('test2.txt') - I check at the server that test2.txt is deleted +- + !python {model: ir.attachment }: | + ids = self.search(cr, uid, [('name', '=', 'test2.txt')]) + assert not ids - I create a test2.txt file again. +- + !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('abcd') + ftp.storbinary('STOR test2.txt', fdata) - I delete the test2.txt from the server (RPC). +- + !delete { model: ir.attachment, id:, search: "[('name','=','test2.txt')]" } - I check through FTP that test2.txt does not appear. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert ftp.nlst("test2.txt") == [] - I create a "test-name.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') + fdata = StringIO('abcd') + ftp.storbinary('STOR test-name.txt', fdata) - I rename the "test-name.txt" file through ftp. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.rename("test-name.txt", "test-renamed.txt") - I check that test-name.txt has been renamed. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert ftp.nlst("test-name.txt") == [] + assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt'] - I create a new folder 'Test-Folder2' through FTP +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.mkd("Test-Folder2") - I create a file 'test3.txt' at the 'Test-Folder2' +- + !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/Test-Folder2') + fdata = StringIO('abcd') + ftp.storbinary('STOR test3.txt', fdata) - I try to retrieve test3.txt +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') + assert ftp.nlst("test3.txt") == ['test3.txt'] - I create a new folder, 'Test-Folder3', through FTP I try to move test3.txt to 'Test-Folder3' +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.mkd("Test-Folder2") + # TODO move - I remove the 'Test-Folder3' - I check that test3.txt is removed. - I create 1000 files through FTP +- + !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/Test-Folder2') + fdata = StringIO('abcd') + # TODO speed + for i in range(0, 1000): + fdata.seek(0) + ftp.storbinary('STOR test-name%s.txt' %i, fdata) - I list the 1000 files, check speed +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') + # TODO speed + assert len(ftp.nlst() > 1000) - I read the 1000 files, check speed + # TODO - I move the 1000 files to 'Test-Folder2' + # TODO - \ No newline at end of file -- cgit v1.2.3 From 45b7a3adc3a8e3669d15598d67f99513856fbab0 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Sat, 3 Jul 2010 00:53:04 +0300 Subject: Document FTP: improve the tests Now, a non-existing path will return 550, an exception. bzr revid: p_christ@hol.gr-20100702215304-7l2pit3ceih3wvo9 --- addons/document_ftp/test/document_ftp_test2.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 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 e0b3b72b320..a5eaa13521f 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -145,8 +145,13 @@ - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te + from ftplib import error_perm ftp = te.get_ftp_folder(cr, uid, self, 'Documents') - assert ftp.nlst("test-name.txt") == [] + try: + res = ftp.nlst("test-name.txt") + assert res == [] + except error_perm, e: + pass assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt'] - I create a new folder 'Test-Folder2' through FTP @@ -203,7 +208,7 @@ from document_ftp import test_easyftp as te ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') # TODO speed - assert len(ftp.nlst() > 1000) + assert len(ftp.nlst()) > 1000 - I read the 1000 files, check speed # TODO -- cgit v1.2.3 From 950058dae348bfb856ce5cf9c120822d7a147f6f Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 6 Jul 2010 15:10:53 +0300 Subject: Document FTP: fix yaml tests. bzr revid: p_christ@hol.gr-20100706121053-5a9z29ub8hrnpqo9 --- addons/document_ftp/test/document_ftp_test2.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (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 a5eaa13521f..8b7d538c00b 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -21,7 +21,7 @@ !python {model: ir.attachment}: | from document_ftp import test_easyftp as te ftp = te.get_ftp_login(cr, uid, self) - ftp.cwd('/Documents') + ftp.cwd('Documents') - I create a "test.txt" file at the server (directly). The file should have the "abcd" content @@ -69,10 +69,13 @@ - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te + import ftplib ftp = te.get_ftp_login(cr, uid, self) try: ftp.cwd('/Not-This') assert False, "We should't be able to change here" + except ftplib.error_perm: + pass except OSError, err: assert err.errno == 2, err.errno - -- cgit v1.2.3 From 74b2dcfd80ff8e76089b0094c00f60ee02743997 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Fri, 9 Jul 2010 11:23:56 +0300 Subject: Document ftp: Only test with 200 files, todo comment. bzr revid: p_christ@hol.gr-20100709082356-p6xij5d22spqxrrx --- addons/document_ftp/test/document_ftp_test2.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 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 8b7d538c00b..544c61e38eb 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -193,7 +193,7 @@ - I check that test3.txt is removed. - - I create 1000 files through FTP + I create 200 files through FTP - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te @@ -201,21 +201,21 @@ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') fdata = StringIO('abcd') # TODO speed - for i in range(0, 1000): + for i in range(0, 200): fdata.seek(0) ftp.storbinary('STOR test-name%s.txt' %i, fdata) - - I list the 1000 files, check speed + I list the 200 files, check speed - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') # TODO speed - assert len(ftp.nlst()) > 1000 + assert len(ftp.nlst()) > 200 - - I read the 1000 files, check speed + I read the 200 files, check speed # TODO - - I move the 1000 files to 'Test-Folder2' + I move the 200 files to 'Test-Folder2' # TODO - \ No newline at end of file -- cgit v1.2.3 From 0e8b07f4908aa318870e370aca24c545948267a3 Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 13 Jul 2010 13:30:16 +0300 Subject: Document ftp: have timeout at tests, skip if server is not available. At trunk-xrg, the FTP daemon is only started *after* the db is loaded, which means that it will not be available for tests on a server upgrade. (still, tests can be performed through the base_module_record's importer) Anyway, it is not wise to block the server startup if FTP doesn't respond. bzr revid: p_christ@hol.gr-20100713103016-33gu4o7yvkn7hmnd --- addons/document_ftp/test/document_ftp_test2.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 544c61e38eb..55a77d6b73e 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -5,7 +5,7 @@ - !python {model: ir.attachment}: | from document_ftp import test_easyftp as te - ftp = te.get_plain_ftp() + ftp = te.get_plain_ftp(timeout=2.0) assert ftp.sock and (ftp.lastresp == '220'), ftp.lastresp - I read the list of databases at port 8021 and confirm our db is -- cgit v1.2.3 From 10eea231091570db9740c7fe6b5e7ed640af898e Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Tue, 13 Jul 2010 23:54:21 +0300 Subject: Document tests: remove last, empty block This just suppresses a warning. bzr revid: p_christ@hol.gr-20100713205421-th0c0vuohsum3vj8 --- addons/document_ftp/test/document_ftp_test2.yml | 3 +-- 1 file changed, 1 insertion(+), 2 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 55a77d6b73e..e9ac2d84582 100644 --- a/addons/document_ftp/test/document_ftp_test2.yml +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -217,5 +217,4 @@ # TODO - I move the 200 files to 'Test-Folder2' - # TODO -- \ No newline at end of file + # TODO \ No newline at end of file -- cgit v1.2.3