Remove unnecessary imports and variables from test code.

svn path=/plone.app.discussion/trunk/; revision=37768
This commit is contained in:
Timo Stollenwerk 2010-07-13 10:45:53 +00:00
parent cfdd99b111
commit a54a15a90f
9 changed files with 50 additions and 112 deletions

View File

@ -4,15 +4,13 @@ from datetime import datetime
from zope.component import createObject from zope.component import createObject
from zope.component import getMultiAdapter
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer
from plone.app.discussion.interfaces import IComment, IConversation, IReplies from plone.app.discussion.interfaces import IConversation
class CatalogSetupTest(PloneTestCase): class CatalogSetupTest(PloneTestCase):
@ -218,7 +216,7 @@ class CommentCatalogTest(PloneTestCase):
self.assertEquals(self.comment_brain.Type, 'Comment') self.assertEquals(self.comment_brain.Type, 'Comment')
def test_review_state(self): def test_review_state(self):
self.assertEquals(self.comment_brain.review_state, 'published') self.assertEquals(self.comment_brain.review_state, 'published')
def test_creator(self): def test_creator(self):
self.assertEquals(self.comment_brain.Creator, 'Jim') self.assertEquals(self.comment_brain.Creator, 'Jim')
@ -294,13 +292,13 @@ class CommentCatalogTest(PloneTestCase):
new_id_1_1 = self.conversation.addComment(comment1_1) new_id_1_1 = self.conversation.addComment(comment1_1)
comment1_1_1.in_reply_to = new_id_1_1 comment1_1_1.in_reply_to = new_id_1_1
new_id_1_1_1 = self.conversation.addComment(comment1_1_1) self.conversation.addComment(comment1_1_1)
comment1_2.in_reply_to = new_id_1 comment1_2.in_reply_to = new_id_1
new_id_1_2 = self.conversation.addComment(comment1_2) self.conversation.addComment(comment1_2)
comment2_1.in_reply_to = new_id_2 comment2_1.in_reply_to = new_id_2
new_id_2_1 = self.conversation.addComment(comment2_1) self.conversation.addComment(comment2_1)
# Clear and rebuild catalog # Clear and rebuild catalog
self.catalog.clearFindAndRebuild() self.catalog.clearFindAndRebuild()

View File

@ -4,8 +4,6 @@ from zope.component import createObject
from zope.component import getMultiAdapter from zope.component import getMultiAdapter
from Products.CMFCore.utils import getToolByName
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer
@ -209,7 +207,7 @@ class RepliesTest(PloneTestCase):
comment1.title = 'Comment 1' comment1.title = 'Comment 1'
comment1.text = 'Comment text' comment1.text = 'Comment text'
new_comment1_id = conversation.addComment(comment1) conversation.addComment(comment1)
comment = createObject('plone.Comment') comment = createObject('plone.Comment')
comment.title = 'Comment 1' comment.title = 'Comment 1'

View File

