コード例 #1
0
def test_enclosure_addin():
    """Test the problem through and in the context of the enclosure
    handling addins (enclosures are one of the problem areas with respect
    to this bug.
    """

    ADDINS = [
        # both plugins separately exhibited the bug in the passed,
        # though note that ``collect_enclosure_data`` depends on
        # ``store_encloures`` and cannot be used without it
        store_enclosures(),
        collect_enclosure_data('length', 'type'),
    ]

    class BozoFeed(feedev.Feed):
        content = """
            <rss>
            <channel>
                <item>
                    <guid>item1</guid>
                    <enclosure href="http://h.com/p/f.mp3" length="10" />
                <!-- item closing tag missing -->
            </channel></rss>
        """

        def pass1(feed):
            # If the patch were not applied, we'd expect a Storm
            # "unicode expected" exception to be raised during
            # addin execution, the assertion here is just for
            # completeness sake.
            href = feed.items.one().enclosures.one().href
            assert href == 'http://h.com/p/f.mp3'
            assert type(href) == unicode

    feedev.testcaller()
コード例 #2
0
# TODO: better test enclosure href uniqueness

from feedplatform import test as feedev
from feedplatform.lib import store_enclosures
from feedplatform import db

ADDINS = [store_enclosures()]

class EnclosureFeed(feedev.Feed):
    content = """
        <rss><channel>
            <item>
                <enclosure href="http://example.org/files/1" />
                {% =2 %}<enclosure href="http://example.org/files/2" />{% end %}
                {% 4 %}<enclosure href="" />{% end %}
                {% 5 %}<enclosure />{% end %}
                <guid>item-1</guid>
            </item>
        </channel></rss>
    """

    def pass1(feed):
        # the enclosure was found
        assert feed.items.one().enclosures.count() == 1

    def pass2(feed):
        # a second enclosure was added
        assert feed.items.one().enclosures.count() == 2

    def pass3(feed):
        # the second enclosure was deleted again