Exemplo n.º 1
0
    def setUp(self):
        try:
            import feedparser
        except ImportError:
            raise SkipTest()

        super(TestFeeds, self).setUp()
        create_basic_categories(self)
        create_and_place_more_publishables(self)
        list_all_publishables_in_category_by_hour(self)

        self._feeder = RSSTopCategoryListings()
Exemplo n.º 2
0
    def test_get_enclosure_uses_formated_photo_when_format_available(self):
        f = Format.objects.create(name='enc_format', max_width=10, max_height=10,
            flexible_height=False, stretch=False, nocrop=False)

        feeder = RSSTopCategoryListings()
        feeder.format = f

        self._set_photo()
        tools.assert_true(self.publishables[0].photo is not None)
        original = self.publishables[0].photo.image
        new = self._feeder.item_enclosure_url(self.listings[0])
        tools.assert_not_equals(unicode(original), unicode(new))
Exemplo n.º 3
0
    def test_get_enclosure_uses_formated_photo_when_format_available(self):
        f = Format.objects.create(name='enc_format', max_width=10, max_height=10,
            flexible_height=False, stretch=False, nocrop=False)

        feeder = RSSTopCategoryListings()
        feeder.format = f

        self._set_photo()
        tools.assert_true(self.publishables[0].photo is not None)
        original = self.publishables[0].photo.image
        new = self._feeder.item_enclosure_url(self.listings[0])
        tools.assert_not_equals(unicode(original), unicode(new))
Exemplo n.º 4
0
    def setUp(self):
        try:
            import feedparser
        except ImportError:
            raise SkipTest()

        super(TestFeeds, self).setUp()
        create_basic_categories(self)
        create_and_place_more_publishables(self)
        list_all_publishables_in_category_by_hour(self)


        self._feeder = RSSTopCategoryListings()
Exemplo n.º 5
0
class TestFeeds(DatabaseTestCase):
    def setUp(self):
        try:
            import feedparser
        except ImportError, e:
            raise self.SkipTest()

        super(TestFeeds, self).setUp()
        create_basic_categories(self)
        create_and_place_a_publishable(self)
        create_and_place_more_publishables(self)
        list_all_placements_in_category_by_hour(self)

        self._feeder = RSSTopCategoryListings('test', HttpRequest())
Exemplo n.º 6
0
 def test_no_enclosure_when_format_not_set(self):
     feeder = RSSTopCategoryListings()
     feeder.format = None
     self._set_photo()
     tools.assert_true(self.publishables[0].photo is not None)
     tools.assert_equals(None, feeder.item_enclosure_url(self.listings[0]))
Exemplo n.º 7
0
class TestFeeds(TestCase):

    def setUp(self):
        try:
            import feedparser
        except ImportError:
            raise SkipTest()

        super(TestFeeds, self).setUp()
        create_basic_categories(self)
        create_and_place_more_publishables(self)
        list_all_publishables_in_category_by_hour(self)


        self._feeder = RSSTopCategoryListings()

    def tearDown(self):
        super(TestFeeds, self).tearDown()
        template_loader.templates.clear()

    def _set_photo(self):
        from test_ella.test_photos.fixtures import create_photo

        photo = create_photo(self)

        self.publishables[0].photo = photo
        self.publishables[0].save()
        # update the cache on the Listing object
        self.listings[0].publishable = self.publishables[0]

    def test_rss(self):
        import feedparser
        Listing.objects.all().update(category=self.category)
        url = reverse('home_rss_feed')
        c = self.client

        response = c.get(url)
        tools.assert_equals(200, response.status_code)
        d = feedparser.parse(response.content)

        tools.assert_equals(len(self.publishables), len(d['items']))

    def test_atom(self):
        import feedparser
        Listing.objects.all().update(category=self.category)
        url = reverse('home_atom_feed')
        c = self.client

        response = c.get(url)
        tools.assert_equals(200, response.status_code)
        d = feedparser.parse(response.content)

        tools.assert_equals(len(self.publishables), len(d['items']))

    def test_title_defaults_to_category_title(self):
        tools.assert_true(self._feeder.title(self.category), self.category.title)

    def test_title_uses_app_data_when_set(self):
        self.category.app_data = {'syndication': {'title': 'SYNDICATION_TITLE'}}
        tools.assert_true(self._feeder.title(self.category), 'SYNDICATION_TITLE')

    def test_description_defaults_to_category_title(self):
        tools.assert_true(self._feeder.title(self.category), self.category.title)

    def test_description_uses_app_data_when_set(self):
        self.category.app_data = {'syndication': {'description': 'SYNDICATION_DESCRIPTION'}}
        tools.assert_true(self._feeder.description(self.category), 'SYNDICATION_DESCRIPTION')

    def test_no_enclosure_when_format_not_set(self):
        feeder = RSSTopCategoryListings()
        feeder.format = None
        self._set_photo()
        tools.assert_true(self.publishables[0].photo is not None)
        tools.assert_equals(None, feeder.item_enclosure_url(self.listings[0]))

    def test_get_enclosure_uses_optional_hook_on_publishable(self):
        class A(object):
            @property
            def publishable(self):
                return self

            def feed_enclosure(self):
                return {'url': 'URL', 'size': 1000}

        tools.assert_equals('URL', self._feeder.item_enclosure_url(A()))
        tools.assert_equals(1000, self._feeder.item_enclosure_length(A()))

    def test_get_enclosure_uses_formated_photo_when_format_available(self):
        f = Format.objects.create(name='enc_format', max_width=10, max_height=10,
            flexible_height=False, stretch=False, nocrop=False)

        feeder = RSSTopCategoryListings()
        feeder.format = f

        self._set_photo()
        tools.assert_true(self.publishables[0].photo is not None)
        original = self.publishables[0].photo.image
        new = self._feeder.item_enclosure_url(self.listings[0])
        tools.assert_not_equals(unicode(original), unicode(new))

    def test_get_enclosure_returns_none_when_no_image_set(self):
        tools.assert_equals(self._feeder.item_enclosure_url(self.listings[0]), None)

    def test_item_description_defaults_to_publishable_description(self):
        feeder = RSSTopCategoryListings()
        feeder.box_context = {}
        tools.assert_equals(self.publishables[0].description, feeder.item_description(self.listings[0]))

    def test_box_rss_description_can_override_rss_description(self):
        template_loader.templates['box/rss_description.html'] = 'XXX'
        feeder = RSSTopCategoryListings()
        feeder.box_context = Context({})
        tools.assert_equals('XXX', feeder.item_description(self.listings[0]))