@ -1,28 +1,20 @@
import unittest import unittest
from datetime import datetime, timedelta from datetime import datetime
from plone.registry import Registry
from zope.component import createObject, queryUtility from zope.component import createObject, queryUtility
from Acquisition import aq_base, aq_parent, aq_inner
from OFS.Image import Image from OFS.Image import Image
from plone.app.vocabularies.types import BAD_TYPES
from plone.registry.interfaces import IRegistry from plone.registry.interfaces import IRegistry
from Products.CMFCore.FSImage import FSImage
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.tests import dummy from Products.CMFPlone.tests import dummy
from Products.Five.testbrowser import Browser from Products.Five.testbrowser import Browser
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from Products.PloneTestCase.ptc import FunctionalTestCase from Products.PloneTestCase.ptc import FunctionalTestCase
from plone.app.discussion.browser.comments import CommentForm, CommentsViewlet from plone.app.discussion.browser.comments import CommentsViewlet
from plone.app.discussion.interfaces import IConversation, IComment from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.interfaces import IReplies, IDiscussionSettings
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer
@ -42,7 +34,7 @@ class TestCommentForm(PloneTestCase):
self.viewlet = CommentsViewlet(context, request, None, None) self.viewlet = CommentsViewlet(context, request, None, None)
def test_add_comment(self): def test_add_comment(self):
form = CommentForm(self.viewlet, self.app.REQUEST) #form = CommentForm(self.viewlet, self.app.REQUEST)
#self.viewlet.form.render(form) #self.viewlet.form.render(form)
#self.viewlet.form.handleComment() #self.viewlet.form.handleComment()
#from z3c.form.testing import TestRequest #from z3c.form.testing import TestRequest
@ -64,7 +56,7 @@ class TestCommentForm(PloneTestCase):
# Always check form errors after update() # Always check form errors after update()
#errors = view.errors #errors = view.errors
#self.assertEqual(len(errors), 0, "Got errors:" + str(errors)) #self.assertEqual(len(errors), 0, "Got errors:" + str(errors))
pass
class TestCommentsViewletIntegration(FunctionalTestCase): class TestCommentsViewletIntegration(FunctionalTestCase):
@ -185,7 +177,7 @@ class TestCommentsViewlet(PloneTestCase):
comment = createObject('plone.Comment') comment = createObject('plone.Comment')
comment.title = 'Comment 1' comment.title = 'Comment 1'
comment.text = 'Comment text' comment.text = 'Comment text'
conversation = IConversation(self.portal.doc1) IConversation(self.portal.doc1)
portal_membership = getToolByName(self.portal, 'portal_membership') portal_membership = getToolByName(self.portal, 'portal_membership')
m = portal_membership.getAuthenticatedMember() m = portal_membership.getAuthenticatedMember()
self.assertEquals(self.viewlet.get_commenter_home_url(m.getUserName()), self.assertEquals(self.viewlet.get_commenter_home_url(m.getUserName()),
@ -209,7 +201,7 @@ class TestCommentsViewlet(PloneTestCase):
comment.text = 'Comment text' comment.text = 'Comment text'
comment.Creator = 'Jim' comment.Creator = 'Jim'
comment.author_username = 'jim' comment.author_username = 'jim'
new_id = conversation.addComment(comment) conversation.addComment(comment)
# Call get_commenter_portrait method of the viewlet # Call get_commenter_portrait method of the viewlet
self.viewlet.update() self.viewlet.update()
@ -235,7 +227,7 @@ class TestCommentsViewlet(PloneTestCase):
comment.text = 'Comment text' comment.text = 'Comment text'
comment.Creator = 'Jim' comment.Creator = 'Jim'
comment.author_username = 'jim' comment.author_username = 'jim'
new_id = conversation.addComment(comment) conversation.addComment(comment)
# Call get_commenter_portrait method of the viewlet # Call get_commenter_portrait method of the viewlet
self.viewlet.update() self.viewlet.update()
@ -249,7 +241,6 @@ class TestCommentsViewlet(PloneTestCase):
self.failIf(self.viewlet.anonymous_discussion_allowed()) self.failIf(self.viewlet.anonymous_discussion_allowed())
# Allow anonymous discussion # Allow anonymous discussion
registry = queryUtility(IRegistry) registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
registry['plone.app.discussion.interfaces.IDiscussionSettings.anonymous_comments'] = True registry['plone.app.discussion.interfaces.IDiscussionSettings.anonymous_comments'] = True
# Test if anonymous discussion is allowed for the viewlet # Test if anonymous discussion is allowed for the viewlet
self.failUnless(self.viewlet.anonymous_discussion_allowed()) self.failUnless(self.viewlet.anonymous_discussion_allowed())
@ -257,7 +248,6 @@ class TestCommentsViewlet(PloneTestCase):
def test_show_commenter_image(self): def test_show_commenter_image(self):
self.failUnless(self.viewlet.show_commenter_image()) self.failUnless(self.viewlet.show_commenter_image())
registry = queryUtility(IRegistry) registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
registry['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image'] = False registry['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image'] = False
self.failIf(self.viewlet.show_commenter_image()) self.failIf(self.viewlet.show_commenter_image())

View File

@ -35,36 +35,26 @@ class RegistryTest(PloneTestCase):
def test_globally_enabled(self): def test_globally_enabled(self):
# Check globally_enabled record # Check globally_enabled record
globally_enabled_record = self.registry.records['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled']
self.failUnless('globally_enabled' in IDiscussionSettings) self.failUnless('globally_enabled' in IDiscussionSettings)
self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled'], True) self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled'], True)
def test_captcha(self): def test_captcha(self):
# Check globally_enabled record # Check globally_enabled record
globally_enabled_record = self.registry.records['plone.app.discussion.interfaces.IDiscussionSettings.captcha']
self.failUnless('captcha' in IDiscussionSettings) self.failUnless('captcha' in IDiscussionSettings)
self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.captcha'], 'disabled') self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.captcha'], 'disabled')
def test_anonymous_comments(self): def test_anonymous_comments(self):
# Check anonymous_comments record # Check anonymous_comments record
anonymous_comments_record = self.registry.records['plone.app.discussion.interfaces.IDiscussionSettings.anonymous_comments']
self.failUnless('anonymous_comments' in IDiscussionSettings) self.failUnless('anonymous_comments' in IDiscussionSettings)
self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.anonymous_comments'], False) self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.anonymous_comments'], False)
def test_show_commenter_image(self): def test_show_commenter_image(self):
# Check show_commenter_image record # Check show_commenter_image record
show_commenter_image = self.registry.records['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image']
self.failUnless('show_commenter_image' in IDiscussionSettings) self.failUnless('show_commenter_image' in IDiscussionSettings)
self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image'], True) self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.show_commenter_image'], True)
def test_moderator_notification_enabled(self): def test_moderator_notification_enabled(self):
# Check show_commenter_image record # Check show_commenter_image record
show_commenter_image = self.registry.records['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled']
self.failUnless('moderator_notification_enabled' in IDiscussionSettings) self.failUnless('moderator_notification_enabled' in IDiscussionSettings)
self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled'], False) self.assertEquals(self.registry['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled'], False)

