
==============================================================================
Doctest generated Sat Oct 13 2007 18:39:12 GMT+0200 (CEST)
created by cjj
==============================================================================

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')
     'Installing Dependencies\n'
     >>> 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'

Note: setting 'displayValue = ['UNITED STATES']' would give an
AmbiguityError as the browser does not understand that we do not mean
'UNITED STATES MINO' which is also an option.  So we set an
unambiguous value::

    >>> 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('Email Notifications').click()
    >>> browser.getControl(name='form.merchant_email_notification').displayValue = ['Do not send merchant email notification of a completed transaction']
    >>> browser.getControl(name='form.customer_email_notification').displayValue = ['Do not send customer email notification of a completed transaction']
    >>> 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']
    >>> options.buyable_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. 

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

Test for expected results in home page.  There should be a link to reverse it and a price in the portlet on the right

    >>> browser.getLink('Home').click()
    >>> 'Make Not Buyable' in browser.contents
    True
    >>> '10.00' in browser.contents
    True
    
Reverse buyable

    >>> browser.getLink('Make Not Buyable').click()    
    >>> browser.getLink('Home').click()
    >>> 'Make Buyable' in browser.contents
    True

Test make shippable

    >>> browser.getLink('Make Shippable Product').click()
    >>> browser.getControl('Price').value = '1'
    >>> browser.getControl('Dimensions').value = '1 lb'
    >>> browser.getControl('Product SKU').value = '1234'
    >>> browser.getControl('Shipping Weight').value = '1234'
    >>> browser.getControl('Weight Unit').displayValue = ['lbs']
    >>> browser.getControl('Activate').click()

Test for expected results

    >>> browser.getLink('Home').click()
    >>> 'Make Not Shippable Product' in browser.contents
    True
    >>> '1.00' in browser.contents
    True

Reverse shippable

    >>> browser.getLink('Make Not Shippable Product').click()    
    >>> browser.getLink('Home').click()
    >>> 'Make Shippable Product' in browser.contents
    True


Test Donatable

    >>> browser.getLink('Make this a Donation').click()
    >>> browser.getControl(name='form.donation_text').value = 'Test donation description'
    >>> browser.getControl(name='form.price').value = '11.00'
    >>> browser.getControl('Activate').click()


Test for expected results in home page.  There should be a link to reverse it and a price in the portlet on the right

    >>> browser.getLink('Home').click()
    >>> 'Make this not a Donation' in browser.contents
    True
    >>> '11.00' in browser.contents
    True

Reverse it

    >>> browser.getLink('Make this not a Donation').click()    
    >>> browser.getLink('Home').click()    
    >>> 'Make this a Donation' in browser.contents
    True


