Merge pull request #63 from plone/davisagli-test-fixture
create doc1 once in the text fixture rather than in setup for each test
This commit is contained in:
commit
83046caf73
@ -1,16 +1,14 @@
|
|||||||
from Products.CMFCore.utils import getToolByName
|
|
||||||
|
|
||||||
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
|
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
|
||||||
from plone.app.discussion.interfaces import IDiscussionSettings
|
from plone.app.discussion.interfaces import IDiscussionSettings
|
||||||
from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING
|
from plone.app.robotframework.testing import REMOTE_LIBRARY_ROBOT_TESTING
|
||||||
from plone.app.testing import IntegrationTesting
|
|
||||||
from plone.app.testing import FunctionalTesting
|
|
||||||
from plone.app.testing import PloneSandboxLayer
|
|
||||||
from plone.app.testing import applyProfile
|
from plone.app.testing import applyProfile
|
||||||
|
from plone.app.testing import FunctionalTesting
|
||||||
from plone.testing import z2
|
from plone.app.testing import IntegrationTesting
|
||||||
|
from plone.app.testing import PloneSandboxLayer
|
||||||
|
from plone.app.testing import setRoles
|
||||||
|
from plone.app.testing import TEST_USER_ID
|
||||||
from plone.registry.interfaces import IRegistry
|
from plone.registry.interfaces import IRegistry
|
||||||
|
from Products.CMFCore.utils import getToolByName
|
||||||
from zope.component import queryUtility
|
from zope.component import queryUtility
|
||||||
from zope.configuration import xmlconfig
|
from zope.configuration import xmlconfig
|
||||||
|
|
||||||
@ -88,6 +86,14 @@ class PloneAppDiscussion(PloneSandboxLayer):
|
|||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Add a document
|
||||||
|
setRoles(portal, TEST_USER_ID, ['Manager'])
|
||||||
|
portal.invokeFactory(
|
||||||
|
id='doc1',
|
||||||
|
title='Document 1',
|
||||||
|
type_name='Document'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class PloneAppDiscussionRobot(PloneAppDiscussion):
|
class PloneAppDiscussionRobot(PloneAppDiscussion):
|
||||||
|
|
||||||
|
@ -56,8 +56,7 @@ Enable commenting.
|
|||||||
|
|
||||||
Create a public page with comments allowed.
|
Create a public page with comments allowed.
|
||||||
|
|
||||||
>>> browser.open(portal_url)
|
>>> browser.open(portal['doc1'].absolute_url() + '/edit')
|
||||||
>>> browser.getLink(id='document').click()
|
|
||||||
>>> browser.getControl(name='form.widgets.IDublinCore.title').value = "Doc1"
|
>>> browser.getControl(name='form.widgets.IDublinCore.title').value = "Doc1"
|
||||||
>>> browser.getControl(name='form.widgets.IAllowDiscussion.allow_discussion:list').value = ['True']
|
>>> browser.getControl(name='form.widgets.IAllowDiscussion.allow_discussion:list').value = ['True']
|
||||||
>>> browser.getControl('Save').click()
|
>>> browser.getControl('Save').click()
|
||||||
|
@ -63,11 +63,6 @@ class ConversationCatalogTest(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
Title='Document 1',
|
|
||||||
type_name='Document'
|
|
||||||
)
|
|
||||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
comment1 = createObject('plone.Comment')
|
comment1 = createObject('plone.Comment')
|
||||||
@ -260,9 +255,6 @@ class CommentCatalogTest(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
self.portal.invokeFactory(id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document')
|
|
||||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||||
|
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
@ -540,9 +532,6 @@ class NoConversationCatalogTest(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
self.portal.invokeFactory(id='doc1',
|
|
||||||
Title='Document 1',
|
|
||||||
type_name='Document')
|
|
||||||
|
|
||||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||||
|
|
||||||
|
@ -34,11 +34,6 @@ class CommentTest(unittest.TestCase):
|
|||||||
self.request = self.layer['request']
|
self.request = self.layer['request']
|
||||||
|
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document'
|
|
||||||
)
|
|
||||||
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
self.catalog = getToolByName(self.portal, 'portal_catalog')
|
||||||
self.document_brain = self.catalog.searchResults(
|
self.document_brain = self.catalog.searchResults(
|
||||||
portal_type='Document')[0]
|
portal_type='Document')[0]
|
||||||
@ -360,11 +355,6 @@ class RepliesTest(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document'
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_add_comment(self):
|
def test_add_comment(self):
|
||||||
# Add comments to a CommentReplies adapter
|
# Add comments to a CommentReplies adapter
|
||||||
|
@ -59,8 +59,6 @@ class TestCommentForm(unittest.TestCase):
|
|||||||
interfaces.IDiscussionLayer,
|
interfaces.IDiscussionLayer,
|
||||||
)
|
)
|
||||||
|
|
||||||
typetool = self.portal.portal_types
|
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
wftool = getToolByName(self.portal, "portal_workflow")
|
wftool = getToolByName(self.portal, "portal_workflow")
|
||||||
wftool.doActionFor(self.portal.doc1, action='publish')
|
wftool.doActionFor(self.portal.doc1, action='publish')
|
||||||
self.portal.doc1.allow_discussion = True
|
self.portal.doc1.allow_discussion = True
|
||||||
@ -464,8 +462,6 @@ class TestCommentsViewlet(unittest.TestCase):
|
|||||||
self.workflowTool = getToolByName(self.portal, 'portal_workflow')
|
self.workflowTool = getToolByName(self.portal, 'portal_workflow')
|
||||||
self.workflowTool.setDefaultChain('one_state_workflow')
|
self.workflowTool.setDefaultChain('one_state_workflow')
|
||||||
|
|
||||||
typetool = self.portal.portal_types
|
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
self.membershipTool = getToolByName(self.folder, 'portal_membership')
|
self.membershipTool = getToolByName(self.folder, 'portal_membership')
|
||||||
self.memberdata = self.portal.portal_memberdata
|
self.memberdata = self.portal.portal_memberdata
|
||||||
context = getattr(self.portal, 'doc1')
|
context = getattr(self.portal, 'doc1')
|
||||||
|
@ -35,12 +35,8 @@ class CommentContentRulesTest(unittest.TestCase):
|
|||||||
})
|
})
|
||||||
|
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
name = self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document')
|
|
||||||
|
|
||||||
self.document = self.portal[name]
|
self.document = self.portal['doc1']
|
||||||
|
|
||||||
comment = createObject('plone.Comment')
|
comment = createObject('plone.Comment')
|
||||||
comment.text = "This is a comment"
|
comment.text = "This is a comment"
|
||||||
@ -93,12 +89,8 @@ class ReplyContentRulesTest(unittest.TestCase):
|
|||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
self.request = self.layer['request']
|
self.request = self.layer['request']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
name = self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document')
|
|
||||||
|
|
||||||
self.document = self.portal[name]
|
self.document = self.portal['doc1']
|
||||||
conversation = IConversation(self.document)
|
conversation = IConversation(self.document)
|
||||||
replies = IReplies(conversation)
|
replies = IReplies(conversation)
|
||||||
|
|
||||||
|
@ -42,9 +42,7 @@ class ConversationTest(unittest.TestCase):
|
|||||||
interface.alsoProvides(
|
interface.alsoProvides(
|
||||||
self.portal.REQUEST, interfaces.IDiscussionLayer)
|
self.portal.REQUEST, interfaces.IDiscussionLayer)
|
||||||
|
|
||||||
typetool = self.portal.portal_types
|
self.typetool = self.portal.portal_types
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
self.typetool = typetool
|
|
||||||
self.portal_discussion = getToolByName(
|
self.portal_discussion = getToolByName(
|
||||||
self.portal,
|
self.portal,
|
||||||
'portal_discussion',
|
'portal_discussion',
|
||||||
@ -685,8 +683,6 @@ class ConversationEnabledForDexterityTypesTest(unittest.TestCase):
|
|||||||
interfaces.IDiscussionLayer
|
interfaces.IDiscussionLayer
|
||||||
)
|
)
|
||||||
|
|
||||||
typetool = self.portal.portal_types
|
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
if DEXTERITY:
|
if DEXTERITY:
|
||||||
interface.alsoProvides(
|
interface.alsoProvides(
|
||||||
self.portal.doc1,
|
self.portal.doc1,
|
||||||
@ -750,8 +746,6 @@ class RepliesTest(unittest.TestCase):
|
|||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
typetool = self.portal.portal_types
|
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
|
|
||||||
def test_add_comment(self):
|
def test_add_comment(self):
|
||||||
# Add comments to a ConversationReplies adapter
|
# Add comments to a ConversationReplies adapter
|
||||||
|
@ -50,12 +50,7 @@ class CommentEventsTest(unittest.TestCase):
|
|||||||
self.registry = EventsRegistry
|
self.registry = EventsRegistry
|
||||||
|
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
name = self.portal.invokeFactory(
|
self.document = self.portal['doc1']
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document')
|
|
||||||
|
|
||||||
self.document = self.portal[name]
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Subscribers
|
# Subscribers
|
||||||
@ -107,12 +102,7 @@ class RepliesEventsTest(unittest.TestCase):
|
|||||||
self.registry = EventsRegistry
|
self.registry = EventsRegistry
|
||||||
|
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
name = self.portal.invokeFactory(
|
self.document = self.portal['doc1']
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document')
|
|
||||||
|
|
||||||
self.document = self.portal[name]
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Subscribers
|
# Subscribers
|
||||||
|
@ -40,12 +40,6 @@ class ConversationIndexersTest(unittest.TestCase):
|
|||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
|
|
||||||
self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a conversation.
|
# Create a conversation.
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
@ -121,12 +115,6 @@ class CommentIndexersTest(unittest.TestCase):
|
|||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
|
|
||||||
self.portal.invokeFactory(
|
|
||||||
id='doc1',
|
|
||||||
title='Document 1',
|
|
||||||
type_name='Document'
|
|
||||||
)
|
|
||||||
|
|
||||||
# Create a conversation. In this case we doesn't assign it to an
|
# Create a conversation. In this case we doesn't assign it to an
|
||||||
# object, as we just want to check the Conversation object API.
|
# object, as we just want to check the Conversation object API.
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
@ -24,8 +24,6 @@ class ModerationViewTest(unittest.TestCase):
|
|||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
self.request = self.layer['request']
|
self.request = self.layer['request']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
typetool = self.portal.portal_types
|
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
self.portal_discussion = getToolByName(self.portal,
|
self.portal_discussion = getToolByName(self.portal,
|
||||||
'portal_discussion',
|
'portal_discussion',
|
||||||
None)
|
None)
|
||||||
@ -66,8 +64,6 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
|
|||||||
self.portal = self.layer['portal']
|
self.portal = self.layer['portal']
|
||||||
self.request = self.layer['request']
|
self.request = self.layer['request']
|
||||||
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
setRoles(self.portal, TEST_USER_ID, ['Manager'])
|
||||||
typetool = self.portal.portal_types
|
|
||||||
typetool.constructContent('Document', self.portal, 'doc1')
|
|
||||||
self.wf = getToolByName(self.portal,
|
self.wf = getToolByName(self.portal,
|
||||||
'portal_workflow',
|
'portal_workflow',
|
||||||
None)
|
None)
|
||||||
|
@ -44,8 +44,6 @@ class TestUserNotificationUnit(unittest.TestCase):
|
|||||||
registry = queryUtility(IRegistry)
|
registry = queryUtility(IRegistry)
|
||||||
registry['plone.app.discussion.interfaces.IDiscussionSettings' +
|
registry['plone.app.discussion.interfaces.IDiscussionSettings' +
|
||||||
'.user_notification_enabled'] = True
|
'.user_notification_enabled'] = True
|
||||||
# Create test content
|
|
||||||
self.portal.invokeFactory('Document', 'doc1')
|
|
||||||
# Archetypes content types store data as utf-8 encoded strings
|
# Archetypes content types store data as utf-8 encoded strings
|
||||||
# The missing u in front of a string is therefor not missing
|
# The missing u in front of a string is therefor not missing
|
||||||
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
||||||
@ -193,8 +191,6 @@ class TestModeratorNotificationUnit(unittest.TestCase):
|
|||||||
'plone.app.discussion.interfaces.IDiscussionSettings.' +
|
'plone.app.discussion.interfaces.IDiscussionSettings.' +
|
||||||
'moderator_notification_enabled'
|
'moderator_notification_enabled'
|
||||||
] = True
|
] = True
|
||||||
# Create test content
|
|
||||||
self.portal.invokeFactory('Document', 'doc1')
|
|
||||||
# Archetypes content types store data as utf-8 encoded strings
|
# Archetypes content types store data as utf-8 encoded strings
|
||||||
# The missing u in front of a string is therefor not missing
|
# The missing u in front of a string is therefor not missing
|
||||||
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
|
||||||
|
@ -187,9 +187,6 @@ class CommentReviewWorkflowTest(unittest.TestCase):
|
|||||||
('Discussion Item',),
|
('Discussion Item',),
|
||||||
('comment_review_workflow',))
|
('comment_review_workflow',))
|
||||||
|
|
||||||
# Create a Document
|
|
||||||
self.portal.invokeFactory('Document', 'doc1')
|
|
||||||
|
|
||||||
# Create a conversation for this Document
|
# Create a conversation for this Document
|
||||||
conversation = IConversation(self.portal.doc1)
|
conversation = IConversation(self.portal.doc1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user