Using a member-posting forum
============================

Test starting conversations, replying and modifying comments in a free-for-all
forum.

First, some set-up:

    >>> from Zope2.App import zcml
    >>> import Products
    >>> zcml.load_config('configure.zcml', package=Products.Ploneboard)

    >>> from Products.Ploneboard.tests import utils
    >>> utils.setUpDefaultMembersBoardAndForum(self)

Enable anonymous name chooser
    >>> utils.enableDisableAnonName(self, True)

    >>> from Testing.testbrowser import Browser
    >>> browser = Browser()
    >>> browser.handleErrors = False

    >>> from time import sleep
    >>> SLEEP_INTERVAL = 0.1

Let us log all exceptions, which is useful for debugging. Also, clear portlet
slots, to make the test browser less confused by things like the recent portlet
and the navtree.

    >>> self.portal.error_log._ignored_exceptions = ()
    >>> self.portal.left_slots = self.portal.right_slots = []
    >>> workflow = self.portal.portal_workflow

Verify that the forum is a free for all posting one by default:

    >>> workflow.doActionFor(self.forum, 'make_freeforall')
    >>> workflow.getInfoFor(self.forum, 'review_state')
    'freeforall'

View as anonymous
-----------------

Log out, and add new conversation.

    >>> browser.open(self.forum.absolute_url())
    >>> browser.getControl('Start a new Conversation').click()
    >>> browser.url
    '.../add_conversation_form...'

Check that we have a new field

    >>> browser.getControl(name='anon_name')
    <Control name='anon_name' type='text'>
    >>> browser.getControl(name='anon_name').value = 'John Doe'
    >>> browser.getControl('Title').value = 'John Doe posting title'
    >>> browser.getControl('Body text').value = 'Some fuzzy text'
    >>> browser.getControl(name='form.button.Post').click()
    >>> browser.url.startswith(self.forum.absolute_url())
    True
    >>> browser.contents
    '...John Doe posting title...by John Doe...'
    >>> conversation = self.forum.getConversations()[0]
    >>> browser.getLink('John Doe posting title').click()
    >>> browser.contents
    '...Some fuzzy text...'

An anonymous can also add a comment with his name

    >>> browser.getControl(name='anon_name')
    <Control name='anon_name' type='text'>
    >>> browser.getControl(name='anon_name').value = 'Joe Bloggs'
    >>> browser.getControl(name='text').value = 'A quick reply from Joe Bloggs'
    >>> browser.getControl(name='form.button.Post').click()
    >>> browser.url.startswith(conversation.absolute_url())
    True
    >>> "'...Posted by\n                Anonymous...'" not in browser.contents
    True
    >>> browser.contents
    '...Posted by\n                Joe Bloggs...'

If an anonymous doesn't set a name, default "Anonymous" name will be used

    >>> browser.getControl(name='text').value = 'A quick reply from an anonymous user'
    >>> browser.getControl(name='form.button.Post').click()
    >>> browser.url.startswith(conversation.absolute_url())
    True
    >>> browser.contents
    '...Posted by\n                Anonymous...'

Now, disable anonymous name settings and the field disappear from the comment form
    >>> utils.enableDisableAnonName(self, False)
    >>> browser.open(conversation.absolute_url())
    >>> browser.getControl(name='anon_name')
    Traceback (most recent call last):
    ...
    LookupError: name 'anon_name'

And also from dicussion form

    >>> browser.open(self.forum.absolute_url())
    >>> browser.getControl('Start a new Conversation').click()
    >>> browser.url
    '.../add_conversation_form...'
    >>> browser.getControl(name='anon_name')
    Traceback (most recent call last):
    ...
    LookupError: name 'anon_name'