2013-08-29 22:20:47 +02:00
|
|
|
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
|
2014-05-02 13:22:08 +02:00
|
|
|
from plone.app.discussion.interfaces import IDiscussionSettings
|
|
|
|
from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING
|
2015-03-10 05:51:45 +01:00
|
|
|
from plone.app.testing import applyProfile
|
2010-09-28 18:35:45 +02:00
|
|
|
from plone.app.testing import FunctionalTesting
|
2015-03-10 05:51:45 +01:00
|
|
|
from plone.app.testing import IntegrationTesting
|
2014-05-02 13:22:08 +02:00
|
|
|
from plone.app.testing import PloneSandboxLayer
|
2015-03-10 05:51:45 +01:00
|
|
|
from plone.app.testing import setRoles
|
|
|
|
from plone.app.testing import TEST_USER_ID
|
2014-05-02 13:22:08 +02:00
|
|
|
from plone.registry.interfaces import IRegistry
|
2015-03-10 05:51:45 +01:00
|
|
|
from Products.CMFCore.utils import getToolByName
|
2014-05-02 13:22:08 +02:00
|
|
|
from zope.component import queryUtility
|
2010-09-28 18:35:45 +02:00
|
|
|
from zope.configuration import xmlconfig
|
|
|
|
|
2012-03-31 18:40:58 +02:00
|
|
|
try:
|
2013-04-18 15:51:57 +02:00
|
|
|
import plone.app.collection # noqa
|
2012-03-31 18:40:58 +02:00
|
|
|
COLLECTION_TYPE = "Collection"
|
|
|
|
except:
|
|
|
|
COLLECTION_TYPE = "Topic"
|
|
|
|
|
2012-01-14 07:53:03 +01:00
|
|
|
|
2010-09-28 18:35:45 +02:00
|
|
|
class PloneAppDiscussion(PloneSandboxLayer):
|
|
|
|
|
2013-08-29 22:20:47 +02:00
|
|
|
defaultBases = (PLONE_APP_CONTENTTYPES_FIXTURE,)
|
2010-09-28 18:35:45 +02:00
|
|
|
|
|
|
|
USER_NAME = 'johndoe'
|
|
|
|
USER_PASSWORD = 'secret'
|
2010-12-09 11:58:32 +01:00
|
|
|
MEMBER_NAME = 'janedoe'
|
|
|
|
MEMBER_PASSWORD = 'secret'
|
2010-09-28 18:35:45 +02:00
|
|
|
USER_WITH_FULLNAME_NAME = 'jim'
|
|
|
|
USER_WITH_FULLNAME_FULLNAME = 'Jim Fulton'
|
|
|
|
USER_WITH_FULLNAME_PASSWORD = 'secret'
|
|
|
|
MANAGER_USER_NAME = 'manager'
|
|
|
|
MANAGER_USER_PASSWORD = 'secret'
|
2014-03-03 15:12:16 +01:00
|
|
|
REVIEWER_NAME = 'reviewer'
|
|
|
|
REVIEWER_PASSWORD = 'secret'
|
2010-12-16 00:52:56 +01:00
|
|
|
|
2010-09-28 18:35:45 +02:00
|
|
|
def setUpZope(self, app, configurationContext):
|
|
|
|
# Load ZCML
|
|
|
|
import plone.app.discussion
|
2010-12-16 00:52:56 +01:00
|
|
|
xmlconfig.file('configure.zcml',
|
|
|
|
plone.app.discussion,
|
2010-09-28 18:35:45 +02:00
|
|
|
context=configurationContext)
|
|
|
|
|
|
|
|
def setUpPloneSite(self, portal):
|
|
|
|
# Install into Plone site using portal_setup
|
|
|
|
applyProfile(portal, 'plone.app.discussion:default')
|
|
|
|
|
|
|
|
# Creates some users
|
|
|
|
acl_users = getToolByName(portal, 'acl_users')
|
|
|
|
acl_users.userFolderAddUser(
|
|
|
|
self.USER_NAME,
|
|
|
|
self.USER_PASSWORD,
|
2010-12-09 11:58:32 +01:00
|
|
|
[],
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
acl_users.userFolderAddUser(
|
|
|
|
self.MEMBER_NAME,
|
|
|
|
self.MEMBER_PASSWORD,
|
2010-09-28 18:35:45 +02:00
|
|
|
['Member'],
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
acl_users.userFolderAddUser(
|
|
|
|
self.USER_WITH_FULLNAME_NAME,
|
|
|
|
self.USER_WITH_FULLNAME_PASSWORD,
|
|
|
|
['Member'],
|
|
|
|
[],
|
|
|
|
)
|
2014-03-03 15:12:16 +01:00
|
|
|
acl_users.userFolderAddUser(
|
|
|
|
self.REVIEWER_NAME,
|
|
|
|
self.REVIEWER_PASSWORD,
|
|
|
|
['Member'],
|
|
|
|
[],
|
|
|
|
)
|
2010-12-16 00:52:56 +01:00
|
|
|
mtool = getToolByName(portal, 'portal_membership', None)
|
2014-03-03 15:12:16 +01:00
|
|
|
gtool = getToolByName(portal, 'portal_groups', None)
|
|
|
|
gtool.addPrincipalToGroup(self.REVIEWER_NAME, 'Reviewers')
|
2010-12-16 00:52:56 +01:00
|
|
|
mtool.addMember('jim', 'Jim', ['Member'], [])
|
2012-01-14 07:53:03 +01:00
|
|
|
mtool.getMemberById('jim').setMemberProperties(
|
|
|
|
{"fullname": 'Jim Fult\xc3\xb8rn'})
|
2010-09-28 18:35:45 +02:00
|
|
|
|
|
|
|
acl_users.userFolderAddUser(
|
|
|
|
self.MANAGER_USER_NAME,
|
|
|
|
self.MANAGER_USER_PASSWORD,
|
|
|
|
['Manager'],
|
|
|
|
[],
|
|
|
|
)
|
|
|
|
|
2015-03-10 05:51:45 +01:00
|
|
|
# Add a document
|
|
|
|
setRoles(portal, TEST_USER_ID, ['Manager'])
|
|
|
|
portal.invokeFactory(
|
|
|
|
id='doc1',
|
|
|
|
title='Document 1',
|
|
|
|
type_name='Document'
|
|
|
|
)
|
|
|
|
|
2014-05-02 13:22:08 +02:00
|
|
|
|
|
|
|
class PloneAppDiscussionRobot(PloneAppDiscussion):
|
|
|
|
|
|
|
|
def setUpPloneSite(self, portal):
|
|
|
|
registry = queryUtility(IRegistry)
|
|
|
|
settings = registry.forInterface(IDiscussionSettings)
|
|
|
|
settings.globally_enabled = True
|
|
|
|
|
|
|
|
|
|
|
|
PLONE_APP_DISCUSSION_ROBOT_FIXTURE = PloneAppDiscussionRobot()
|
2010-09-28 18:35:45 +02:00
|
|
|
PLONE_APP_DISCUSSION_FIXTURE = PloneAppDiscussion()
|
|
|
|
PLONE_APP_DISCUSSION_INTEGRATION_TESTING = IntegrationTesting(
|
2010-12-16 00:52:56 +01:00
|
|
|
bases=(PLONE_APP_DISCUSSION_FIXTURE,),
|
2010-09-28 18:35:45 +02:00
|
|
|
name="PloneAppDiscussion:Integration")
|
|
|
|
PLONE_APP_DISCUSSION_FUNCTIONAL_TESTING = FunctionalTesting(
|
2010-12-16 00:52:56 +01:00
|
|
|
bases=(PLONE_APP_DISCUSSION_FIXTURE,),
|
2010-09-28 18:35:45 +02:00
|
|
|
name="PloneAppDiscussion:Functional")
|
2014-05-02 13:22:08 +02:00
|
|
|
PLONE_APP_DISCUSSION_ROBOT_TESTING = FunctionalTesting(
|
|
|
|
bases=(
|
|
|
|
PLONE_APP_DISCUSSION_ROBOT_FIXTURE,
|
|
|
|
REMOTE_LIBRARY_ROBOT_TESTING
|
|
|
|
),
|
|
|
|
name="PloneAppDiscussion:Robot"
|
|
|
|
)
|