Commit cae3752e authored by Romain Courteaud's avatar Romain Courteaud

[officejs_test] Add a basic scenario test

parent df78d117
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
import time
from StringIO import StringIO
import zipfile
class LocalStringIO(StringIO):
__allow_access_to_unprotected_subobjects__=1
def __init__(self, filename, *args, **kw):
self.filename = filename
StringIO.__init__(self, *args, **kw)
class TestOfficeJSScenario(SecurityTestCase):
def getTitle(self):
return "Test OfficeJS Scenario"
def getBusinessTemplateList(self):
"""
Tuple of Business Templates we need to install
"""
return ('officejs_meta',)
def createNewUser(self,
first_name="John_test",
last_name="Smith_test",
reference="TEST_OFFICEJS_",
email="john.smith@test.com"):
"""
Add new member using script for the website sign-in
"""
reference += "%s" % time.time()
user = self.portal.person_module.newContent(
portal_type="Person",
reference=reference,
user_id=reference,
first_name=first_name,
last_name=last_name,
default_email_coordinate_text=email,
career_role_list=["author"]
)
user.validate()
assignment = user.newContent(portal_type="Assignment", role="author")
assignment.open()
return user
def test_01_user_can_contribute(self):
###################################
### Manager: Create user
person = self.createNewUser()
self.tic()
###################################
### User: submit application
self.login(person.getUserId())
import_file = LocalStringIO('your.zip')
my_zip = zipfile.ZipFile(import_file, 'w')
my_zip.writestr('foo.txt', 'foobar')
my_zip.close()
self.portal.ERP5Site_createNewSoftwarePublication(
import_file,
'software/application',
'My Foo App',
'My Bar version'
)
self.tic()
###################################
### Alarm: extract zip file
self.login()
self.portal.portal_alarms.officejs_process_submit_software_publication\
.activeSense()
self.tic()
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Test Component" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testOfficeJSScenario</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test.erp5.testOfficeJSScenario</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Test Component</string> </value>
</item>
<item>
<key> <string>sid</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>text_content_error_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>text_content_warning_message</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>erp5</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>validate</string> </value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>validated</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
test.erp5.testOfficeJSSecurity
\ No newline at end of file
test.erp5.testOfficeJSSecurity
test.erp5.testOfficeJSScenario
\ No newline at end of file
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