=====================================
SQL Server configlet
=====================================

Create the browser object we'll be using.

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> portal_url = self.portal.absolute_url()
    >>> browser.handleErrors = False
    >>> self.portal.error_log._ignored_exceptions = ()

Some initial setup code:

    >>> from zope.component import getUtility
    >>> from icnews.acquire.interfaces import IicNewsManagementAcquireSQLServer
    >>> settings = getUtility(IicNewsManagementAcquireSQLServer, name='icnews.configuration', context=self.portal)
    >>> self.loginAsPortalOwner()

    >>> settings.hostname = 'localhost'
    >>> settings.username = 'admin'
    >>> settings.password = u'admin'

Log in into the site as manager.

    >>> from Products.PloneTestCase.setup import portal_owner, default_user, default_password
    >>> login_url = portal_url + '/login_form'
    >>> logout_url = portal_url + '/logout'
    >>> browser.open(login_url)

We have the login portlet, so let's use that.

    >>> 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)

Viewing the SQL server control panel.

    >>> browser.getLink('Site Setup').click()
    >>> browser.getLink('icNews').click()
    >>> browser.getLink('News Acquire SQL Server').click()
    >>> browser.url
    'http://nohost/plone/@@manage-news-acquire-sql-server'

Click the save button without making any changes:

    >>> browser.getControl("Apply").click()
    >>> browser.url.endswith('manage-news-acquire-sql-server')
    True

We should get a status message telling that there were errors because there some
required fields.

    >>> 'There were errors' in browser.contents
    True

Make some changes.

    >>> browser.open('http://nohost/plone/@@manage-news-acquire-sql-server')
    >>> browser.url.endswith('manage-news-acquire-sql-server')
    True

    >>> browser.getControl(name='form.hostname').value = 'http://localhost.com'
    >>> browser.getControl(name='form.username').value = 'admin2'
    >>> browser.getControl(name='form.password').value = 'admin2'

Click the save button:

    >>> browser.getControl("Apply").click()
    >>> browser.url.endswith('manage-news-acquire-sql-server')
    True

We get an error because there is no server running...

    >>> 'Error' in browser.contents
    True

