==============================================================================
Doctest generated Mon Oct 15 2007 12:36:37 GMT+0200 (CEST)
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

Preparing the site to test for anonymous and logged in users behaviour of
address book in checkout

     >>> membership = self.portal.portal_membership
     >>> membership.addMember('testmanager', 'secret',
     ...             ['Member', 'Manager'], [])
     >>> membership.getMemberById('testmanager').setMemberProperties({'email':'testmember@getpaid.org','location':'here on earth'})
     >>> 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()
 
Setting required settings. (Especially anonymous checkout)

    >>> 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(name = 'form.allow_anonymous_checkout').value = True
    >>> 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('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
    >>> browser.getLink('Payment Options').click()
    >>> browser.getControl(name ='form.allow_anonymous_checkout').value
    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']

Here we set up the Credit cards accepted for payment:

   >>> options.accepted_credit_cards = ["Visa"]

Add a buyable document.

    >>> browser.getLink('Home').click()
    >>> browser.getLink('Make Buyable').click()
    >>> browser.getControl('Product Code').value = 'PAY-ME'
    >>> browser.getControl('Price').value = '42.17'
    >>> browser.getControl('Activate').click()

Now we need to be anonymous to test some stuff so

    >>> browser.getLink('Log out').click()
    
    
We want it so we buy it.

    >>> browser.getLink('Home').click()
    >>> 'Add to Cart' in browser.contents
    True
    >>> browser.getLink('Add to Cart').click()

And we do our anonymous checkout

    >>> browser.getControl('Checkout').click()

We check that the fields are empty, since anonymous should not have a 
profile from which take data

    >>> browser.getControl(name='form.email').value.strip() == ''
    True
    >>> browser.getControl(name='form.bill_first_line').value.strip() == ''
    True

And finally we check that our dear anonymous isn't wrongly offered to 
save his data on the Address book

    >>> 'Save to address book' not in browser.contents
    True

And now we check that the logged user is seing the button

    >>> browser.getLink('Log in').click()
    >>> browser.getControl('Login Name').value = 'testmanager'
    >>> browser.getControl('Password').value = 'secret'
    >>> browser.getControl('Log in').click()

    
We want it (again) so we buy it.

    >>> browser.getLink('Home').click()
    >>> 'Add to Cart' in browser.contents
    True
    >>> browser.getLink('Add to Cart').click()

And we do our anonymous checkout

    >>> browser.getControl('Checkout').click()

We check that the fields are not empty since now we are logged in

    >>> membership.getMemberById('testmanager').getProperty('email')
    'testmember@getpaid.org'
    >>> browser.getControl(name='form.bill_first_line').value.strip() == 'here on earth'
    True

And finally we check that the user gets offered to
save his data on the Address book

    >>> 'Save to address book' in browser.contents
    True
    
    >>> 'Load from address book' not in browser.contents
    True


Finished verification.
