Commit 40ef9afa authored by Ivan Tyagov's avatar Ivan Tyagov

Refactor test to use new script for contribute.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33079 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 98a971b5
...@@ -842,52 +842,58 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -842,52 +842,58 @@ class TestDocument(ERP5TypeTestCase, ZopeTestCase.Functional):
document.Base_showFoundText()) document.Base_showFoundText())
def test_Base_createNewFile(self): def test_Base_createNewFile(self):
context = self.portal.person_module.newContent(portal_type='Person') """
ret = context.Base_createNewFile(portal_type=None, Test contributing a file and attaching it to context.
title=None, """
reference=None, person = self.portal.person_module.newContent(portal_type='Person')
short_title=None, contributed_document = person.Base_contribute(
language=None, portal_type=None,
version=None, title=None,
description=None, reference=None,
file=makeFileUpload('TEST-en-002.odt')) short_title=None,
self.assertTrue(ret.endswith( language=None,
'?portal_status_message=Text%20created%20successfully.'), ret) version=None,
transaction.commit() description=None,
self.tic() attach_document_to_context=True,
document_list = context.getFollowUpRelatedValueList() file=makeFileUpload('TEST-en-002.odt'))
self.assertEquals('Text', contributed_document.getPortalType())
self.stepTic()
document_list = person.getFollowUpRelatedValueList()
self.assertEquals(1, len(document_list)) self.assertEquals(1, len(document_list))
document = document_list[0] document = document_list[0]
self.assertEquals('converted', document.getExternalProcessingState()) self.assertEquals('converted', document.getExternalProcessingState())
self.assertEquals('Text', document.getPortalType()) self.assertEquals('Text', document.getPortalType())
self.assertEquals('title', document.getTitle()) self.assertEquals('title', document.getTitle())
self.assertEquals(contributed_document, document)
def test_Base_createNewFile_empty(self): def test_Base_createNewFile_empty(self):
context = self.portal.person_module.newContent(portal_type='Person') """
Test contributing an empty file and attaching it to context.
"""
person = self.portal.person_module.newContent(portal_type='Person')
empty_file_upload = ZPublisher.HTTPRequest.FileUpload(FieldStorage( empty_file_upload = ZPublisher.HTTPRequest.FileUpload(FieldStorage(
fp=StringIO.StringIO(), fp=StringIO.StringIO(),
environ=dict(REQUEST_METHOD='PUT'), environ=dict(REQUEST_METHOD='PUT'),
headers={"content-disposition": headers={"content-disposition":
"attachment; filename=empty;"})) "attachment; filename=empty;"}))
ret = context.Base_createNewFile(portal_type=None, contributed_document = person.Base_contribute(
title=None, portal_type=None,
reference=None, title=None,
short_title=None, reference=None,
language=None, short_title=None,
version=None, language=None,
description=None, version=None,
file=empty_file_upload) description=None,
attach_document_to_context=True,
self.assertTrue(ret.endswith( file=empty_file_upload)
'?portal_status_message=File%20created%20successfully.'), ret) self.stepTic()
transaction.commit() document_list = person.getFollowUpRelatedValueList()
self.tic()
document_list = context.getFollowUpRelatedValueList()
self.assertEquals(1, len(document_list)) self.assertEquals(1, len(document_list))
document = document_list[0] document = document_list[0]
self.assertEquals('empty', document.getExternalProcessingState()) self.assertEquals('empty', document.getExternalProcessingState())
self.assertEquals('File', document.getPortalType()) self.assertEquals('File', document.getPortalType())
self.assertEquals(contributed_document, document)
def test_HTML_to_ODT_conversion_keep_enconding(self): def test_HTML_to_ODT_conversion_keep_enconding(self):
"""This test perform an PDF conversion of HTML content """This test perform an PDF conversion of HTML content
......
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