============
Introduction
============

This is the test file from iservices.rssdocument.


Preeliminary setup
-------------------

Being a doctest, we can tell a story here. 

First, we must perform some setup. We use the testbrowser that is shipped
with Five, as this provides proper Zope 2 integration. Most of the 
documentation, though, is in the underlying zope.testbrower package.

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> portal_url = self.portal.absolute_url()

The following is useful when writing and debugging testbrowser tests. It lets
us see all error messages in the error_log.

    >>> self.portal.error_log._ignored_exceptions = ()

With that in place, we can go to the portal front page and log in. We will
do this using the default user from PloneTestCase:

    >>> from Products.PloneTestCase.setup import portal_owner, default_password

    >>> browser.open(portal_url+'/login_form')

    >>> browser.getControl(name='__ac_name').value = portal_owner
    >>> browser.getControl(name='__ac_password').value = default_password
    >>> browser.getControl(name='submit').click()

Here, we set the value of the fields on the login form and then simulate a
submit click.

Go back to the front page:

    >>> browser.open(portal_url)
    >>> browser.url == portal_url
    True


Testing import
---------------
We should already be installed::

    >>> import iservices.rssdocument


Testing creation of RSSDocument
--------------------------------

    >>> browser.open(portal_url)

Verify that we have the links to create RSSDocument, from the add
item menu:

    >>> browser.getLink(id='rssdocument').url.endswith("createObject?type_name=RSSDocument")
    True

So, let's click on it and fill-in the form:

    >>> browser.getLink(id='rssdocument').click()
    >>> browser.getControl(name='title').value = "myrss"
    >>> browser.getControl(name='description').value = "Description of RSS Document 1"
    >>> browser.getControl(name='RSSLink').value = "http://somehost/blog/rss.xml"
    >>> browser.getControl(name='max_entries').value = "5"
    >>> browser.getControl(name='form.button.save').click()
    
    >>> 'myrss' in self.portal.objectIds()
    True
    >>> rssdoc = self.portal['myrss']
    >>> rssdoc.getRSSLink() == "http://somehost/blog/rss.xml"
    True
    
Testing JavaScript code
--------------------------------

Open the zrssfeed Jquery Plugin::

    >>> browser.open(portal_url+'/++resource++jquery.zrssfeed.min.js')

And, make sure it's got our code in it::

    >>> print browser.contents
    /* zrssfeed jquery plugin http://www.zazar.net/developers/zrssfeed/ */
    ...

Check if the above script is being included in the RSSDocument page

    >>> browser.open(portal_url+'/myrss')
    >>> '++resource++jquery.zrssfeed.min.js' in browser.contents
    True

Next. Open the generated javascript code from the @@rss_code browserview ::

    >>> browser.open(portal_url+'/myrss/@@rss_code.js')

And, make sure it's got the right javascript variables ::

    >>> print browser.contents
    jq(document).ready(function () {jq('#rsscontainer').rssfeed('http://somehost/blog/rss.xml', {limit: 5});});