View File

@ -3,7 +3,7 @@ from datetime import datetime, timedelta
from zope.component import createObject, queryUtility from zope.component import createObject, queryUtility
from Acquisition import aq_base, aq_parent, aq_inner from Acquisition import aq_base, aq_parent
from plone.app.vocabularies.types import BAD_TYPES from plone.app.vocabularies.types import BAD_TYPES
@ -83,7 +83,7 @@ class ConversationTest(PloneTestCase):
# 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)
replies = IReplies(conversation) IReplies(conversation)
# Create a nested comment structure: # Create a nested comment structure:
# #
@ -128,10 +128,10 @@ class ConversationTest(PloneTestCase):
new_id_1_1 = conversation.addComment(comment1_1) new_id_1_1 = conversation.addComment(comment1_1)
comment1_1_1.in_reply_to = new_id_1_1 comment1_1_1.in_reply_to = new_id_1_1
new_id_1_1_1 = conversation.addComment(comment1_1_1) conversation.addComment(comment1_1_1)
comment1_2.in_reply_to = new_id_1 comment1_2.in_reply_to = new_id_1
new_id_1_2 = conversation.addComment(comment1_2) conversation.addComment(comment1_2)
comment2_1.in_reply_to = new_id_2 comment2_1.in_reply_to = new_id_2
new_id_2_1 = conversation.addComment(comment2_1) new_id_2_1 = conversation.addComment(comment2_1)
@ -150,7 +150,7 @@ class ConversationTest(PloneTestCase):
comment = createObject('plone.Comment') comment = createObject('plone.Comment')
comment.title = 'Comment 1' comment.title = 'Comment 1'
comment.text = 'Comment text' comment.text = 'Comment text'
new_id = conversation.addComment(comment) conversation.addComment(comment)
# Delete the content object # Delete the content object
self.portal.manage_delObjects(['doc1']) self.portal.manage_delObjects(['doc1'])
@ -170,11 +170,10 @@ class ConversationTest(PloneTestCase):
# Create a conversation. # Create a conversation.
conversation = IConversation(self.portal.doc1) IConversation(self.portal.doc1)
# By default, discussion is disabled for all content types # By default, discussion is disabled for all content types
portal_types = getToolByName(self.portal, 'portal_types') portal_types = getToolByName(self.portal, 'portal_types')
from plone.app.vocabularies.types import BAD_TYPES
for type in list(portal_types): for type in list(portal_types):
type_fti = getattr(portal_types, type) type_fti = getattr(portal_types, type)
if type not in BAD_TYPES: if type not in BAD_TYPES:
@ -349,9 +348,6 @@ class ConversationTest(PloneTestCase):
def test_is_discussion_allowed_on_content_object(self): def test_is_discussion_allowed_on_content_object(self):
# Allow discussion on a single content object # Allow discussion on a single content object
registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
# Create a conversation. # Create a conversation.
conversation = IConversation(self.portal.doc1) conversation = IConversation(self.portal.doc1)
@ -448,9 +444,9 @@ class ConversationTest(PloneTestCase):
comment3.title = 'Comment 3' comment3.title = 'Comment 3'
comment3.text = 'Comment text' comment3.text = 'Comment text'
new_comment1_id = conversation.addComment(comment1) conversation.addComment(comment1)
new_comment2_id = conversation.addComment(comment2) conversation.addComment(comment2)
new_comment3_id = conversation.addComment(comment3) conversation.addComment(comment3)
self.assertEquals(conversation.total_comments, 3) self.assertEquals(conversation.total_comments, 3)
@ -472,13 +468,13 @@ class ConversationTest(PloneTestCase):
comment1.title = 'Comment 1' comment1.title = 'Comment 1'
comment1.text = 'Comment text' comment1.text = 'Comment text'
comment1.author_username = "Jim" comment1.author_username = "Jim"
new_comment1_id = conversation.addComment(comment1) conversation.addComment(comment1)
comment2 = createObject('plone.Comment') comment2 = createObject('plone.Comment')
comment2.title = 'Comment 2' comment2.title = 'Comment 2'
comment2.text = 'Comment text' comment2.text = 'Comment text'
comment2.author_username = "Joe" comment2.author_username = "Joe"
new_comment2_id = conversation.addComment(comment2) conversation.addComment(comment2)
comment3 = createObject('plone.Comment') comment3 = createObject('plone.Comment')
comment3.title = 'Comment 3' comment3.title = 'Comment 3'
@ -533,7 +529,7 @@ class ConversationTest(PloneTestCase):
comment1.title = 'Comment 1' comment1.title = 'Comment 1'
comment1.text = 'Comment text' comment1.text = 'Comment text'
comment1.creation_date = datetime.now() - timedelta(4) comment1.creation_date = datetime.now() - timedelta(4)
new_comment1_id = conversation.addComment(comment1) conversation.addComment(comment1)
comment2 = createObject('plone.Comment') comment2 = createObject('plone.Comment')
comment2.title = 'Comment 2' comment2.title = 'Comment 2'
@ -579,7 +575,7 @@ class ConversationTest(PloneTestCase):
# 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)
replies = IReplies(conversation) IReplies(conversation)
# Create a nested comment structure: # Create a nested comment structure:
# #
@ -803,11 +799,11 @@ class RepliesTest(PloneTestCase):
new_id_1_1 = replies_to_comment1.addComment(comment1_1) new_id_1_1 = replies_to_comment1.addComment(comment1_1)
comment1_1 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_1_1) comment1_1 = self.portal.doc1.restrictedTraverse('++conversation++default/%s' % new_id_1_1)
replies_to_comment1_1 = IReplies(comment1_1) replies_to_comment1_1 = IReplies(comment1_1)
new_id_1_1_1 = replies_to_comment1_1.addComment(comment1_1_1) replies_to_comment1_1.addComment(comment1_1_1)
new_id_1_2 = replies_to_comment1.addComment(comment1_2) replies_to_comment1.addComment(comment1_2)
new_id_2_1 = replies_to_comment2.addComment(comment2_1) replies_to_comment2.addComment(comment2_1)
# check that replies only contain the direct comments # check that replies only contain the direct comments
# and no comments deeper than 1 # and no comments deeper than 1

