Uploading the contents of a document
====================================

Test setup.

    >>> import cStringIO
    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> browser.open('http://nohost/plone')
    
Log in.
    
    >>> from Products.PloneTestCase.setup import portal_owner, default_password
    >>> browser.getControl('Login Name').value = portal_owner
    >>> browser.getControl('Password').value = default_password
    >>> browser.getControl('Log in').click()
    
Let's create a new document, ending up at its edit form.

    >>> browser.getLink('Add new').click()
    >>> 'Add new item' in browser.contents
    True
    >>> browser.getControl('Page').click()
    >>> browser.getControl('Add').click()
    >>> browser.url
    'http://nohost/plone/portal_factory/Document/document.../edit'
    
Now upload a file.  The uploaded file should take precedence over the
contents of the text field, if any.

    >>> browser.getControl(name='title').value = 'test document'
    >>> browser.getControl(name='text').value = 'This will be ignored.'
    >>> browser.getControl(name='text_file').add_file(cStringIO.StringIO('file contents'), 'text/plain', 'test.txt')
    >>> browser.getControl('Save').click()
    >>> browser.url
    'http://nohost/plone/test-document'
    >>> 'file contents' in browser.contents
    True
    >>> 'This will be ignored.' in browser.contents
    False

