==============================================================================
Doctest generated Fri Sep 05 2008 15:18:11 GMT-0300 (ART)
created by walteralini
==============================================================================

We create the browser to make all tests

    >>> portal_url = portal.absolute_url()
    >>> browser = self.browser

Let's login first as the portal admin

    >>> from Products.PloneTestCase.setup import portal_owner, default_password
    >>> browser.open(portal_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()

I will test warehouse add interface

    >>> browser.getLink('Site Setup').click()
    >>> browser.getLink('GetPaid').click()
    >>> browser.getLink('Warehouses').click()
    >>> browser.getControl('Add').click()

Testing failed add

    >>> browser.getControl('Add Warehouse').click()
    >>> 'There were errors' in browser.contents
    True
    >>> browser.getControl('Warehouse Name').value = 'warehouse1'
    >>> browser.getControl('Add Warehouse').click()
    >>> 'There were errors' in browser.contents
    True
    >>> browser.getControl('Warehouse Name').value
    'warehouse1'
    >>> browser.getControl('Address 1').value = 'Street 244'
    >>> browser.getControl('Add Warehouse').click()
    >>> 'There were errors' in browser.contents
    True
    >>> browser.getControl(name='form.city').value = 'Chicago'
    >>> browser.getControl(name='form.state').value = ('US-IL',)
    >>> browser.getControl('Zip/Postal Code').value = '60601'
    >>> browser.getControl('Add Warehouse').click()
    >>> 'Warehouse Information' in browser.contents
    True
    >>> 'warehouse1' in browser.contents
    True
    >>> 'Street 244' in browser.contents
    True
    >>> 'Chicago' in browser.contents
    True
    >>> 'Illinois' in browser.contents
    True
    >>> '60601' in browser.contents
    True

We return to the warehouses menu

    >>> browser.getLink('Up to GetPaid Setup').click()
    >>> browser.getLink('Warehouses').click()
    >>> 'warehouse1' in browser.contents
    True
    >>> browser.getControl('Add').click()

Adding another warehouse, just to test deletion

    >>> browser.getControl('Warehouse Name').value = 'warehouse2'
    >>> browser.getControl('Address 1').value = 'Street 244'
    >>> browser.getControl(name='form.city').value = 'Chicago'
    >>> browser.getControl(name='form.state').value = ('US-IL',)
    >>> browser.getControl('Zip/Postal Code').value = '60601'
    >>> browser.getControl('Add Warehouse').click()

Go to the warehouse menu, and delete the last we add

    >>> browser.getLink('Up to GetPaid Setup').click()
    >>> browser.getLink('Warehouses').click()
    >>> 'warehouse2' in browser.contents
    True

Ok, seems deletion is not trivial, because of automatic generated names in warehouse options.
Trying to be as neat as possible:

    >>> import re
    >>> pattern = re.compile('name="selection_column\.[^"]*?==\."')
    >>> all_inputs = re.findall(pattern, browser.contents)

Now, I suppose warehouse2 (which I want to delete) is the second place of all_inputs:

    >>> w2_name = all_inputs[1].split('"')[1]
    >>> browser.getControl(name=w2_name).value = True
    >>> browser.getControl('Delete').click()
    >>> 'warehouse2' not in browser.contents
    True
    >>> 'warehouse1' in browser.contents
    True
