create doc1 in the text fixture rather than in setup for each test

This commit is contained in:
David Glick 2015-03-09 21:51:45 -07:00
parent 8d72da071f
commit 8690461ffb
12 changed files with 20 additions and 87 deletions

View File

@ -1,16 +1,14 @@
from Products.CMFCore.utils import getToolByName
from plone.app.contenttypes.testing import PLONE_APP_CONTENTTYPES_FIXTURE
from plone.app.discussion.interfaces import IDiscussionSettings
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.testing import z2
from plone.app.testing import FunctionalTesting
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 Products.CMFCore.utils import getToolByName
from zope.component import queryUtility
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):

View File

@ -56,8 +56,7 @@ Enable commenting.
Create a public page with comments allowed.
>>> browser.open(portal_url)
>>> browser.getLink(id='document').click()
>>> browser.open(portal['doc1'].absolute_url() + '/edit')
>>> browser.getControl(name='form.widgets.IDublinCore.title').value = "Doc1"
>>> browser.getControl(name='form.widgets.IAllowDiscussion.allow_discussion:list').value = ['True']
>>> browser.getControl('Save').click()

View File

@ -63,11 +63,6 @@ class ConversationCatalogTest(unittest.TestCase):
def setUp(self):
self.portal = self.layer['portal']
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')
conversation = IConversation(self.portal.doc1)
comment1 = createObject('plone.Comment')
@ -260,9 +255,6 @@ class CommentCatalogTest(unittest.TestCase):
def setUp(self):
self.portal = self.layer['portal']
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')
conversation = IConversation(self.portal.doc1)
@ -540,9 +532,6 @@ class NoConversationCatalogTest(unittest.TestCase):
def setUp(self):
self.portal = self.layer['portal']
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')

View File

@ -34,11 +34,6 @@ class CommentTest(unittest.TestCase):
self.request = self.layer['request']
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.document_brain = self.catalog.searchResults(
portal_type='Document')[0]
@ -360,11 +355,6 @@ class RepliesTest(unittest.TestCase):
def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory(
id='doc1',
title='Document 1',
type_name='Document'
)
def test_add_comment(self):
# Add comments to a CommentReplies adapter

View File

@ -59,8 +59,6 @@ class TestCommentForm(unittest.TestCase):
interfaces.IDiscussionLayer,
)
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
wftool = getToolByName(self.portal, "portal_workflow")
wftool.doActionFor(self.portal.doc1, action='publish')
self.portal.doc1.allow_discussion = True
@ -464,8 +462,6 @@ class TestCommentsViewlet(unittest.TestCase):
self.workflowTool = getToolByName(self.portal, 'portal_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.memberdata = self.portal.portal_memberdata
context = getattr(self.portal, 'doc1')

View File

@ -35,12 +35,8 @@ class CommentContentRulesTest(unittest.TestCase):
})
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.text = "This is a comment"
@ -93,12 +89,8 @@ class ReplyContentRulesTest(unittest.TestCase):
self.portal = self.layer['portal']
self.request = self.layer['request']
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)
replies = IReplies(conversation)

View File

@ -42,9 +42,7 @@ class ConversationTest(unittest.TestCase):
interface.alsoProvides(
self.portal.REQUEST, interfaces.IDiscussionLayer)
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
self.typetool = typetool
self.typetool = self.portal.portal_types
self.portal_discussion = getToolByName(
self.portal,
'portal_discussion',
@ -685,8 +683,6 @@ class ConversationEnabledForDexterityTypesTest(unittest.TestCase):
interfaces.IDiscussionLayer
)
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
if DEXTERITY:
interface.alsoProvides(
self.portal.doc1,
@ -750,8 +746,6 @@ class RepliesTest(unittest.TestCase):
def setUp(self):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
def test_add_comment(self):
# Add comments to a ConversationReplies adapter

View File

@ -50,12 +50,7 @@ class CommentEventsTest(unittest.TestCase):
self.registry = EventsRegistry
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']
#
# Subscribers
@ -107,12 +102,7 @@ class RepliesEventsTest(unittest.TestCase):
self.registry = EventsRegistry
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']
#
# Subscribers

View File

@ -40,12 +40,6 @@ class ConversationIndexersTest(unittest.TestCase):
self.portal = self.layer['portal']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
self.portal.invokeFactory(
id='doc1',
title='Document 1',
type_name='Document'
)
# Create a conversation.
conversation = IConversation(self.portal.doc1)
@ -121,12 +115,6 @@ class CommentIndexersTest(unittest.TestCase):
self.portal = self.layer['portal']
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
# object, as we just want to check the Conversation object API.
conversation = IConversation(self.portal.doc1)

View File

@ -24,8 +24,6 @@ class ModerationViewTest(unittest.TestCase):
self.portal = self.layer['portal']
self.request = self.layer['request']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
self.portal_discussion = getToolByName(self.portal,
'portal_discussion',
None)
@ -66,8 +64,6 @@ class ModerationBulkActionsViewTest(unittest.TestCase):
self.portal = self.layer['portal']
self.request = self.layer['request']
setRoles(self.portal, TEST_USER_ID, ['Manager'])
typetool = self.portal.portal_types
typetool.constructContent('Document', self.portal, 'doc1')
self.wf = getToolByName(self.portal,
'portal_workflow',
None)

View File

@ -44,8 +44,6 @@ class TestUserNotificationUnit(unittest.TestCase):
registry = queryUtility(IRegistry)
registry['plone.app.discussion.interfaces.IDiscussionSettings' +
'.user_notification_enabled'] = True
# Create test content
self.portal.invokeFactory('Document', 'doc1')
# Archetypes content types store data as utf-8 encoded strings
# The missing u in front of a string is therefor not missing
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?
@ -193,8 +191,6 @@ class TestModeratorNotificationUnit(unittest.TestCase):
'plone.app.discussion.interfaces.IDiscussionSettings.' +
'moderator_notification_enabled'
] = True
# Create test content
self.portal.invokeFactory('Document', 'doc1')
# Archetypes content types store data as utf-8 encoded strings
# The missing u in front of a string is therefor not missing
self.portal.doc1.title = 'Kölle Alaaf' # What is "Fasching"?

View File

@ -187,9 +187,6 @@ class CommentReviewWorkflowTest(unittest.TestCase):
('Discussion Item',),
('comment_review_workflow',))
# Create a Document
self.portal.invokeFactory('Document', 'doc1')
# Create a conversation for this Document
conversation = IConversation(self.portal.doc1)