Exemplo n.º 8
0
 def test_box_rss_description_can_override_rss_description(self):
     template_loader.templates['box/rss_description.html'] = 'XXX'
     feeder = RSSTopCategoryListings()
     feeder.box_context = Context({})
     tools.assert_equals('XXX', feeder.item_description(self.listings[0]))
Exemplo n.º 9
0
 def test_item_description_defaults_to_publishable_description(self):
     feeder = RSSTopCategoryListings()
     feeder.box_context = {}
     tools.assert_equals(self.publishables[0].description, feeder.item_description(self.listings[0]))
Exemplo n.º 10
0
class TestFeeds(TestCase):
    def setUp(self):
        try:
            import feedparser
        except ImportError:
            raise SkipTest()

        super(TestFeeds, self).setUp()
        create_basic_categories(self)
        create_and_place_more_publishables(self)
        list_all_publishables_in_category_by_hour(self)

        self._feeder = RSSTopCategoryListings()

    def tearDown(self):
        super(TestFeeds, self).tearDown()
        template_loader.templates.clear()

    def _set_photo(self):
        from test_ella.test_photos.fixtures import create_photo

        photo = create_photo(self)

        self.publishables[0].photo = photo
        self.publishables[0].save()
        # update the cache on the Listing object
        self.listings[0].publishable = self.publishables[0]

    def test_rss(self):
        import feedparser
        Listing.objects.all().update(category=self.category)
        url = reverse('home_rss_feed')
        c = self.client

        response = c.get(url)
        tools.assert_equals(200, response.status_code)
        d = feedparser.parse(response.content)

        tools.assert_equals(len(self.publishables), len(d['items']))

    def test_guids_set_properly_in_rss(self):
        import feedparser
        Listing.objects.all().update(category=self.category)
        url = reverse('home_atom_feed')
        c = self.client

        response = c.get(url)
        tools.assert_equals(200, response.status_code)
        d = feedparser.parse(response.content)

        tools.assert_equals(len(d['items']),
                            len(set(i['guid'] for i in d['items'])))

    def test_atom(self):
        import feedparser
        Listing.objects.all().update(category=self.category)
        url = reverse('home_atom_feed')
        c = self.client

        response = c.get(url)
        tools.assert_equals(200, response.status_code)
        d = feedparser.parse(response.content)

        tools.assert_equals(len(self.publishables), len(d['items']))

    def test_title_defaults_to_category_title(self):
        tools.assert_true(self._feeder.title(self.category),
                          self.category.title)

    def test_title_uses_app_data_when_set(self):
        self.category.app_data = {
            'syndication': {
                'title': 'SYNDICATION_TITLE'
            }
        }
        tools.assert_true(self._feeder.title(self.category),
                          'SYNDICATION_TITLE')

    def test_description_defaults_to_category_title(self):
        tools.assert_true(self._feeder.title(self.category),
                          self.category.title)

    def test_description_uses_app_data_when_set(self):
        self.category.app_data = {
            'syndication': {
                'description': 'SYNDICATION_DESCRIPTION'
            }
        }
        tools.assert_true(self._feeder.description(self.category),
                          'SYNDICATION_DESCRIPTION')

    def test_no_enclosure_when_format_not_set(self):
        feeder = RSSTopCategoryListings()
        feeder.format = None
        self._set_photo()
        tools.assert_true(self.publishables[0].photo is not None)
        tools.assert_equals(None, feeder.item_enclosure_url(self.listings[0]))

    def test_get_enclosure_uses_optional_hook_on_publishable(self):
        class A(object):
            @property
            def publishable(self):
                return self

            def feed_enclosure(self):
                return {'url': 'URL', 'size': 1000}

        tools.assert_equals('URL', self._feeder.item_enclosure_url(A()))
        tools.assert_equals(1000, self._feeder.item_enclosure_length(A()))

    def test_get_enclosure_uses_formated_photo_when_format_available(self):
        f = Format.objects.create(name='enc_format',
                                  max_width=10,
                                  max_height=10,
                                  flexible_height=False,
                                  stretch=False,
                                  nocrop=False)

        feeder = RSSTopCategoryListings()
        feeder.format = f

        self._set_photo()
        tools.assert_true(self.publishables[0].photo is not None)
        original = self.publishables[0].photo.image
        new = self._feeder.item_enclosure_url(self.listings[0])
        tools.assert_not_equals(unicode(original), unicode(new))

    def test_get_enclosure_returns_none_when_no_image_set(self):
        tools.assert_equals(self._feeder.item_enclosure_url(self.listings[0]),
                            None)

    def test_item_description_defaults_to_publishable_description(self):
        feeder = RSSTopCategoryListings()
        feeder.box_context = {}
        tools.assert_equals(self.publishables[-1].description,
                            feeder.item_description(self.listings[0]))

    def test_box_rss_description_can_override_rss_description(self):
        template_loader.templates['box/rss_description.html'] = 'XXX'
        feeder = RSSTopCategoryListings()
        feeder.box_context = Context({})
        tools.assert_equals('XXX', feeder.item_description(self.listings[0]))

    def test_guid_is_set_properly(self):
        feeder = RSSTopCategoryListings()
        tools.assert_equals(str(self.publishables[-1].pk),
                            feeder.item_guid(self.listings[0]))