View File

@ -1,6 +1,6 @@
import unittest import unittest
from datetime import datetime, timedelta from datetime import datetime
from DateTime import DateTime from DateTime import DateTime
from zope.component import createObject from zope.component import createObject
@ -10,11 +10,8 @@ from plone.app.discussion.tests.layer import DiscussionLayer
from plone.app.discussion.interfaces import IConversation from plone.app.discussion.interfaces import IConversation
from plone.indexer import indexer
from plone.indexer.delegate import DelegatingIndexerFactory from plone.indexer.delegate import DelegatingIndexerFactory
from zope.component import provideAdapter
from plone.app.discussion import catalog from plone.app.discussion import catalog
@ -128,7 +125,7 @@ class CommentIndexersTest(PloneTestCase):
comment_long.title = 'Long Comment' comment_long.title = 'Long Comment'
comment_long.text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.' comment_long.text = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
new_id = self.conversation.addComment(comment_long) self.conversation.addComment(comment_long)
self.assertEquals(catalog.description(comment_long)(), 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At [...]') self.assertEquals(catalog.description(comment_long)(), 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At [...]')
def test_dates(self): def test_dates(self):

View File

@ -91,14 +91,14 @@ class MigrationTest(PloneTestCase):
talkback = self.discussion.getDiscussionFor(self.doc) talkback = self.discussion.getDiscussionFor(self.doc)
# First comment # First comment
comment1_id = talkback.createReply(title='First comment', talkback.createReply(title='First comment',
text='This is my first comment.') text='This is my first comment.')
comment1 = talkback.getReplies()[0] comment1 = talkback.getReplies()[0]
talkback_comment1 = self.discussion.getDiscussionFor(comment1) talkback_comment1 = self.discussion.getDiscussionFor(comment1)
# Re: First comment # Re: First comment
comment1_1_id = talkback_comment1.createReply(title='Re: First comment', talkback_comment1.createReply(title='Re: First comment',
text='This is my first reply.') text='This is my first reply.')
comment1_1 = talkback_comment1.getReplies()[0] comment1_1 = talkback_comment1.getReplies()[0]
talkback_comment1_1 = self.discussion.getDiscussionFor(comment1_1) talkback_comment1_1 = self.discussion.getDiscussionFor(comment1_1)
@ -107,40 +107,30 @@ class MigrationTest(PloneTestCase):
self.assertEquals(len(talkback_comment1_1.getReplies()), 0) self.assertEquals(len(talkback_comment1_1.getReplies()), 0)
#Re: Re: First comment #Re: Re: First comment
comment1_1_1_id = talkback_comment1_1.createReply(title='Re: Re: First comment', talkback_comment1_1.createReply(title='Re: Re: First comment',
text='This is my first re-reply.') text='This is my first re-reply.')
comment1_1_1 = talkback_comment1_1.getReplies()[0] comment1_1_1 = talkback_comment1_1.getReplies()[0]
talkback_comment1_1_1 = self.discussion.getDiscussionFor(comment1_1_1) talkback_comment1_1_1 = self.discussion.getDiscussionFor(comment1_1_1)
# Re: Re: Re: First comment # Re: Re: Re: First comment
comment1_1_1_1_id = talkback_comment1_1_1.createReply(title='Re: Re: Re: First comment', talkback_comment1_1_1.createReply(title='Re: Re: Re: First comment',
text='This is my first re-re-reply.') text='This is my first re-re-reply.')
comment1_1_1_1 = talkback_comment1_1_1.getReplies()[0]
talkback_comment1_1_1_1 = self.discussion.getDiscussionFor(comment1_1_1_1)
# Re: First comment (2) # Re: First comment (2)
comment1_2_id = talkback_comment1.createReply(title='Re: First comment (2)', talkback_comment1.createReply(title='Re: First comment (2)',
text='This is my first reply (2).') text='This is my first reply (2).')
comment1_2 = talkback_comment1.getReplies()[1]
talkback_comment1_2 = self.discussion.getDiscussionFor(comment1_2)
# Re: First comment (3) # Re: First comment (3)
comment1_3_id = talkback_comment1.createReply(title='Re: First comment (3)', talkback_comment1.createReply(title='Re: First comment (3)',
text='This is my first reply (3).') text='This is my first reply (3).')
comment1_3 = talkback_comment1.getReplies()[2]
talkback_comment1_3 = self.discussion.getDiscussionFor(comment1_3)
# Re: First comment (4) # Re: First comment (4)
comment1_4_id = talkback_comment1.createReply(title='Re: First comment (4)', talkback_comment1.createReply(title='Re: First comment (4)',
text='This is my first reply (4).') text='This is my first reply (4).')
comment1_4 = talkback_comment1.getReplies()[3]
talkback_comment1_4 = self.discussion.getDiscussionFor(comment1_4)
# Second comment # Second comment
comment2_id = talkback.createReply(title='Second comment', talkback.createReply(title='Second comment',
text='This is my second comment.') text='This is my second comment.')
comment2 = talkback.getReplies()[1]
talkback_comment2 = self.discussion.getDiscussionFor(comment2)
# Call migration script # Call migration script
self.view() self.view()

