def test_last_entries(self):
     self.create_published_entry()
     feed = LastEntries()
     self.assertEqual(feed.link(), '/')
     self.assertEqual(len(feed.items()), 1)
     self.assertEqual(feed.get_title(None), 'Last entries')
     self.assertEqual(
         feed.description(),
         'The last entries on the site example.com')
Beispiel #2
0
 def test_entry_feed_rss_or_atom(self):
     original_feeds_format = feeds.FEEDS_FORMAT
     feeds.FEEDS_FORMAT = ''
     feed = LastEntries()
     self.assertEqual(feed.feed_type, DefaultFeed)
     feeds.FEEDS_FORMAT = 'atom'
     feed = LastEntries()
     self.assertEqual(feed.feed_type, Atom1Feed)
     self.assertEqual(feed.subtitle, feed.description)
     feeds.FEEDS_FORMAT = original_feeds_format
Beispiel #3
0
 def test_entry_feed_rss_or_atom(self):
     original_feed_format = LastEntries.feed_format
     LastEntries.feed_format = ''
     feed = LastEntries()
     self.assertEqual(feed.feed_type, DefaultFeed)
     LastEntries.feed_format = 'atom'
     feed = LastEntries()
     self.assertEqual(feed.feed_type, Atom1Feed)
     self.assertEqual(feed.subtitle, feed.description)
     LastEntries.feed_format = original_feed_format
Beispiel #4
0
 def test_entry_feed_enclosure_replace_https_in_rss(self):
     entry = self.create_published_entry()
     feed = EntryFeed()
     entry.content = 'My test content with image in https ' \
                     '<img src="https://test.com/image.jpg" />'
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry),
                      'http://test.com/image.jpg')
     feed.protocol = 'https'
     entry.content = 'My test content with image <img src="image.jpg" />'
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry),
                      'http://example.com/image.jpg')
     path = default_storage.save('enclosure.png', ContentFile('Content'))
     entry.image = path
     entry.save()
     self.assertEqual(feed.item_enclosure_url(entry),
                      urljoin('http://example.com', entry.image.url))
     original_feed_format = LastEntries.feed_format
     LastEntries.feed_format = 'atom'
     feed = LastEntries()
     feed.protocol = 'https'
     self.assertEqual(feed.item_enclosure_url(entry),
                      urljoin('https://example.com', entry.image.url))
     LastEntries.feed_format = original_feed_format
     default_storage.delete(path)
Beispiel #5
0
 def test_last_entries(self):
     self.create_published_entry()
     feed = LastEntries()
     self.assertEqual(feed.link(), '/')
     self.assertEqual(len(feed.items()), 1)
     self.assertEqual(feed.get_title(None), 'Last entries')
     self.assertEqual(feed.description(),
                      'The last entries on the site example.com')
Beispiel #6
0
from zinnia.feeds import AuthorEntries
from zinnia.feeds import CategoryEntries
from zinnia.feeds import EntryComments
from zinnia.feeds import EntryDiscussions
from zinnia.feeds import EntryPingbacks
from zinnia.feeds import EntryTrackbacks
from zinnia.feeds import LastDiscussions
from zinnia.feeds import LastEntries
from zinnia.feeds import SearchEntries
from zinnia.feeds import TagEntries
from zinnia.urls import _


urlpatterns = [
    url(r'^$',
        LastEntries(),
        name='entry_feed'),
    url(_(r'^discussions/$'),
        LastDiscussions(),
        name='discussion_feed'),
    url(_(r'^search/$'),
        SearchEntries(),
        name='entry_search_feed'),
    url(_(r'^tags/(?P<tag>[^/]+(?u))/$'),
        TagEntries(),
        name='tag_feed'),
    url(_(r'^authors/(?P<username>[.+-@\w]+)/$'),
        AuthorEntries(),
        name='author_feed'),
    url(_(r'^categories/(?P<path>[-\/\w]+)/$'),
        CategoryEntries(),
Beispiel #7
0
 def test_title_with_sitename_implementation(self):
     feed = ZinniaFeed()
     self.assertRaises(NotImplementedError, feed.title)
     feed = LastEntries()
     self.assertEqual(feed.title(), 'example.com - Last entries')
Beispiel #8
0
from django.conf.urls import url

from zinnia.urls import _
from zinnia.feeds import LastEntries
from zinnia.feeds import TagEntries
from zinnia.feeds import AuthorEntries
from zinnia.feeds import CategoryEntries
from zinnia.feeds import SearchEntries
from zinnia.feeds import EntryComments
from zinnia.feeds import EntryPingbacks
from zinnia.feeds import EntryTrackbacks
from zinnia.feeds import EntryDiscussions
from zinnia.feeds import LastDiscussions

urlpatterns = [
    url(r'^$', LastEntries(), name='entry_feed'),
    url(_(r'^discussions/$'), LastDiscussions(), name='discussion_feed'),
    url(_(r'^search/$'), SearchEntries(), name='entry_search_feed'),
    url(_(r'^tags/(?P<tag>[^/]+(?u))/$'), TagEntries(), name='tag_feed'),
    url(_(r'^authors/(?P<username>[.+-@\w]+)/$'),
        AuthorEntries(),
        name='author_feed'),
    url(_(r'^categories/(?P<path>[-\/\w]+)/$'),
        CategoryEntries(),
        name='category_feed'),
    url(_(r'^discussions/(?P<year>\d{4})/(?P<month>\d{2})/'
          '(?P<day>\d{2})/(?P<slug>[-\w]+)/$'),
        EntryDiscussions(),
        name='entry_discussion_feed'),
    url(_(r'^comments/(?P<year>\d{4})/(?P<month>\d{2})/'
          '(?P<day>\d{2})/(?P<slug>[-\w]+)/$'),
Beispiel #9
0
from django.urls import path

from zinnia.feeds import AuthorEntries
from zinnia.feeds import CategoryEntries
from zinnia.feeds import EntryComments
from zinnia.feeds import EntryDiscussions
from zinnia.feeds import EntryPingbacks
from zinnia.feeds import EntryTrackbacks
from zinnia.feeds import LastDiscussions
from zinnia.feeds import LastEntries
from zinnia.feeds import SearchEntries
from zinnia.feeds import TagEntries
from zinnia.urls import _

urlpatterns = [
    path('', LastEntries(), name='entry_feed'),
    path(_('discussions/'), LastDiscussions(), name='discussion_feed'),
    path(_('search/'), SearchEntries(), name='entry_search_feed'),
    path(_('tags/<tag:tag>/'), TagEntries(), name='tag_feed'),
    path(_('authors/<username:username>/'),
         AuthorEntries(),
         name='author_feed'),
    path(_('categories/<path:path>/'), CategoryEntries(),
         name='category_feed'),
    path(_('discussions/<yyyy:year>/<mm:month>/<dd:day>/<slug:slug>/'),
         EntryDiscussions(),
         name='entry_discussion_feed'),
    path(_('comments/<yyyy:year>/<mm:month>/<dd:day>/<slug:slug>/'),
         EntryComments(),
         name='entry_comment_feed'),
    path(_('pingbacks/<yyyy:year>/<mm:month>/<dd:day>/<slug:slug>/'),