Commit 5afebc71 authored by Jérome Perrin's avatar Jérome Perrin

testDms

parent 43d8c9ce
...@@ -31,11 +31,10 @@ ...@@ -31,11 +31,10 @@
import unittest import unittest
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from erp5.component.test.testDms import DocumentUploadTestCase
from erp5.component.test.testDms import makeFileUpload
class TestERP5Discussion(ERP5TypeTestCase): class TestERP5Discussion(DocumentUploadTestCase):
"""Test for erp5_discussion business template. """Test for erp5_discussion business template.
""" """
...@@ -143,7 +142,7 @@ class TestERP5Discussion(ERP5TypeTestCase): ...@@ -143,7 +142,7 @@ class TestERP5Discussion(ERP5TypeTestCase):
self.assertEqual(0, len(attachment_list)) self.assertEqual(0, len(attachment_list))
# check attachment creation # check attachment creation
file_ = makeFileUpload('TEST-en-002.doc') file_ = self.makeFileUpload('TEST-en-002.doc')
web_section1.WebSection_createNewDiscussionThread('test1-new-with-attachment', 'test1 body', file=file_) web_section1.WebSection_createNewDiscussionThread('test1-new-with-attachment', 'test1 body', file=file_)
discussion_thread, = [x for x in self.portal.discussion_thread_module.objectValues() \ discussion_thread, = [x for x in self.portal.discussion_thread_module.objectValues() \
if x.getId() not in discussion_thread_id_set] if x.getId() not in discussion_thread_id_set]
...@@ -240,7 +239,7 @@ class TestERP5Discussion(ERP5TypeTestCase): ...@@ -240,7 +239,7 @@ class TestERP5Discussion(ERP5TypeTestCase):
web_site_value = self.portal.web_site_module.newContent(portal_type='Web Site') web_site_value = self.portal.web_site_module.newContent(portal_type='Web Site')
web_section_value = web_site_value.newContent(portal_type='Web Section') web_section_value = web_site_value.newContent(portal_type='Web Section')
file_ = makeFileUpload('simple.csv') file_ = self.makeFileUpload('simple.csv')
web_section_value.WebSection_createNewDiscussionThread( web_section_value.WebSection_createNewDiscussionThread(
"Thread Title", "Thread Title",
"Post Content", "Post Content",
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
import unittest import unittest
from DateTime import DateTime from DateTime import DateTime
from erp5.component.test.testDms import TestDocumentMixin, makeFileUpload from erp5.component.test.testDms import TestDocumentMixin
try: try:
import magic import magic
...@@ -59,7 +59,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -59,7 +59,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
def test_image_conversion(self): def test_image_conversion(self):
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
self.tic() self.tic()
format_ = 'png' format_ = 'png'
...@@ -96,7 +96,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -96,7 +96,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
Test Conversion Cache mechanism Test Conversion Cache mechanism
""" """
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
self.tic() self.tic()
document_url = document.getRelativeUrl() document_url = document.getRelativeUrl()
...@@ -129,7 +129,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -129,7 +129,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
def test_02_VolatileCacheConversionOfTempObject(self): def test_02_VolatileCacheConversionOfTempObject(self):
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_, temp_object=1) document = self.portal.portal_contributions.newContent(file=file_, temp_object=1)
document.uploadFile() document.uploadFile()
document.processFile() document.processFile()
...@@ -163,8 +163,8 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -163,8 +163,8 @@ class TestDocumentConversionCache(TestDocumentMixin):
def test_03_CacheConversionOfTempObjectIsNotMixed(self): def test_03_CacheConversionOfTempObjectIsNotMixed(self):
filename1 = 'TEST-en-002.doc' filename1 = 'TEST-en-002.doc'
filename2 = 'TEST-en-002.odt' filename2 = 'TEST-en-002.odt'
file1 = makeFileUpload(filename1) file1 = self.makeFileUpload(filename1)
file2 = makeFileUpload(filename2) file2 = self.makeFileUpload(filename2)
document1 = self.portal.portal_contributions.newContent(file=file1, temp_object=1) document1 = self.portal.portal_contributions.newContent(file=file1, temp_object=1)
document1.uploadFile() document1.uploadFile()
document1.processFile() document1.processFile()
...@@ -187,7 +187,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -187,7 +187,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.tic() self.tic()
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
self.tic() self.tic()
document_url = document.getRelativeUrl() document_url = document.getRelativeUrl()
...@@ -223,7 +223,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -223,7 +223,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
Test Conversion Cache return expected value with checksum Test Conversion Cache return expected value with checksum
""" """
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
self.tic() self.tic()
document_url = document.getRelativeUrl() document_url = document.getRelativeUrl()
...@@ -252,7 +252,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -252,7 +252,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
Check that md5 checksum is well updated when upload a file Check that md5 checksum is well updated when upload a file
""" """
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
self.tic() self.tic()
document_url = document.getRelativeUrl() document_url = document.getRelativeUrl()
...@@ -260,7 +260,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -260,7 +260,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
md5sum = document.getContentMd5() md5sum = document.getContentMd5()
self.assertTrue(md5sum) self.assertTrue(md5sum)
filename2 = 'TEST-en-002.odt' filename2 = 'TEST-en-002.odt'
file2 = makeFileUpload(filename2) file2 = self.makeFileUpload(filename2)
document.edit(file=file2) document.edit(file=file2)
self.assertNotEqual(md5sum, document.getContentMd5()) self.assertNotEqual(md5sum, document.getContentMd5())
self.tic() self.tic()
...@@ -275,7 +275,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -275,7 +275,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self.portal.portal_caches.clearAllCache() self.portal.portal_caches.clearAllCache()
self.tic() self.tic()
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document_id = 'an id with spaces' document_id = 'an id with spaces'
portal_type = 'Text' portal_type = 'Text'
module = self.portal.getDefaultModule(portal_type) module = self.portal.getDefaultModule(portal_type)
...@@ -314,7 +314,7 @@ class TestDocumentConversionCache(TestDocumentMixin): ...@@ -314,7 +314,7 @@ class TestDocumentConversionCache(TestDocumentMixin):
self.assertEqual(len(portal_type_list), len([pt for pt in portal_type_list if pt in data_mapping])) self.assertEqual(len(portal_type_list), len([pt for pt in portal_type_list if pt in data_mapping]))
for portal_type in portal_type_list: for portal_type in portal_type_list:
module = self.portal.getDefaultModule(portal_type=portal_type) module = self.portal.getDefaultModule(portal_type=portal_type)
upload_file = makeFileUpload(data_mapping[portal_type]) upload_file = self.makeFileUpload(data_mapping[portal_type])
document = module.newContent(portal_type=portal_type) document = module.newContent(portal_type=portal_type)
document.edit(file=upload_file) document.edit(file=upload_file)
self.tic() self.tic()
......
...@@ -25,12 +25,11 @@ ...@@ -25,12 +25,11 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from erp5.component.test.testDms import DocumentUploadTestCase
from erp5.component.test.testDms import makeFileUpload
from Products.ERP5Form.PreferenceTool import Priority from Products.ERP5Form.PreferenceTool import Priority
class TestOOoConversionServerRetry(ERP5TypeTestCase): class TestOOoConversionServerRetry(DocumentUploadTestCase):
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
business_template_list = ['erp5_core_proxy_field_legacy', business_template_list = ['erp5_core_proxy_field_legacy',
'erp5_jquery', 'erp5_jquery',
...@@ -80,7 +79,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase): ...@@ -80,7 +79,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
self.tic() self.tic()
filename = 'monochrome_sample.tiff' filename = 'monochrome_sample.tiff'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.document_module.newContent(portal_type='Text') document = self.portal.document_module.newContent(portal_type='Text')
document.edit(file = file_) document.edit(file = file_)
message = document.Document_tryToConvertToBaseFormat() message = document.Document_tryToConvertToBaseFormat()
...@@ -95,7 +94,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase): ...@@ -95,7 +94,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
system_pref.setPreferredDocumentConversionServerUrlList(['https://broken.url']) system_pref.setPreferredDocumentConversionServerUrlList(['https://broken.url'])
self.tic() self.tic()
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
message = document.Document_tryToConvertToBaseFormat() message = document.Document_tryToConvertToBaseFormat()
...@@ -110,7 +109,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase): ...@@ -110,7 +109,7 @@ class TestOOoConversionServerRetry(ERP5TypeTestCase):
system_pref.setPreferredOoodocServerTimeout(1) system_pref.setPreferredOoodocServerTimeout(1)
self.tic() self.tic()
filename = 'TEST-en-002.doc' filename = 'TEST-en-002.doc'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document = self.portal.portal_contributions.newContent(file=file_) document = self.portal.portal_contributions.newContent(file=file_)
message = document.Document_tryToConvertToBaseFormat() message = document.Document_tryToConvertToBaseFormat()
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
############################################################################## ##############################################################################
import unittest import unittest
from erp5.component.test.testDms import TestDocument, makeFileUpload from erp5.component.test.testDms import TestDocument
class TestDocumentWithPreConversion(TestDocument): class TestDocumentWithPreConversion(TestDocument):
""" """
...@@ -40,7 +40,7 @@ class TestDocumentWithPreConversion(TestDocument): ...@@ -40,7 +40,7 @@ class TestDocumentWithPreConversion(TestDocument):
def test_preConvertedReferencedImageInWebPageContent(self): def test_preConvertedReferencedImageInWebPageContent(self):
# create an image # create an image
upload_file = makeFileUpload('cmyk_sample.jpg') upload_file = self.makeFileUpload('cmyk_sample.jpg')
image = self.portal.image_module.newContent(portal_type='Image', image = self.portal.image_module.newContent(portal_type='Image',
reference='Embedded-XXX', reference='Embedded-XXX',
version='001', version='001',
...@@ -75,7 +75,7 @@ class TestDocumentWithPreConversion(TestDocument): ...@@ -75,7 +75,7 @@ class TestDocumentWithPreConversion(TestDocument):
language='en') language='en')
# draft image is not convertible # draft image is not convertible
upload_file = makeFileUpload('cmyk_sample.jpg') upload_file = self.makeFileUpload('cmyk_sample.jpg')
image.edit(file=upload_file) image.edit(file=upload_file)
self.tic() self.tic()
self.assertEqual(False, image.Base_isConvertible()) self.assertEqual(False, image.Base_isConvertible())
......
...@@ -31,7 +31,7 @@ import unittest ...@@ -31,7 +31,7 @@ import unittest
from unittest import expectedFailure from unittest import expectedFailure
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.Base import TempBase from Products.ERP5Type.Base import TempBase
from erp5.component.test.testDms import makeFileUpload, TestDocumentMixin from erp5.component.test.testDms import TestDocumentMixin
def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget): def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget):
""" Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad.""" """ Get Knowledge Box's relative URL specialising a gadget in a Knowledge Pad."""
...@@ -39,6 +39,7 @@ def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget): ...@@ -39,6 +39,7 @@ def _getGadgetInstanceUrlFromKnowledgePad(knowledge_pad, gadget):
portal_type = 'Knowledge Box', portal_type = 'Knowledge Box',
specialise_uid = gadget.getUid())[0].getObject().getRelativeUrl() specialise_uid = gadget.getUid())[0].getObject().getRelativeUrl()
class TestKMMixIn(TestDocumentMixin): class TestKMMixIn(TestDocumentMixin):
""" """
Mix in class for Knowledge Management system. Mix in class for Knowledge Management system.
...@@ -1008,38 +1009,38 @@ class TestKMSearch(TestKMMixIn): ...@@ -1008,38 +1009,38 @@ class TestKMSearch(TestKMMixIn):
# create docs to be referenced: # create docs to be referenced:
# (1) TEST, 002, en # (1) TEST, 002, en
filename = 'TEST-en-002.odt' filename = 'TEST-en-002.odt'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
self.portal.portal_contributions.newContent(file=file_) self.portal.portal_contributions.newContent(file=file_)
# (2) TEST, 002, fr # (2) TEST, 002, fr
as_name = 'TEST-fr-002.odt' as_name = 'TEST-fr-002.odt'
file_ = makeFileUpload(filename, as_name) file_ = self.makeFileUpload(filename, as_name)
document2 = self.portal.portal_contributions.newContent(file=file_) document2 = self.portal.portal_contributions.newContent(file=file_)
# (3) TEST, 003, en # (3) TEST, 003, en
as_name = 'TEST-en-003.odt' as_name = 'TEST-en-003.odt'
file_ = makeFileUpload(filename, as_name) file_ = self.makeFileUpload(filename, as_name)
document3 = self.portal.portal_contributions.newContent(file=file_) document3 = self.portal.portal_contributions.newContent(file=file_)
# create docs to contain references in text_content: # create docs to contain references in text_content:
# REF, 002, en; "I use reference to look up TEST" # REF, 002, en; "I use reference to look up TEST"
filename = 'REF-en-002.odt' filename = 'REF-en-002.odt'
file_ = makeFileUpload(filename) file_ = self.makeFileUpload(filename)
document5 = self.portal.portal_contributions.newContent(file=file_) document5 = self.portal.portal_contributions.newContent(file=file_)
# REFLANG, 001, en: "I use reference and language to look up TEST-fr" # REFLANG, 001, en: "I use reference and language to look up TEST-fr"
#filename = 'REFLANG-en-001.odt' #filename = 'REFLANG-en-001.odt'
#file = makeFileUpload(filename) #file = self.makeFileUpload(filename)
#document6 = self.portal.portal_contributions.newContent(file=file) #document6 = self.portal.portal_contributions.newContent(file=file)
# REFVER, 001, en: "I use reference and version to look up TEST-002" # REFVER, 001, en: "I use reference and version to look up TEST-002"
#filename = 'REFVER-en-001.odt' #filename = 'REFVER-en-001.odt'
#file = makeFileUpload(filename) #file = self.makeFileUpload(filename)
#document7 = self.portal.portal_contributions.newContent(file=file) #document7 = self.portal.portal_contributions.newContent(file=file)
# REFVERLANG, 001, en: "I use reference, version and language to look up TEST-002-en" # REFVERLANG, 001, en: "I use reference, version and language to look up TEST-002-en"
#filename = 'REFVERLANG-en-001.odt' #filename = 'REFVERLANG-en-001.odt'
#file = makeFileUpload(filename) #file = self.makeFileUpload(filename)
#document8 = self.portal.portal_contributions.newContent(file=file) #document8 = self.portal.portal_contributions.newContent(file=file)
self.tic() self.tic()
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
############################################################################## ##############################################################################
import warnings import warnings
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from erp5.component.test.testDms import DocumentUploadTestCase
from erp5.component.test.testDms import makeFileUpload
from Products.ERP5Type import Utils from Products.ERP5Type import Utils
class TestERP5PDFMerge(ERP5TypeTestCase):
class TestERP5PDFMerge(DocumentUploadTestCase):
def test_showwarning_issue(self): def test_showwarning_issue(self):
""" """
...@@ -39,7 +39,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase): ...@@ -39,7 +39,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
""" """
self.assertEqual(Utils._showwarning, warnings.showwarning) self.assertEqual(Utils._showwarning, warnings.showwarning)
document = self.portal.portal_contributions.newContent( document = self.portal.portal_contributions.newContent(
file=makeFileUpload('REF-en-001.pdf')) file=self.makeFileUpload('REF-en-001.pdf'))
merged_pdf_data = self.portal.ERP5Site_mergePDFList( merged_pdf_data = self.portal.ERP5Site_mergePDFList(
[document.getData(), document.getData()]) [document.getData(), document.getData()])
self.portal.document_module.newContent( self.portal.document_module.newContent(
...@@ -50,7 +50,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase): ...@@ -50,7 +50,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
def test_erp5_merge_pdf(self): def test_erp5_merge_pdf(self):
document = self.portal.portal_contributions.newContent( document = self.portal.portal_contributions.newContent(
file=makeFileUpload('REF-en-001.pdf')) file=self.makeFileUpload('REF-en-001.pdf'))
merged_pdf_data = self.portal.ERP5Site_mergePDFList( merged_pdf_data = self.portal.ERP5Site_mergePDFList(
[document.getData(), document.getData()]) [document.getData(), document.getData()])
merged_document = self.portal.document_module.newContent( merged_document = self.portal.document_module.newContent(
...@@ -60,7 +60,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase): ...@@ -60,7 +60,7 @@ class TestERP5PDFMerge(ERP5TypeTestCase):
def test_erp5_merge_pdf_start_on_recto(self): def test_erp5_merge_pdf_start_on_recto(self):
document = self.portal.portal_contributions.newContent( document = self.portal.portal_contributions.newContent(
file=makeFileUpload('REF-en-001.pdf')) file=self.makeFileUpload('REF-en-001.pdf'))
merged_pdf_data = self.portal.ERP5Site_mergePDFList( merged_pdf_data = self.portal.ERP5Site_mergePDFList(
[document.getData(), document.getData()], start_on_recto=True) [document.getData(), document.getData()], start_on_recto=True)
merged_document = self.portal.document_module.newContent( merged_document = self.portal.document_module.newContent(
......
...@@ -26,12 +26,12 @@ ...@@ -26,12 +26,12 @@
# #
############################################################################## ##############################################################################
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from erp5.component.test.testDms import DocumentUploadTestCase
from erp5.component.test.testDms import makeFileUpload
from time import time from time import time
import base64 import base64
class TestRunMyDoc(ERP5TypeTestCase):
class TestRunMyDoc(DocumentUploadTestCase):
""" """
Basic Test for internal implementation of RunMyDocs Basic Test for internal implementation of RunMyDocs
""" """
...@@ -96,7 +96,7 @@ class TestRunMyDoc(ERP5TypeTestCase): ...@@ -96,7 +96,7 @@ class TestRunMyDoc(ERP5TypeTestCase):
Test Screeshot upload script used by Zelenium to Test Screeshot upload script used by Zelenium to
update screenshots of the documents. update screenshots of the documents.
""" """
image_upload = makeFileUpload('TEST-en-002.png') image_upload = self.makeFileUpload('TEST-en-002.png')
self.assertNotEqual(None, image_upload) self.assertNotEqual(None, image_upload)
# Create a web page, and check if the content is not overwriten # Create a web page, and check if the content is not overwriten
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment