Move regression test for #11157 into the main functional test.

svn path=/plone.app.discussion/trunk/; revision=40458
This commit is contained in:
Timo Stollenwerk 2010-09-30 17:45:26 +00:00
parent 22db0b1c78
commit 0e27b8b7b6
2 changed files with 27 additions and 98 deletions

View File

@ -160,3 +160,30 @@ Now we can post an anonymous comment.
>>> 'This is an anonymous comment' in unprivileged_browser.contents >>> 'This is an anonymous comment' in unprivileged_browser.contents
True True
Regression Test
---------------
Make sure we still can edit the content object after a comment has been posted.
This is a regression test for http://dev.plone.org/plone/ticket/11157
(TypeError: Can't pickle objects in acquisition wrappers).
Login as admin.
>>> browser.open(portal_url + '/logout')
>>> browser.open(portal_url + '/login_form')
>>> browser.getControl(name='__ac_name').value = 'admin'
>>> browser.getControl(name='__ac_password').value = 'secret'
>>> browser.getControl(name='submit').click()
Edit the content object.
>>> browser.open(urldoc1 + "/edit")
>>> browser.getControl(name='text').value = "Lorem ipsum"
>>> browser.getControl(name='form.button.save').click()
Make sure the edit was successful.
>>> 'Lorem ipsum' in browser.contents
True

View File

@ -1,98 +0,0 @@
# -*- coding: utf-8 -*-
import unittest
import time
from datetime import datetime
from AccessControl import Unauthorized
from zope.component import createObject, queryUtility
from OFS.Image import Image
from zope.interface import alsoProvides
from zope.publisher.browser import TestRequest
from zope.annotation.interfaces import IAttributeAnnotatable
from z3c.form.interfaces import IFormLayer
from zope.component import provideAdapter
from zope.publisher.interfaces.browser import IBrowserRequest
from zope.interface import Interface
from zope.component import getMultiAdapter
from plone.registry.interfaces import IRegistry
from Products.CMFCore.utils import getToolByName
from Products.CMFPlone.tests import dummy
from Products.Five.testbrowser import Browser
from Products.PloneTestCase.ptc import PloneTestCase
from Products.PloneTestCase.ptc import FunctionalTestCase
from Products.PloneTestCase.setup import portal_owner, default_password
from plone.app.discussion.browser.comments import CommentsViewlet
from plone.app.discussion.browser.comments import CommentForm
from plone.app.discussion.interfaces import IConversation
from plone.app.discussion.tests.layer import DiscussionLayer
class TestPostCommentsRegression(FunctionalTestCase):
layer = DiscussionLayer
def testCantPickleObjectsInAcquisitionWrapper(self):
"""https://dev.plone.org/plone/ticket/11157
"""
browser = Browser()
portal_url = self.portal.absolute_url()
browser.handleErrors = False
browser.open(portal_url + '/login_form')
browser.getControl(name='__ac_name').value = portal_owner
browser.getControl(name='__ac_password').value = default_password
browser.getControl(name='submit').click()
browser.open(portal_url)
browser.getLink(id='document').click()
browser.getControl(name='title').value = "Doc1"
browser.getControl(name='allowDiscussion:boolean').value = True
browser.getControl(name='form.button.save').click()
browser.getLink('Publish').click()
urldoc1 = browser.url
# Enable anonymous comment
browser.open(portal_url+'/@@discussion-settings')
browser.getControl(name='form.widgets.anonymous_comments:list').value = [True]
browser.getControl(name='form.buttons.save').click()
def post(poster=None, password=None, url=urldoc1):
if poster:
browser.open(portal_url + '/logout')
browser.open(portal_url + '/login_form')
browser.getControl(name='__ac_name').value = poster
browser.getControl(name='__ac_password').value = password
browser.getControl(name='submit').click()
browser.open(url)
browser.getControl(name='form.widgets.text').value = "%s Lorem ipsum" % poster
submit = browser.getControl(name='form.buttons.comment')
submit.click()
browser.open(portal_url + '/logout')
# Login and post comment as Anonymous
post()
browser.open(portal_url + '/login_form')
browser.getControl(name='__ac_name').value = portal_owner
browser.getControl(name='__ac_password').value = default_password
browser.getControl(name='submit').click()
browser.open(portal_url + '/doc1/edit')
browser.getControl(name='title').value = "New Doc1"
browser.getControl(name='text').value = "Lorem ipsum"
browser.getControl(name='form.button.save').click()
self.failUnless('Lorem ipsum' in browser.contents)
def test_suite():
return unittest.defaultTestLoader.loadTestsFromName(__name__)