View File

@ -1,26 +1,14 @@
import unittest import unittest
from DateTime import DateTime from DateTime import DateTime
from datetime import datetime, timedelta
from plone.registry import Registry
from zope.component import createObject from zope.component import createObject
from Acquisition import aq_base, aq_parent, aq_inner
from OFS.Image import Image
from plone.app.vocabularies.types import BAD_TYPES
from Products.CMFCore.FSImage import FSImage
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.tests import dummy
from Products.PloneTestCase.ptc import PloneTestCase from Products.PloneTestCase.ptc import PloneTestCase
from plone.app.discussion.browser.moderation import View from plone.app.discussion.browser.moderation import View
from plone.app.discussion.interfaces import IConversation, IComment from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.interfaces import IReplies, IDiscussionSettings
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer

View File

@ -1,12 +1,7 @@
import unittest import unittest
from email import message_from_string
from Acquisition import aq_base from Acquisition import aq_base
from zope.app.container.contained import ObjectAddedEvent
from zope.app.container.interfaces import IObjectAddedEvent
from zope.component import createObject from zope.component import createObject
from zope.component import getSiteManager from zope.component import getSiteManager
from zope.component import queryUtility from zope.component import queryUtility
@ -18,9 +13,7 @@ from Products.CMFPlone.tests.utils import MockMailHost
from plone.registry.interfaces import IRegistry from plone.registry.interfaces import IRegistry
from plone.app.discussion.comment import notify_user from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.interfaces import IComment, IConversation, IReplies
from plone.app.discussion.interfaces import IDiscussionSettings
from plone.app.discussion.tests.layer import DiscussionLayer from plone.app.discussion.tests.layer import DiscussionLayer
@ -163,7 +156,6 @@ class TestModeratorNotificationUnit(PloneTestCase):
# Enable moderator notification setting # Enable moderator notification setting
registry = queryUtility(IRegistry) registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
registry['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled'] = True registry['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled'] = True
# Create test content # Create test content
@ -221,7 +213,6 @@ class TestModeratorNotificationUnit(PloneTestCase):
# Disable moderator notification setting and make sure no email is send # Disable moderator notification setting and make sure no email is send
# to the moderator. # to the moderator.
registry = queryUtility(IRegistry) registry = queryUtility(IRegistry)
settings = registry.forInterface(IDiscussionSettings)
registry['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled'] = False registry['plone.app.discussion.interfaces.IDiscussionSettings.moderator_notification_enabled'] = False
comment = createObject('plone.Comment') comment = createObject('plone.Comment')