Exemplo n.º 11
0
 def test_guid_is_set_properly(self):
     feeder = RSSTopCategoryListings()
     tools.assert_equals(str(self.publishables[-1].pk),
                         feeder.item_guid(self.listings[0]))
Exemplo n.º 12
0
 def test_box_rss_description_can_override_rss_description(self):
     template_loader.templates['box/rss_description.html'] = 'XXX'
     feeder = RSSTopCategoryListings()
     feeder.box_context = Context({})
     tools.assert_equals('XXX', feeder.item_description(self.listings[0]))
Exemplo n.º 13
0
 def test_item_description_defaults_to_publishable_description(self):
     feeder = RSSTopCategoryListings()
     feeder.box_context = {}
     tools.assert_equals(self.publishables[-1].description,
                         feeder.item_description(self.listings[0]))
Exemplo n.º 14
0
 def test_no_enclosure_when_format_not_set(self):
     feeder = RSSTopCategoryListings()
     feeder.format = None
     self._set_photo()
     tools.assert_true(self.publishables[0].photo is not None)
     tools.assert_equals(None, feeder.item_enclosure_url(self.listings[0]))
Exemplo n.º 15
0
 def test_guid_is_set_properly(self):
     feeder = RSSTopCategoryListings()
     tools.assert_equals(str(self.publishables[-1].pk), feeder.item_guid(self.listings[0]))
Exemplo n.º 16
0
        list_content_type,
        name="category_list_year"),

    # static detail with custom action
    url(r'^%(cat)s/%(id)s-%(slug)s/%(rest)s$' % res,
        object_detail,
        name='static_detail_action'),
    url(r'^%(id)s-%(slug)s/%(rest)s$' % res,
        object_detail, {'category': ''},
        name='home_static_detail_action'),

    # static detail
    url(r'^%(cat)s/%(id)s-%(slug)s/$' % res,
        object_detail,
        name='static_detail'),
    url(r'^%(id)s-%(slug)s/$' % res,
        object_detail, {'category': ''},
        name='home_static_detail'),

    # rss feeds
    url(r'^feeds/$', RSSTopCategoryListings(), name='home_rss_feed'),
    url(r'^feeds/atom/$', AtomTopCategoryListings(), name='home_atom_feed'),
    url(r'^%(cat)s/feeds/$' % res, RSSTopCategoryListings(), name='rss_feed'),
    url(r'^%(cat)s/feeds/atom/$' % res,
        AtomTopCategoryListings(),
        name='atom_feed'),

    # category homepage
    url(r'^%(cat)s/$' % res, category_detail, name="category_detail"),
)