
==============================================================================
Doctest half generated half handwritten
created by perrito
==============================================================================

Create the browser object we'll be using.

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> browser.handleErrors = False
    >>> browser.open(portal.absolute_url())
    >>> 'Welcome to Plone' in browser.contents
    True
    >>> membership = self.portal.portal_membership
    >>> membership.addMember('testmanager', 'secret',
    ...		     ['Member', 'Manager'], [])

    >>> browser.getLink('Log in').click()
    >>> browser.getControl('Login Name').value = 'testmanager'
    >>> browser.getControl('Password').value = 'secret'
    >>> browser.getControl('Log in').click()
    >>> self.portal.portal_quickinstaller.installProduct('PloneGetPaid')
    ''
    >>> browser.getLink('Home').click()
     
Testing the setup aspects of GetPaid. Setting required settings. 

    >>> browser.getLink('Site Setup').click()
    >>> browser.getLink('GetPaid').click()
    >>> browser.getLink('Site Profile').click()
    >>> browser.getControl('Contact Email').value = 'info@plonegetpaid.com'
    >>> browser.getControl( name="form.store_name").value = 'Test this fake company'
    >>> browser.getControl('Contact Country').value = ['US']
    >>> browser.getControl('Apply').click()
    >>> browser.getLink('GetPaid').click()
    >>> browser.getLink('Content Types').click()
    >>> browser.getLink('GetPaid').click()
    >>> browser.getLink('Payment Options').click()
    >>> browser.getControl(name = 'form.payment_processor').displayValue = ['Testing Processor']
    >>> browser.getControl(name = 'form.allow_anonymous_checkout.used').value = 'on'
    >>> browser.getControl('Apply').click()
    >>> browser.getLink('GetPaid').click()
    >>> browser.getLink('Payment Processor Settings').click()
    >>> browser.getControl(name="form.allow_authorization").displayValue = ['allow_authorization']
    >>> browser.getControl(name="form.allow_capture").displayValue = ['allow_capture']
    >>> browser.getControl(name="form.allow_refunds").displayValue = ['allow_refund']    
    >>> browser.getControl('Apply').click()
    >>> browser.getLink('GetPaid').click()
    >>> browser.getLink('Legal Disclaimers').click()
    >>> browser.getControl(name='form.disclaimer').value = 'Test disclaimer'
    >>> browser.getControl(name='form.privacy_policy').value = 'Test privacy policy'
    >>> browser.getControl('Apply').click()
    >>> browser.getLink('GetPaid').click() 
    >>> 'Test this fake company' in browser.contents
    True


Here we are setting the buyable types for use in the following tests
  
    >>> from Products.PloneGetPaid.interfaces import IGetPaidManagementOptions
    >>> options = IGetPaidManagementOptions(self.portal)
    >>> options.buyable_types = ['Document']
    >>> options.donate_types = ['Document']
    >>> options.shippable_types = ['Document']


Check to make sure the settings we put in Site Profile appear on this page. 

    >>> browser.getLink('Home').click()

Testing process of configuring Plone content for "buyable" states of donation, buyable and shippable. Depends on options that were set in the admin functional tests. 

Make Buyable

    >>> browser.getLink('Make Buyable').click()
    >>> browser.getControl(name='form.product_code').value = 'Test Buy Code'
    >>> browser.getControl(name='form.price').value = '10.00'
    >>> browser.getControl('Activate').click()

Buy

    >>> browser.getControl('Add to Cart').click()
    >>> 'SubTotal' in browser.contents
    True

Set item quantity to 0 so the product is removed from the cart

    >>> import sre
    >>> regex = sre.compile("edit\..*?\.quantity")
    >>> try:
    ...     editName = regex.findall(browser.contents)[0]
    ...     browser.getControl(name=editName).value = '0'
    ...     browser.getControl('Update').click()
    ...     'subtotal' in browser.contents
    ... except:
    ...     # And Just in case the regex finds nothing we fail because we
    ...     # should have at least one
    ...     True
    False
