Solr control panel
==================

First some initial setup code:

    >>> self.loginAsManager()
    >>> from zope.component import getUtility
    >>> from collective.solr.interfaces import ISolrConnectionConfig
    >>> config = getUtility(ISolrConnectionConfig)
    >>> config.active
    False
    >>> config.host
    '127.0.0.1'
    >>> config.port
    8983
    >>> config.base
    '/solr'
    >>> config.async
    False
    >>> config.index_timeout
    0.0
    >>> config.search_timeout
    0.0
    >>> config.max_results
    0
    >>> config.required
    ('SearchableText',)

Viewing the site control panel
-----------------------------

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

Check for the icon to exist:

    >>> self.browser.contents
    '...<img src="http://nohost/plone/++resource++collective.solr.images/icon.png"...'

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/@@solr-controlpanel')
    >>> self.browser.url.endswith('solr-controlpanel')
    True

    >>> self.browser.getControl(name='form.active').value = True
    >>> self.browser.getControl(name='form.host').value = 'foo.bar'
    >>> self.browser.getControl(name='form.port').value = '1234'
    >>> self.browser.getControl(name='form.base').value = '/solr'
    >>> self.browser.getControl(name='form.async').value = True
    >>> self.browser.getControl(name='form.index_timeout').value = '7'
    >>> self.browser.getControl(name='form.search_timeout').value = '3.1415'
    >>> self.browser.getControl(name='form.max_results').value = '23'
    >>> self.browser.getControl(name='form.required.0.').value = 'foo'
    >>> self.browser.getControl(name='form.required.add').click()
    >>> self.browser.getControl(name='form.required.1.').value = 'bar'

Click the save button:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('solr-controlpanel')
    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:

    >>> config.active
    True
    >>> config.host
    u'foo.bar'
    >>> config.port
    1234
    >>> config.base
    '/solr'
    >>> config.async
    True
    >>> config.index_timeout
    7.0
    >>> config.search_timeout
    3.1415...
    >>> config.max_results
    23
    >>> config.required
    [u'foo', u'bar']

