=========================
 click2sell control panel
=========================

These tests are adapted from that in plone.app.controlpanel 

First some initial setup code:

    >>> from zope.component import getUtility
    >>> from niteoweb.click2sell.interfaces import IClick2SellSettings
    >>> configuration = getUtility(IClick2SellSettings)
    >>> self.login_with_browser(self.browser)

    >>> configuration.secret_key = 'secret'


Viewing the click2sell control panel
-----------------------------------------------

    >>> self.browser.open('http://nohost/plone/@@configure-click2sell')
    >>> self.browser.url
    'http://nohost/plone/@@configure-click2sell'

Click the save button without making any changes:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('configure-click2sell')
    True

We should get a status message:

    >>> 'Changes saved.' in self.browser.contents
    True

Now click the cancel button:

    >>> self.browser.getControl(name="form.actions.cancel").click()
    >>> self.browser.url.endswith('plone_control_panel')
    True

There should be still no changes:

    >>> 'Changes canceled.' in self.browser.contents
    True

Make some changes
-----------------

    >>> self.browser.open('http://nohost/plone/@@configure-click2sell')
    >>> self.browser.url.endswith('configure-click2sell')
    True

    >>> self.browser.getControl(name='form.secret_key').value = 'new secret'

Click the save button:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('configure-click2sell')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in self.browser.contents
    True

Make sure the changes have been applied correctly to the tool:

    >>> configuration.secret_key
    u'new secret'
