Syndication
===========

First we need to make sure the container feed class can be instantiated.

    >>> from p4a.ploneaudio.syndication import AudioContainerFeed
    >>> AudioContainerFeed(None)
    <p4a.ploneaudio.syndication.AudioContainerFeed ...>

Next we can get the feed source and ask it for entries.  But before we
can do that we need to hookup a mock ``IAudioProvider`` adapter.

    >>> from zope.interface import implements
    >>> from Products.basesyndication.interfaces import IFeedEntry, IEnclosure
    >>> from p4a.ploneaudio.syndication import AudioContainerFeedSource
    >>> from p4a.audio.interfaces import IAudioProvider
    >>> class MockFolder(object):
    ...     implements(IAudioProvider, IFeedEntry)
    ...     audio_items = []

    >>> AudioContainerFeedSource(MockFolder()).getFeedEntries()
    []

Now that the feed container information has been setup we can test the
audio items specifically.  But first we check the audio source.

    >>> from p4a.ploneaudio.syndication import AudioFeedSource
    >>> AudioFeedSource(MockFolder()).getFeedEntries()
    [<MockFolder object ...>]

And now we check the feed entries.

    >>> from p4a.ploneaudio.syndication import AudioFeedEntry
    >>> from p4a.audio.interfaces import IAudio 
    >>> class MockAudio(object):
    ...     implements(IAudio, IEnclosure)
    ...     title = u'Mock audio'
    ...     artist = u'Mock artist'
    ...     description = u'Mock description'
    ...     genre = 4
    >>> entry = AudioFeedEntry(MockAudio())
    >>> entry
    <p4a.ploneaudio.syndication.AudioFeedEntry instance ...>

    >>> entry.getBody()
    ''

    >>> entry.getEnclosure()
    <MockAudio object ...>

    >>> entry.getTitle()
    u'Mock audio'

    >>> entry.getArtist()
    u'Mock artist'

    >>> entry.getDescription()
    u'Mock description'

    >>> entry.getCategory()
    'Disco'

Of course if we set a radical genre id that doesn't exist, we get empty
behaviour.

    >>> entry.context.genre = 900000
    >>> entry.getCategory()
    u''

As far as actual enclosure support is concerned, we can see here what happens.

    >>> from p4a.ploneaudio.syndication import ATFileEnclosure
    >>> class MockContent(object):
    ...     def __init__(self, **kwargs):
    ...         for k, v in kwargs.items(): setattr(self, k, v)
    ...     def absolute_url(self): return 'http://nohost.com/someurl'
    ...     def getFile(self):
    ...         return MockContent(get_size=lambda: 10,
    ...                            getContentType=lambda: 'text/plain')
    >>> enclosure = ATFileEnclosure(MockContent())
    >>> enclosure
    <p4a.ploneaudio.syndication.ATFileEnclosure object ...>

    >>> enclosure.getURL()
    'http://nohost.com/someurl'

    >>> enclosure.getLength()
    10

    >>> len(enclosure)
    10

    >>> enclosure.getMajorType()
    'text'

    >>> enclosure.getMinorType()
    'plain'

    >>> enclosure.getType()
    'text/plain'

