Functional test for Resource booking through the resource container
===================================================================

Let's log in:

    >>> manager = Browser()
    >>> manager.addHeader('Authorization', 'Basic manager:schooltool')
    >>> manager.handleErrors = False
    >>> manager.open('http://localhost/')

And add a couple of resources to book:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Resources').click()
    >>> manager.getLink('Add Location').click()
    >>> manager.getControl('Title').value = 'mud'
    >>> manager.getControl('Add').click()
    >>> manager.getLink('Resource', index=2).click()
    >>> 'mud' in manager.contents
    True

    >>> manager.getLink('Add Resource').click()
    >>> manager.getControl('Title').value = 'fish'
    >>> manager.getControl('Add').click()
    >>> manager.getLink('Resource', index=3).click()
    >>> 'fish' in manager.contents
    True

And a few events to our calendar:

    >>> manager.getLink('Calendar').click()
    >>> manager.getLink('New Event').click()
    >>> manager.getControl('Title').value = "Some big event"
    >>> manager.getControl('Date').value = "2005-01-15"
    >>> manager.getControl('Time').value = "10:15"
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Event').click()
    >>> manager.getControl('Title').value = "Some other big event"
    >>> manager.getControl('Date').value = "2005-01-15"
    >>> manager.getControl('Time').value = "12:35"
    >>> manager.getControl('Add').click()

    >>> manager.getLink('New Event').click()
    >>> manager.getControl('Title').value = "Some other big event"
    >>> manager.getControl('Date').value = "2005-01-16"
    >>> manager.getControl('Time').value = "17:35"
    >>> manager.getControl('Add').click()

And a couple of events to our resource calendars:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Resources').click()
    >>> manager.getLink('Resource', index=3).click()
    >>> manager.getLink('fish').click()
    >>> manager.getLink('View Calendar').click()

    >>> manager.getLink('New Event').click()
    >>> manager.getControl('Title').value = "A small event"
    >>> manager.getControl('Date').value = "2005-01-15"
    >>> manager.getControl('Time').value = "11:55"
    >>> manager.getControl('Add').click()


    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Resources').click()
    >>> manager.getLink('Resource', index=2).click()
    >>> manager.getLink('mud').click()
    >>> manager.getLink('View Calendar').click()

    >>> manager.getLink('New Event').click()
    >>> manager.getControl('Title').value = "Another small event"
    >>> manager.getControl('Date').value = "2005-01-15"
    >>> manager.getControl('Time').value = "10:55"
    >>> manager.getControl('Add').click()

Now if we go to the resource container and select both resources for
booking:

    >>> manager.getLink('Manage').click()
    >>> manager.getLink('Resources').click()
    >>> manager.getLink('Resource', index=3).click()

    >>> manager.getControl(name='delete.fish').value = ['delete.fish']

And go to their booking calendar:

    >>> manager.getControl('Book').click()

When we select the right date we should see a booking event:

    >>> manager.handleErrors = False
    >>> manager.open("%s/%s" % (manager.url, '2005-01-15'))
    >>> manager.getLink('fish').click()

Now we should have booked a 'fish' for the '2005-01-15' and we have
been redirected on the 2005-01-15 view:

    >>> manager.getControl('Title').value
    'Some big event'

    >>> manager.getControl('Date').value
    '2005-01-15'

And the fish resource is well booked:

    >>> manager.getLink('Book resources').click()
    >>> print analyze.queryHTML('//label[@for="remove_item.fish"]', manager.contents)[0]
    <label for="remove_item.fish">fish</label>

